Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop): show presentment currency on Cap Pro upgrade card
Richie McIlroybfc456e740fe
diff --git a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx b/apps/desktop/src/routes/(window-chrome)/upgrade.tsxindex c9fd22ef7..1a4c3b26f 100644--- a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx+++ b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx@@ -1,8 +1,9 @@import { Button } from "@cap/ui-solid";import { createMutation, useQueryClient } from "@tanstack/solid-query";import { getCurrentWindow, Window } from "@tauri-apps/api/window";-import { type Accessor, createSignal, Show } from "solid-js";+import { type Accessor, createResource, createSignal, Show } from "solid-js";import { generalSettingsStore } from "~/store";+import { getPresentmentCurrencySymbol } from "~/utils/currency";import { getProPlanId } from "~/utils/plans";import { createLicenseQuery } from "~/utils/queries";import { createRive } from "~/utils/rive";@@ -38,6 +39,8 @@ export default function Page() {const signIn = createSignInMutation();const license = createLicenseQuery();const [openLicenseDialog, setOpenLicenseDialog] = createSignal(false);+ const [currencySymbol] = createResource(getPresentmentCurrencySymbol);+ const proSymbol = () => currencySymbol() ?? "$";const resetLicense = createMutation(() => ({mutationFn: async () => {@@ -471,7 +474,8 @@ export default function Page() {</div><div class="flex flex-col justify-center items-center"><h3 class="text-4xl leading-6 text-gray-1">- {isProAnnual() ? "$8.16" : "$12"}+ {proSymbol()}+ {isProAnnual() ? "8.16" : "12"}<span class="text-gray-10 text-[16px]">.00 /</span></h3>{isProAnnual() && (@@ -493,8 +497,8 @@ export default function Page() {Switch to {isProAnnual() ? "monthly" : "yearly"}:{" "}<span class="font-medium">{isProAnnual()- ? "$12 per user, billed monthly"- : "$8.16 per user, billed annually"}+ ? `${proSymbol()}12 per user, billed monthly`+ : `${proSymbol()}8.16 per user, billed annually`}</span></p></div>diff --git a/apps/desktop/src/utils/currency.ts b/apps/desktop/src/utils/currency.tsnew file mode 100644index 000000000..f36fb7159--- /dev/null+++ b/apps/desktop/src/utils/currency.ts@@ -0,0 +1,28 @@+import { fetch } from "@tauri-apps/plugin-http";++import { getConfiguredServerUrl } from "./web-api";++const CURRENCY_SYMBOLS: Record<string, string> = {+ usd: "$",+ gbp: "£",+ eur: "€",+};++export async function getPresentmentCurrencySymbol(): Promise<string> {+ try {+ const serverUrl = await getConfiguredServerUrl();+ const headers: Record<string, string> = {};+ const bypassSecret = import.meta.env.VITE_VERCEL_AUTOMATION_BYPASS_SECRET;+ if (bypassSecret) headers["x-vercel-protection-bypass"] = bypassSecret;++ const resp = await fetch(new URL("/api/currency", serverUrl).toString(), {+ headers,+ });+ if (!resp.ok) return "$";++ const body = (await resp.json()) as { currency?: string };+ return CURRENCY_SYMBOLS[body.currency ?? ""] ?? "$";+ } catch {+ return "$";+ }+}