Skip to content

Commit c342462

Browse files
committed
chore: wip
1 parent 48cc986 commit c342462

File tree

5 files changed

+62
-7
lines changed

5 files changed

+62
-7
lines changed

resources/views/dashboard/components/billing/payment-method-list.vue

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<script setup lang="ts">
22
import CardBrands from './card-brands.vue'
3+
import { notification } from '@stacksjs/notification'
4+
import { Popover, PopoverPanel, PopoverButton } from '@stacksjs/popover'
5+
6+
const isDefaultLoading = ref<{ [key: string]: boolean }>({})
37
48
const paymentStore = usePaymentStore()
59
@@ -10,10 +14,15 @@ async function deletePayment(paymentMethodId: string) {
1014
}
1115
1216
async function makeDefault(paymentMethodId: string) {
17+
isDefaultLoading.value[paymentMethodId] = true
18+
1319
await paymentStore.updateDefaultPaymentMethod(paymentMethodId)
1420
1521
await paymentStore.fetchUserPaymentMethods()
1622
await paymentStore.fetchDefaultPaymentMethod()
23+
24+
notification.success('Default payment method updated')
25+
isDefaultLoading.value[paymentMethodId] = false
1726
}
1827
</script>
1928

@@ -35,13 +44,19 @@ async function makeDefault(paymentMethodId: string) {
3544
type="button"
3645
class="border rounded-md bg-white px-2 py-1 text-sm text-white font-semibold shadow-sm hover:bg-blue-gray-50 focus-visible:outline-2 focus-visible:outline-blue-600 focus-visible:outline-offset-2 focus-visible:outline"
3746
@click="makeDefault(method.id)"
47+
:disabled="isDefaultLoading[method.id]"
3848
>
39-
<svg class="h-4 w-4 text-gray-700" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
49+
<svg v-if="!isDefaultLoading[method.id]" class="h-4 w-4 text-gray-700" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
4050
<path stroke-linecap="round" stroke-linejoin="round" d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z" />
4151
</svg>
52+
53+
<svg v-else class="h-4 w-4 text-gray-700 animate-spin" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
54+
<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-opacity="0.25" stroke-width="4"></circle>
55+
<path d="M4 12a8 8 0 018-8" stroke="currentColor" stroke-width="4" stroke-linecap="round"></path>
56+
</svg>
4257
</button>
4358

44-
<button
59+
<!-- <button
4560
aria-label="delete"
4661
type="button"
4762
class="border rounded-md bg-white px-2 py-1 text-sm text-white font-semibold shadow-sm hover:bg-blue-gray-50 focus-visible:outline-2 focus-visible:outline-blue-600 focus-visible:outline-offset-2 focus-visible:outline"
@@ -50,7 +65,34 @@ async function makeDefault(paymentMethodId: string) {
5065
<svg class="h-4 w-4 text-gray-700" data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
5166
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
5267
</svg>
53-
</button>
68+
</button> -->
69+
70+
<Popover v-slot="{ open }" class="relative">
71+
<PopoverButton
72+
:class="open ? 'text-white' : 'text-white/90'"
73+
class="border rounded-md bg-white px-2 py-1 text-sm text-white font-semibold shadow-sm hover:bg-blue-gray-50 focus-visible:outline-2 focus-visible:outline-blue-600 focus-visible:outline-offset-2 focus-visible:outline"
74+
>
75+
<svg class="h-4 w-4 text-gray-700" data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
76+
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
77+
</svg>
78+
</PopoverButton>
79+
80+
<PopoverPanel
81+
class="absolute left-1/2 z-10 mt-3 w-screen max-w-sm -translate-x-1/2 transform px-4 sm:px-0 lg:max-w-3xl"
82+
>
83+
<div class="p-4">
84+
<h3 class="text-lg font-medium leading-6 text-gray-900">Delete Payment Method</h3>
85+
<div class="mt-2">
86+
<p class="text-sm text-gray-500">Are you sure you want to delete this payment method?</p>
87+
</div>
88+
<div class="mt-4 flex justify-end">
89+
<button type="button" class="border rounded-md bg-white px-2 py-1 text-sm text-white font-semibold shadow-sm hover:bg-blue-gray-50 focus-visible:outline-2 focus-visible:outline-blue-600 focus-visible:outline-offset-2 focus-visible:outline">
90+
Delete
91+
</button>
92+
</div>
93+
</div>
94+
</PopoverPanel>
95+
</Popover>
5496
</div>
5597
</div>
5698
</div>

resources/views/dashboard/components/billing/payment-method.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
<script setup lang="ts">
22
import { useBillable } from '../../../../functions/billing/payments'
33
import CardBrands from './card-brands.vue'
4+
import { Notification, notification } from '@stacksjs/notification'
45
56
import PaymentMethodList from './payment-method-list.vue'
67
78
const paymentStore = usePaymentStore()
89
const clientSecret = ref('')
910
1011
const stripeLoading = ref(true)
12+
const isLoadingWebElement = ref(false)
1113
const showStripe = ref(false)
1214
const elements = ref('')
1315
1416
const { loadStripeElement, isEmpty, handleAddPaymentMethod } = useBillable()
1517
1618
async function loadWebElement() {
19+
isLoadingWebElement.value = true
1720
clientSecret.value = await paymentStore.fetchSetupIntent()
1821
1922
elements.value = await loadStripeElement(clientSecret.value)
2023
2124
showStripe.value = true
2225
stripeLoading.value = false
26+
isLoadingWebElement.value = false
2327
}
2428
2529
async function submitPaymentMethod(clientSecret: string, elements: any) {
@@ -39,6 +43,7 @@ function cancelPaymentForm() {
3943
</script>
4044

4145
<template>
46+
<Notification position="top-right" richColors/>
4247
<div class="mt-16 w-2/3 bg-white px-8 py-6 shadow ring-1 ring-black ring-opacity-5 sm:rounded-lg">
4348
<h2 class="text-lg text-gray-900 font-medium">
4449
Payment Info
@@ -99,7 +104,13 @@ function cancelPaymentForm() {
99104
class="rounded-md bg-blue-600 px-3.5 py-2.5 text-sm text-white font-semibold shadow-sm hover:bg-blue-gray-500 focus-visible:outline-2 focus-visible:outline-blue-600 focus-visible:outline-offset-2 focus-visible:outline"
100105
@click="loadWebElement()"
101106
>
102-
Add Payment Method
107+
<span class="inline-flex items-center" v-if="isLoadingWebElement">
108+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4 animate-spin">
109+
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" />
110+
</svg>
111+
<span class="ml-2">Loading...</span>
112+
</span>
113+
<span v-else>Add Payment Method</span>
103114
</button>
104115
</div>
105116
</div>

storage/framework/core/components/payment/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
"dependencies": {
3737
"@julr/unocss-preset-forms": "^0.1.0",
3838
"@stacksjs/ui": "workspace:*",
39-
"@unocss/reset": "0.64.1",
40-
"unocss": "0.64.1",
39+
"@unocss/reset": "0.61.0",
40+
"unocss": "0.61.0",
4141
"vue": "^3.5.13"
4242
},
4343
"devDependencies": {

storage/framework/core/components/popover/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ const plugin: Plugin = {
1010
}
1111

1212
export default plugin
13+
14+
export { Popover, PopoverButton, PopoverPanel }

storage/framework/core/components/popover/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default defineConfig(({ mode }) => {
5252
output: [
5353
{
5454
format: 'es',
55-
entryFileNames: `stacks-popover.js`,
55+
entryFileNames: `index.js`,
5656
preserveModules: false,
5757
},
5858
],

0 commit comments

Comments
 (0)