chore(go): referral improvements (#28368)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import "./index.css"
|
||||
import { createAsync, query, useLocation } from "@solidjs/router"
|
||||
import { createAsync, query } from "@solidjs/router"
|
||||
import { Title, Meta } from "@solidjs/meta"
|
||||
import { For, createMemo, createSignal, onCleanup, onMount } from "solid-js"
|
||||
//import { HttpHeader } from "@solidjs/start"
|
||||
@@ -224,15 +224,8 @@ function LimitsGraph(props: { href: string }) {
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
const location = useLocation()
|
||||
const workspaceID = createAsync(() => checkLoggedIn())
|
||||
const referralCode = createMemo(() => new URLSearchParams(location.search).get("ref") ?? undefined)
|
||||
const subscribeUrl = createMemo(() => {
|
||||
const code = referralCode()
|
||||
const referral = code ? `?ref=${encodeURIComponent(code)}` : ""
|
||||
if (workspaceID()) return `/workspace/${workspaceID()}/go${referral}`
|
||||
return `/auth${referral}`
|
||||
})
|
||||
const subscribeUrl = createMemo(() => (workspaceID() ? `/workspace/${workspaceID()}/go` : "/auth"))
|
||||
const i18n = useI18n()
|
||||
const language = useLanguage()
|
||||
return (
|
||||
|
||||
@@ -4,13 +4,14 @@ import { IconGo } from "~/component/icon"
|
||||
import { GoReferralSection, queryGoReferral } from "~/component/go-referral"
|
||||
import { useI18n } from "~/context/i18n"
|
||||
import { useLanguage } from "~/context/language"
|
||||
import { LiteSection } from "./lite-section"
|
||||
import { LiteSection, queryLiteSubscription } from "./lite-section"
|
||||
|
||||
export default function () {
|
||||
const params = useParams()
|
||||
const i18n = useI18n()
|
||||
const language = useLanguage()
|
||||
const referral = createAsync(() => queryGoReferral(params.id!))
|
||||
const lite = createAsync(() => queryLiteSubscription(params.id!))
|
||||
|
||||
return (
|
||||
<div data-page="workspace-[id]">
|
||||
@@ -28,13 +29,9 @@ export default function () {
|
||||
</section>
|
||||
|
||||
<div data-slot="sections">
|
||||
<LiteSection />
|
||||
<LiteSection lite={lite()} />
|
||||
<Show when={referral()} fallback={<section>{i18n.t("workspace.lite.loading")}</section>}>
|
||||
{(summary) => (
|
||||
<Show when={summary().hasActiveGo || summary().rewards.length > 0}>
|
||||
<GoReferralSection workspaceID={params.id!} summary={summary()} />
|
||||
</Show>
|
||||
)}
|
||||
{(summary) => <GoReferralSection workspaceID={params.id!} summary={summary()} lite={lite()} />}
|
||||
</Show>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -68,6 +68,8 @@ export const queryLiteSubscription = query(async (workspaceID: string) => {
|
||||
}, workspaceID)
|
||||
}, "lite.subscription.get")
|
||||
|
||||
type LiteSubscription = Awaited<ReturnType<typeof queryLiteSubscription>>
|
||||
|
||||
const createLiteCheckoutUrl = action(
|
||||
async (workspaceID: string, successUrl: string, cancelUrl: string, method?: "alipay" | "upi") => {
|
||||
"use server"
|
||||
@@ -147,13 +149,12 @@ function LiteUsageItem(props: { label: string; usage: { usagePercent: number; re
|
||||
)
|
||||
}
|
||||
|
||||
export function LiteSection() {
|
||||
export function LiteSection(props: { lite: LiteSubscription | undefined }) {
|
||||
const params = useParams()
|
||||
const i18n = useI18n()
|
||||
const language = useLanguage()
|
||||
const billingInfo = createAsync(() => queryBillingInfo(params.id!))
|
||||
const isBlack = createMemo(() => billingInfo()?.subscriptionID || billingInfo()?.timeSubscriptionBooked)
|
||||
const lite = createAsync(() => queryLiteSubscription(params.id!))
|
||||
const sessionAction = useAction(createSessionUrl)
|
||||
const sessionSubmission = useSubmission(createSessionUrl)
|
||||
const checkoutAction = useAction(createLiteCheckoutUrl)
|
||||
@@ -193,7 +194,7 @@ export function LiteSection() {
|
||||
<p data-slot="other-message">{i18n.t("workspace.lite.black.message")}</p>
|
||||
</section>
|
||||
</Show>
|
||||
<Show when={!isBlack() && lite() && lite()!.mine && lite()!}>
|
||||
<Show when={!isBlack() && props.lite && props.lite.mine && props.lite}>
|
||||
{(sub) => (
|
||||
<section class={styles.root}>
|
||||
<div data-slot="section-title">
|
||||
@@ -235,12 +236,12 @@ export function LiteSection() {
|
||||
</section>
|
||||
)}
|
||||
</Show>
|
||||
<Show when={!isBlack() && lite() && !lite()!.mine}>
|
||||
<Show when={!isBlack() && props.lite && !props.lite.mine}>
|
||||
<section class={styles.root}>
|
||||
<p data-slot="other-message">{i18n.t("workspace.lite.other.message")}</p>
|
||||
</section>
|
||||
</Show>
|
||||
<Show when={!isBlack() && lite() === null}>
|
||||
<Show when={!isBlack() && props.lite === null}>
|
||||
<section class={styles.root}>
|
||||
<p data-slot="promo-description">
|
||||
<For
|
||||
|
||||
Reference in New Issue
Block a user