diff --git a/src/components/Header.tsx b/src/components/Header.tsx index ad7ffcd5..ea3e8824 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -28,12 +28,7 @@ export default function Header() { }); const checkUserPaid = useSWR<{ paid: boolean }>(['payment'], fetcher.get.query, { - isPaused: () => { - if (clerkUser.isLoaded && !clerkUser.isSignedIn) { - return true; - } - return !checkUserExists.data?.exists; - }, + isPaused: () => clerkUser.isLoaded && !clerkUser.isSignedIn, }); const [isScrolled, setIsScrolled] = useState(false); diff --git a/src/server/verify-membership-payment.ts b/src/server/verify-membership-payment.ts index 352e555f..38295e3c 100644 --- a/src/server/verify-membership-payment.ts +++ b/src/server/verify-membership-payment.ts @@ -7,7 +7,7 @@ import { updateMemberExpiryDate } from './update-member-expiry-date'; export const verifyMembershipPayment = async (clerkId: string) => { // Get user's membership expiry date from the database - const [{ membershipExpiresAt }] = await db + const [member] = await db .select({ id: memberTable.id, membershipExpiresAt: memberTable.membershipExpiresAt, @@ -15,8 +15,8 @@ export const verifyMembershipPayment = async (clerkId: string) => { .from(memberTable) .where(eq(memberTable.clerkId, clerkId)); // If membership expiry date exists, return the existing date - if (membershipExpiresAt) { - return { paid: true as const, membershipExpiresAt }; + if (member && member.membershipExpiresAt) { + return { paid: true as const, membershipExpiresAt: member.membershipExpiresAt }; } const paymentId = await redisClient.hGet(`payment:membership:${clerkId}`, 'paymentId');