Skip to content

Commit 7ad9cfe

Browse files
committed
fix auth uid issue with stripe button
1 parent b8488db commit 7ad9cfe

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎apps/codingcatdev/src/lib/client/firebase.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export const ccdSignInWithPopUp = async (provider: AuthProvider) => {
7373
export const db = getFirestore(app);
7474

7575
/* STRIPE */
76-
export const addSubscription = async (price: string) => {
77-
const userDoc = doc(collection(db, 'stripe-customers'), auth.currentUser?.uid)
76+
export const addSubscription = async (price: string, uid: string) => {
77+
const userDoc = doc(collection(db, 'stripe-customers'), uid)
7878
const docRef = await addDoc(collection(userDoc, 'checkout_sessions'), {
7979
price,
8080
success_url: window.location.href,

‎apps/codingcatdev/src/routes/(protected)/ProButton.svelte‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
id: string;
55
}[];
66
7+
export let uid: string | undefined;
8+
79
import { Icon } from '@steeze-ui/svelte-icon';
810
import { RocketLaunch } from '@steeze-ui/heroicons';
911
@@ -18,7 +20,8 @@
1820
ref: ProModal
1921
},
2022
meta: {
21-
products: products
23+
products: products,
24+
uid
2225
}
2326
};
2427
modalStore.trigger(d);

‎apps/codingcatdev/src/routes/(protected)/ProModal.svelte‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<script lang="ts">
22
import { Icon } from '@steeze-ui/svelte-icon';
3-
import {
4-
ArrowRightCircle,
5-
ArrowTopRightOnSquare,
6-
CheckCircle,
7-
RocketLaunch
8-
} from '@steeze-ui/heroicons';
3+
import { ArrowTopRightOnSquare, CheckCircle, RocketLaunch } from '@steeze-ui/heroicons';
94
105
import KcPrimary from '$lib/components/global/icons/KCPrimary.svelte';
116
import AjPrimary from '$lib/components/global/icons/AJPrimary.svelte';
@@ -19,7 +14,7 @@
1914
import { toastStore } from '@codingcatdev/blackcatui';
2015
2116
let redirecting = false;
22-
const onSubscribe = async (products: { role: string; price: string }[]) => {
17+
const onSubscribe = async (products: { role: string; price: string }[], uid: string) => {
2318
const price = products
2419
.filter((p) => (monthly ? p.role === 'monthly' : p.role === 'yearly'))
2520
.at(0)?.price;
@@ -30,7 +25,7 @@
3025
});
3126
} else {
3227
redirecting = true;
33-
addSubscription(price);
28+
addSubscription(price, uid);
3429
}
3530
};
3631
@@ -119,7 +114,7 @@
119114
{:else}
120115
<button
121116
class="bcu-button variant-filled-surface flex self-end gap-2"
122-
on:click|once={() => onSubscribe($modalStore[0].meta?.products)}
117+
on:click|once={() => onSubscribe($modalStore[0].meta?.products, $modalStore[0].meta?.uid)}
123118
>
124119
Continue
125120
<Icon src={ArrowTopRightOnSquare} theme="mini" class="w-8" />

‎apps/codingcatdev/src/routes/(protected)/account/+page.svelte‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@
5050
{/if}
5151
</div>
5252
{:else}
53-
<ProButton products={data.products} />
53+
<ProButton products={data.products} uid={data.user?.uid} />
5454
{/if}
5555
</LayoutWrapper>

‎apps/codingcatdev/src/routes/(protected)/dashboard/+page.svelte‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
<div class="bcu-card variant-filled">Welcome Message</div>
1717
<div class="bcu-card variant-filled">Join Discord for LBT</div>
1818
</div>
19-
<ProButton products={data.products} />
19+
{#if !data?.user?.stripeRole}
20+
<ProButton products={data.products} uid={data.user?.uid} />
21+
{/if}
2022
</div>
2123
</section>
2224
</div>

0 commit comments

Comments
 (0)