Skip to content

Commit

Permalink
fix(server): member undefined when verify payment
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun969 committed Feb 18, 2024
1 parent 52bebdb commit b5be1db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/server/verify-membership-payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ 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,
})
.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');
Expand Down

0 comments on commit b5be1db

Please sign in to comment.