Fall Festival Gem Promo (#138)

* content: add gems blocks

* gemsBlocks: include ios and android identifiers

* wip: promo code

* split common constants into multiple files

* add second promo part

* geCurrentEvent, refactor promo

* fix lint

* fix exports, use world state api

* start adding world state tests

* remove console.log

* use gems block for purchases

* remove comments

* fix most unit tests

* restore comment

* fix lint

* prevent apple/google gift tests from breaking other tests when stub is not reset

* fix unit tests, clarify tests names

* iap: use gift object when gifting gems

* allow gift object with less data

* fix iap tests, remove findById stubs

* iap: require less data from the mobile apps

* apply discounts

* add missing worldState file

* fix lint

* add test event

* start removing 20 gems option for web

* start adding support for all gems packages on web

* fix unit tests for apple, stripe and google

* amazon: support all gems blocks

* paypal: support all gems blocks

* fix payments unit tests, add tests for getGemsBlock

* web: add gems plans with discounts, update stripe

* fix amazon and paypal clients, payments success modals

* amazon pay: disabled state

* update icons, start abstracting payments buttons

* begin redesign

* redesign gems modal

* fix buttons

* fix hover color for gems modal close icon

* add key to world state current event

* extend test event length

* implement gems modals designs

* early test fall2020

* fix header banner position

* add missing files

* use iso 8601 for dates, minor ui fixes

* fix time zones

* events: fix ISO8601 format

* fix css indentation

* start abstracting banners

* refactor payments buttons

* test spooky, fix group plans box

* implement gems promo banners, refactor banners, fixes

* fix lint

* fix dates

* remove unused i18n strings

* fix stripe integration test

* fix world state integration tests

* the current active event

* add missing unit tests

* add storybook story for payments buttons component

* fix typo

* fix(stripe): correct label when gifting subscriptions
This commit is contained in:
Matteo Pagliazzi
2020-09-21 16:22:13 +02:00
committed by GitHub
parent 82e6d544c8
commit 83aca20ce5
95 changed files with 1776 additions and 1099 deletions

View File

@@ -15,10 +15,10 @@
<h3 class="panel-heading clearfix">
<div class="float-right">
<span
v-if="gift.gems.fromBalance"
v-if="fromBal"
>{{ $t('sendGiftGemsBalance', {number: userLoggedIn.balance * 4}) }}</span>
<span
v-if="!gift.gems.fromBalance"
v-else
>{{ $t('sendGiftCost', {cost: gift.gems.amount / 4}) }}</span>
</div>
{{ $t('gemsPopoverTitle') }}
@@ -32,15 +32,15 @@
type="number"
placeholder="Number of Gems"
min="0"
:max="gift.gems.fromBalance ? userLoggedIn.balance * 4 : 9999"
:max="fromBal ? userLoggedIn.balance * 4 : 9999"
>
</div>
<div class="btn-group ml-auto">
<button
class="btn"
:class="{
'btn-primary': gift.gems.fromBalance,
'btn-secondary': !gift.gems.fromBalance,
'btn-primary': fromBal,
'btn-secondary': !fromBal,
}"
@click="gift.gems.fromBalance = true"
>
@@ -49,8 +49,8 @@
<button
class="btn"
:class="{
'btn-primary': !gift.gems.fromBalance,
'btn-secondary': gift.gems.fromBalance,
'btn-primary': !fromBal,
'btn-secondary': fromBal,
}"
@click="gift.gems.fromBalance = false"
>
@@ -120,39 +120,15 @@
>
{{ $t("send") }}
</button>
<div
<payments-buttons
v-else
class="payments-column mx-auto"
:class="{'payments-disabled': !gift.subscription.key && gift.gems.amount < 1}"
>
<button
class="purchase btn btn-primary payment-button payment-item"
:disabled="!gift.subscription.key && gift.gems.amount < 1"
@click="showStripe({gift, uuid: userReceivingGems._id, receiverName})"
>
<div
class="svg-icon credit-card-icon"
v-html="icons.creditCardIcon"
></div>
{{ $t('card') }}
</button>
<button
class="btn payment-item paypal-checkout payment-button"
:disabled="!gift.subscription.key && gift.gems.amount < 1"
@click="openPaypalGift({gift: gift, giftedTo: userReceivingGems._id, receiverName})"
>
&nbsp;
<img
src="~@/assets/images/paypal-checkout.png"
:alt="$t('paypal')"
>&nbsp;
</button>
<amazon-button
class="payment-item mb-0"
:amazon-data="{type: 'single', gift, giftedTo: userReceivingGems._id, receiverName}"
:amazon-disabled="!gift.subscription.key && gift.gems.amount < 1"
/>
</div>
:disabled="!gift.subscription.key && gift.gems.amount < 1"
:stripe-fn="() => showStripe({gift, uuid: userReceivingGems._id, receiverName})"
:paypal-fn="() => openPaypalGift({
gift: gift, giftedTo: userReceivingGems._id, receiverName,
})"
:amazon-data="{type: 'single', gift, giftedTo: userReceivingGems._id, receiverName}"
/>
</div>
</b-modal>
</template>
@@ -194,15 +170,14 @@ import { mapState } from '@/libs/store';
import planGemLimits from '@/../../common/script/libs/planGemLimits';
import paymentsMixin from '@/mixins/payments';
import notificationsMixin from '@/mixins/notifications';
import amazonButton from '@/components/payments/amazonButton';
import creditCardIcon from '@/assets/svg/credit-card-icon.svg';
import paymentsButtons from '@/components/payments/buttons/list';
// @TODO: EMAILS.TECH_ASSISTANCE_EMAIL, load from config
const TECH_ASSISTANCE_EMAIL = 'admin@habitica.com';
export default {
components: {
amazonButton,
paymentsButtons,
},
mixins: [paymentsMixin, notificationsMixin],
data () {
@@ -223,9 +198,6 @@ export default {
},
sendingInProgress: false,
userReceivingGems: null,
icons: Object.freeze({
creditCardIcon,
}),
};
},
computed: {