File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ export async function loader({ request }: LoaderFunctionArgs) {
4444 return typedjson ( { view : "invalid" as const , ...authMethods } ) ;
4545 }
4646
47- // Stash the code so it survives the OAuth round-trip and can be applied when
48- // the new org is created .
47+ // Stash the code so it survives the OAuth round-trip and can be applied once
48+ // the new org selects a plan .
4949 return typedjson (
5050 {
5151 view : "valid" as const ,
@@ -152,16 +152,20 @@ export default function PromoPage() {
152152 ) : (
153153 < >
154154 < Header2 className = "sm:text-2xl md:text-3xl lg:text-4xl" spacing >
155- { data . view === "valid" ? `Claim ${ formatDollars ( data . amountInCents ) } credits` : "Create your account" }
155+ { data . view === "valid"
156+ ? `Claim ${ formatDollars ( data . amountInCents ) } credits`
157+ : "Create your account" }
156158 </ Header2 >
157159 { data . view === "valid" ? (
158160 < Paragraph variant = "base" spacing >
159- These are only available for new accounts. The credits expire on { formatExpiry ( data . expiresAt ) } .
160- </ Paragraph >
161+ These are only available for new accounts.
162+ { formatExpiry ( data . expiresAt )
163+ ? ` The credits expire on ${ formatExpiry ( data . expiresAt ) } .`
164+ : "" }
165+ </ Paragraph >
161166 ) : (
162167 < Callout variant = "warning" className = "mb-6 w-full" >
163- That promo code isn't valid. You can still sign up below but credits won't be
164- added.
168+ That promo code isn't valid. You can still sign up below but credits won't be added.
165169 </ Callout >
166170 ) }
167171 < SignInForm showGithubAuth = { data . showGithubAuth } showGoogleAuth = { data . showGoogleAuth } />
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ import { prisma } from "~/db.server";
3434import { redirectWithErrorMessage } from "~/models/message.server" ;
3535import { resolveOrgIdFromSlug } from "~/models/organization.server" ;
3636import { logger } from "~/services/logger.server" ;
37- import { applyPromoCode , setPlan } from "~/services/platform.v3.server" ;
37+ import { applyPromoCode , bustPromoCreditsCache , setPlan } from "~/services/platform.v3.server" ;
3838import { clearPromoCodeCookie , getPromoCodeFromCookie } from "~/services/promoCode.server" ;
3939import { dashboardAction } from "~/services/routeBuilders/dashboardBuilder" ;
4040import { engine } from "~/v3/runEngine.server" ;
@@ -166,6 +166,7 @@ export const action = dashboardAction(
166166 if ( promoCode ) {
167167 const applied = await applyPromoCode ( organization . id , user . id , promoCode ) ;
168168 if ( applied ?. applied ) {
169+ bustPromoCreditsCache ( organization . id ) ;
169170 result . headers . append ( "Set-Cookie" , await clearPromoCodeCookie ( ) ) ;
170171 }
171172 }
Original file line number Diff line number Diff line change @@ -212,6 +212,12 @@ export function bustBillingLimitCaches(organizationId: string) {
212212 invalidateBillingLimitCaches ( organizationId ) ;
213213}
214214
215+ // Clear the cached promo-credits read so a just-granted code shows on the usage
216+ // page immediately rather than after the stale TTL.
217+ export function bustPromoCreditsCache ( organizationId : string ) {
218+ platformCache . promoCredits . remove ( organizationId ) . catch ( ( ) => { } ) ;
219+ }
220+
215221type Machines = typeof machinesFromPlatform ;
216222
217223const MachineOverrideValues = z . object ( {
You can’t perform that action at this time.
0 commit comments