core: credit referral invites on first Lite checkout
Applies saved invites during Lite checkout so users who skip the referral page still credit the inviter. Avoids crediting already-active Lite workspaces so rewards stay tied to the first upgrade.
This commit is contained in:
@@ -15,6 +15,7 @@ import { useI18n } from "~/context/i18n"
|
||||
import { useLanguage } from "~/context/language"
|
||||
import { formError } from "~/lib/form-error"
|
||||
import { formatResetTime, liteResetTimeKeys } from "~/lib/format-reset-time"
|
||||
import { createReferralFromCookie } from "~/lib/referral-invite"
|
||||
|
||||
import { IconAlipay, IconUpi } from "~/component/icon"
|
||||
|
||||
@@ -75,15 +76,16 @@ const createLiteCheckoutUrl = action(
|
||||
"use server"
|
||||
return json(
|
||||
await withActor(
|
||||
() =>
|
||||
Billing.generateLiteCheckoutUrl({ successUrl, cancelUrl, method })
|
||||
.then((data) => ({ error: undefined, data }))
|
||||
.catch((e) => ({
|
||||
error: e.message as string,
|
||||
data: undefined,
|
||||
})),
|
||||
async () => {
|
||||
const data = await Billing.generateLiteCheckoutUrl({ successUrl, cancelUrl, method })
|
||||
await createReferralFromCookie()
|
||||
return { error: undefined, data }
|
||||
},
|
||||
workspaceID,
|
||||
),
|
||||
).catch((e) => ({
|
||||
error: e.message as string,
|
||||
data: undefined,
|
||||
})),
|
||||
{ revalidate: [queryBillingInfo.key, queryLiteSubscription.key] },
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user