Browse Source

Show a completed dialog after a purchase

tags/v0.1.0
Immanuel Onyeka 3 years ago
parent
commit
5bb11c0bae
5 changed files with 32 additions and 15 deletions
  1. +10
    -6
      resources/js/panel/credits.vue
  2. +2
    -7
      resources/js/panel/panel.vue
  3. +9
    -0
      resources/js/panel/purchase-completed.vue
  4. +1
    -2
      resources/js/panel/services.vue
  5. +10
    -0
      resources/scss/main.scss

+ 10
- 6
resources/js/panel/credits.vue View File

@@ -1,5 +1,5 @@
<template> <template>
<section class="select-credits">
<section v-if="!complete" class="select-credits">
<div class="credits-pane"><h2>10 Credits</h2> <div class="credits-pane"><h2>10 Credits</h2>
<h3>$10.99</h3><div><span>Qty</span><input min="0" max="1000" v-model="packs.credits10" type="number"></div> <h3>$10.99</h3><div><span>Qty</span><input min="0" max="1000" v-model="packs.credits10" type="number"></div>
</div> </div>
@@ -19,7 +19,7 @@
<div id="credits-errors"></div> <div id="credits-errors"></div>
</section> </section>


<section id="payment-section">
<section v-if="!complete" id="payment-section">
<h4>Select a payment method</h4> <h4>Select a payment method</h4>


<div class="sliding-menu"> <div class="sliding-menu">
@@ -39,16 +39,19 @@
<div id="payment-error"></div> <div id="payment-error"></div>
</section> </section>


<section class="credits-confirm">
<section v-if="!complete" class="credits-confirm">
<button @click="pay" :disabled="!ready" <button @click="pay" :disabled="!ready"
class="brand-btn">Buy<loading v-if="loading"></loading></button> class="brand-btn">Buy<loading v-if="loading"></loading></button>
</section> </section>

<PurchaseCompleted v-if="complete"></PurchaseCompleted>
</template> </template>


<script> <script>
import Loading from '../icons/loading.vue' import Loading from '../icons/loading.vue'
import PaymentCard from './payment-card.vue' import PaymentCard from './payment-card.vue'
import SavedCards from './saved-cards.vue' import SavedCards from './saved-cards.vue'
import PurchaseCompleted from './purchase-completed.vue'


function total() { function total() {
return this.packs.credits10*10.99 + this.packs.credits50*54.99 return this.packs.credits10*10.99 + this.packs.credits50*54.99
@@ -104,7 +107,8 @@ function pay() {
document.getElementById('payment-error').textContent = document.getElementById('payment-error').textContent =
result.error.message result.error.message
} else if (result.paymentIntent.status === 'succeeded') { } else if (result.paymentIntent.status === 'succeeded') {
this.$emit('purchaseComplete')
setTimeout(() => {this.$emit('purchaseComplete')}, 4000)
this.complete = true
} else { } else {
document.getElementById('payment-error').textContent = document.getElementById('payment-error').textContent =
'An unknown error occured' 'An unknown error occured'
@@ -133,13 +137,13 @@ function ready() {
} }


export default { export default {
components:{Loading, PaymentCard, SavedCards},
components:{Loading, PaymentCard, SavedCards, PurchaseCompleted},
data() { data() {
return {packs: {credits10: 0, credits50: 0, return {packs: {credits10: 0, credits50: 0,
credits100: 0, credits1000: 0}, loading: false, stripe: credits100: 0, credits1000: 0}, loading: false, stripe:
window.Stripe(process.env.VUE_APP_STRIPE_KEY), card: window.Stripe(process.env.VUE_APP_STRIPE_KEY), card:
null, billingName: null, selectSaved: true, cardValid: false, cards: null, billingName: null, selectSaved: true, cardValid: false, cards:
null, picked: null
null, picked: null, complete: false
} }
}, },
computed: {total, ready}, computed: {total, ready},


+ 2
- 7
resources/js/panel/panel.vue View File

@@ -85,20 +85,15 @@ function getOrders() {
}) })
} }


//Should show completed view and update user information after 5 seconds
function showCompleted() {

}

export default { export default {
components: { components: {
Sidebar, Settings, PastOrders, NewOrder
Sidebar, Settings, PastOrders, NewOrder,
}, },
data() { data() {
return {active: window.location.hash, user: null, return {active: window.location.hash, user: null,
token: null, orders: null, loading: true,} token: null, orders: null, loading: true,}
}, },
methods: {getUser, getServices, getOrders, showCompleted},
methods: {getUser, getServices, getOrders, },
created() { created() {
let loaders = [] let loaders = []
loaders.push(this.getUser()) loaders.push(this.getUser())


+ 9
- 0
resources/js/panel/purchase-completed.vue View File

@@ -0,0 +1,9 @@
<template>
<div class="status-dialog">
<img class="icon" src="../../images/checked2.svg" alt=""/>
<h3>Purchase complete. A receipt will be emailed to you.</h3>
</div>
</template>

<script>
</script>

+ 1
- 2
resources/js/panel/services.vue View File

@@ -81,7 +81,7 @@


</template> </template>


<credits :token="token" v-if="page == 'credits'"></credits>
<credits @purchase-complete="$emit('updateUser')" :token="token" v-if="page == 'credits'"></credits>


</div> </div>
</template> </template>
@@ -155,7 +155,6 @@ function page() {
case '#credits': case '#credits':
return 'credits' return 'credits'
} }
console.log(this.active)
} }


export default { export default {


+ 10
- 0
resources/scss/main.scss View File

@@ -1261,3 +1261,13 @@ div#card-errors {
max-width: 15em; max-width: 15em;
margin: auto; margin: auto;
} }

.status-dialog {
margin: auto;
max-width: 20em;

img {
margin: auto;
display: block;
}
}

Loading…
Cancel
Save