Open source CapCut alternative.
TypeScript
refactor(site): offer views carry the credit's life in days
David Le3d4fb3fe94f0
diff --git a/site/src/app/api/credits/offers/claim/route.ts b/site/src/app/api/credits/offers/claim/route.tsindex 3e952200..0b001e6b 100644--- a/site/src/app/api/credits/offers/claim/route.ts+++ b/site/src/app/api/credits/offers/claim/route.ts@@ -13,7 +13,6 @@ import {creditOfferOpen,verifyCreditOfferToken,} from "@/lib/credits/offers";-import { describeCreditLifetime } from "@/lib/email/send-credits-offered";import { forbiddenResponse, notFoundResponse, withDonkeyAuth } from "@/lib/donkey-api-auth";import { prisma } from "@/lib/prisma";@@ -57,7 +56,7 @@ export const GET = withDonkeyAuth(async (request) => {closesAt: offer.closesAt?.toISOString() ?? null,credits: formatUsdPlain(creditMicrosToString(offer.amountMicros)),expiresAt: offer.grant?.expiresAt?.toISOString() ?? null,- lifetime: describeCreditLifetime(offer.expiresAfterDays),+ lifetimeDays: offer.expiresAfterDays,});});diff --git a/site/src/lib/credits/subscribe-bonus.ts b/site/src/lib/credits/subscribe-bonus.tsindex 0c4db2b0..c7fdbe9d 100644--- a/site/src/lib/credits/subscribe-bonus.ts+++ b/site/src/lib/credits/subscribe-bonus.ts@@ -5,7 +5,6 @@ import { creditMicrosToString, creditStringToMicros, zeroCreditMicros } from "@/import { creditOfferOpen } from "@/lib/credits/offers";import { SUBSCRIBE_BONUS_KIND } from "@/lib/credits/offerKinds";import { bestOfferForSubscribing, findOffersForSubscribing } from "@/lib/credits/subscribe-bonus-claim";-import { describeCreditLifetime } from "@/lib/email/send-credits-offered";import { prisma } from "@/lib/prisma";// The subscribe bonus: an account that has spent enough of its signup grant@@ -28,10 +27,10 @@ export type SubscribeBonusView = {dollars: string;openedAt: string;closesAt: string;- // The credit's life once it lands: a fixed last moment, or a span from the- // claim as people read it ("a month"). Both null keeps it forever.+ // The credit's life once it lands: a fixed last moment, or days from the+ // claim. Both null keeps it forever.creditsExpireAt: string | null;- creditsLifetime: string | null;+ creditsLifetimeDays: number | null;status: SubscribeBonusStatus;};@@ -69,7 +68,7 @@ export function subscribeBonusView(offer: CreditOffer, facts: { now: Date; pro:openedAt: offer.createdAt.toISOString(),closesAt: (offer.closesAt ?? offer.createdAt).toISOString(),creditsExpireAt: offer.expiresAt?.toISOString() ?? null,- creditsLifetime: offer.expiresAt ? null : describeCreditLifetime(offer.expiresAfterDays),+ creditsLifetimeDays: offer.expiresAt ? null : offer.expiresAfterDays,status: subscribeBonusStatus(offer, facts),};}diff --git a/site/src/queries/credits.ts b/site/src/queries/credits.tsindex a07d9eb2..7017713a 100644--- a/site/src/queries/credits.ts+++ b/site/src/queries/credits.ts@@ -54,10 +54,10 @@ export type SubscribeBonus = {dollars: string;openedAt: string;closesAt: string;- // The credit's life once it lands: a fixed last moment, or a span from the- // claim as people read it ("a month"). Both null keeps it forever.+ // The credit's life once it lands: a fixed last moment, or days from the+ // claim. Both null keeps it forever.creditsExpireAt: string | null;- creditsLifetime: string | null;+ creditsLifetimeDays: number | null;status: "open" | "closed" | "claimed";};@@ -154,8 +154,8 @@ export type CreditOffer = {// When the claimed credit expires; null before the claim and for a credit// that keeps forever.expiresAt: string | null;- // "a week", or null when the credit keeps forever.- lifetime: string | null;+ // How many days the claimed credit lasts; null when it keeps forever.+ lifetimeDays: number | null;};// The offer a claim link names. 404 is a link that no longer opens anything;