mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Client Fixes (#9050)
* reset yesterdailies array after cron has run * start to fix gifting * remove unused code, move encodegift * wip * fix styles and bugs * fix error if amazon is slow to load its script * fix error notifications not showing up
This commit is contained in:
@@ -1,35 +1,43 @@
|
||||
import axios from 'axios';
|
||||
|
||||
let AUTH_SETTINGS = localStorage.getItem('habit-mobile-settings');
|
||||
let API_TOKEN = '';
|
||||
let API_ID = '';
|
||||
if (AUTH_SETTINGS) {
|
||||
AUTH_SETTINGS = JSON.parse(AUTH_SETTINGS);
|
||||
API_ID = AUTH_SETTINGS.auth.apiId;
|
||||
API_TOKEN = AUTH_SETTINGS.auth.apiToken;
|
||||
}
|
||||
|
||||
const STRIPE_PUB_KEY = process.env.STRIPE_PUB_KEY; // eslint-disable-line
|
||||
import subscriptionBlocks from '../../common/script/content/subscriptionBlocks';
|
||||
import { mapState } from 'client/libs/store';
|
||||
import notificationsMixin from 'client/mixins/notifications';
|
||||
|
||||
let StripeCheckout = window.StripeCheckout;
|
||||
|
||||
export default {
|
||||
mixins: [notificationsMixin],
|
||||
computed: {
|
||||
...mapState(['credentials']),
|
||||
paypalCheckoutLink () {
|
||||
return `/paypal/checkout?_id=${API_ID}&apiToken=${API_TOKEN}`;
|
||||
return `/paypal/checkout?_id=${this.credentials.API_ID}&apiToken=${this.credentials.API_TOKEN}`;
|
||||
},
|
||||
paypalSubscriptionLink () {
|
||||
return `/paypal/subscribe?_id=${API_ID}&apiToken=${API_TOKEN}&sub=${this.subscriptionPlan}`;
|
||||
return `/paypal/subscribe?_id=${this.credentials.API_ID}&apiToken=${this.credentials.API_TOKEN}&sub=${this.subscriptionPlan}`;
|
||||
},
|
||||
paypalPurchaseLink () {
|
||||
if (!this.subscription) return '';
|
||||
let couponString = '';
|
||||
if (this.subscription.coupon) couponString = `&coupon=${this.subscription.coupon}`;
|
||||
return `/paypal/subscribe?_id=${API_ID}&apiToken=${API_TOKEN}&sub=${this.subscription.key}${couponString}`;
|
||||
return `/paypal/subscribe?_id=${this.credentials.API_ID}&apiToken=${this.credentials.API_TOKEN}&sub=${this.subscription.key}${couponString}`;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
encodeGift (uuid, gift) {
|
||||
gift.uuid = uuid;
|
||||
let encodedString = JSON.stringify(gift);
|
||||
return encodeURIComponent(encodedString);
|
||||
},
|
||||
openPaypalGift (data) {
|
||||
if (!this.checkGemAmount(data)) return;
|
||||
|
||||
let gift = this.encodeGift(data.giftedTo, data.gift);
|
||||
const url = `/paypal/checkout?_id=${this.credentials.API_ID}&apiToken=${this.credentials.API_TOKEN}&gift=${gift}`;
|
||||
|
||||
window.open(url, '_blank');
|
||||
},
|
||||
showStripe (data) {
|
||||
if (!this.checkGemAmount(data)) return;
|
||||
|
||||
@@ -56,7 +64,7 @@ export default {
|
||||
description: sub ? this.$t('subscribe') : this.$t('checkout'),
|
||||
image: '/apple-touch-icon-144-precomposed.png',
|
||||
panelLabel: sub ? this.$t('subscribe') : this.$t('checkout'),
|
||||
token: async (res) => {
|
||||
async token (res) {
|
||||
let url = '/stripe/checkout?a=a'; // just so I can concat &x=x below
|
||||
|
||||
if (data.groupToCreate) {
|
||||
@@ -72,6 +80,7 @@ export default {
|
||||
|
||||
let response = await axios.post(url, res);
|
||||
|
||||
// @TODO handle with normal notifications?
|
||||
let responseStatus = response.status;
|
||||
if (responseStatus >= 400) {
|
||||
alert(`Error: ${response.message}`);
|
||||
@@ -82,6 +91,7 @@ export default {
|
||||
if (newGroup && newGroup._id) {
|
||||
// @TODO: Just append? or $emit?
|
||||
this.$router.push(`/group-plans/${newGroup._id}/task-information`);
|
||||
// @TODO action
|
||||
this.user.guilds.push(newGroup._id);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user