Skip to content

Commit

Permalink
comment out subscription for now
Browse files Browse the repository at this point in the history
  • Loading branch information
webdevcody committed Jan 26, 2024
1 parent 881351e commit cc5b61f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
14 changes: 7 additions & 7 deletions convex/thumbnails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ export const createThumbnail = mutation({
throw new Error("you must be logged in to create a thumbnail");
}

const isSubscribed = await isUserSubscribed(ctx);
// const isSubscribed = await isUserSubscribed(ctx);

const user = await getFullUser(ctx, userId);

if (!user) {
throw new Error("no user with that id found");
}

if (!isSubscribed && user.credits <= 0) {
throw new Error("you must be subscribed to create a thumbnail");
}
// if (!isSubscribed && user.credits <= 0) {
// throw new Error("you must be subscribed to create a thumbnail");
// }

await ctx.db.patch(user._id, {
credits: Math.max(0, user.credits - 1),
});
// await ctx.db.patch(user._id, {
// credits: Math.max(0, user.credits - 1),
// });

return await ctx.db.insert("thumbnails", {
title: args.title,
Expand Down
13 changes: 7 additions & 6 deletions convex/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ export const getProfile = query({
});

export const isUserSubscribed = async (ctx: QueryCtx | MutationCtx) => {
const userId = await getUserId(ctx);
return true;
// const userId = await getUserId(ctx);

if (!userId) {
return false;
}
// if (!userId) {
// return false;
// }

const userToCheck = await getFullUser(ctx, userId);
// const userToCheck = await getFullUser(ctx, userId);

return (userToCheck?.endsOn ?? 0) > Date.now();
// return (userToCheck?.endsOn ?? 0) > Date.now();
};

export const createUser = internalMutation({
Expand Down
2 changes: 1 addition & 1 deletion src/app/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function Header() {
<>
{isAuthenticated && (
<>
{!isSubscriped && <UpgradeButton />}
{/* {!isSubscriped && <UpgradeButton />} */}
<UserButton />
</>
)}
Expand Down

0 comments on commit cc5b61f

Please sign in to comment.