diff --git a/apps/desktop/src/routes/(window-chrome)/licensing.tsx b/apps/desktop/src/routes/(window-chrome)/licensing.tsx deleted file mode 100644 index f58a509ac75..00000000000 --- a/apps/desktop/src/routes/(window-chrome)/licensing.tsx +++ /dev/null @@ -1,286 +0,0 @@ -import { Button } from "@cap/ui-solid"; -import { licenseContract } from "@cap/web-api-contract"; -import { useNavigate } from "@solidjs/router"; -import { createMutation } from "@tanstack/solid-query"; -import * as tauriShell from "@tauri-apps/plugin-shell"; -import { ClientInferResponseBody } from "@ts-rest/core"; -import { - createResource, - createSignal, - Match, - Show, - Suspense, - Switch, -} from "solid-js"; -import { generalSettingsStore } from "~/store"; -import { createLicenseQuery } from "~/utils/queries"; -import { licenseApiClient } from "~/utils/web-api"; -import { Input } from "../editor/ui"; - -export default function Page() { - const license = createLicenseQuery(); - const navigate = useNavigate(); - - return ( -
-
-

- Commercial License -

-

- Permits using Cap for commercial purposes, but without paying for - cloud features. -

-
- - }> - -
-

- Your account is upgraded to Cap Pro and already includes a - commercial license. -

-
-
- - {(license) => ( -
-

- Your License -

-
- -
-                  {license().licenseKey}
-                
-
- - {(expiry) => ( -
- - - {new Date(expiry()).toUTCString()} - -
- )} -
- - {/*

- Instance ID: {license().instanceId} -

*/} -
- -
-
- )} -
-
-
- ); -} - -function LicenseKeyActivate(props: { - onActivated: ( - value: ClientInferResponseBody< - (typeof licenseContract)["activateCommercialLicense"], - 200 - > & { licenseKey: string } - ) => void; -}) { - const [store] = createResource(() => generalSettingsStore.get()); - - return ( - - - {(generalSettings) => { - const [licenseKey, setLicenseKey] = createSignal(""); - - const activateLicenseKey = createMutation(() => ({ - mutationFn: async (vars: { licenseKey: string }) => { - const resp = await licenseApiClient.activateCommercialLicense({ - headers: { - licensekey: vars.licenseKey, - instanceid: generalSettings().instanceId!, - }, - body: { reset: false }, - }); - - if (resp.status === 200) return resp.body; - if ( - typeof resp.body === "object" && - resp.body && - "message" in resp.body - ) - throw resp.body.message; - throw new Error((resp.body as any).toString()); - }, - onSuccess: (value, { licenseKey }) => - props.onActivated({ ...value, licenseKey }), - })); - - return ( -
-

- Got a license key? Enter it below -

- setLicenseKey(e.currentTarget.value)} - /> - - {/*

- Instance ID: {generalSettings().instanceId} -

*/} -
- ); - }} -
-
- ); -} - -type CommercialLicenseType = "yearly" | "lifetime"; -function CommercialLicensePurchase() { - const openCheckoutInExternalBrowser = createMutation(() => ({ - mutationFn: async ({ type }: { type: CommercialLicenseType }) => { - const resp = await licenseApiClient.createCommercialCheckoutUrl({ - body: { type }, - }); - - if (resp.status === 200) tauriShell.open(resp.body.url); - else throw resp.body; - }, - })); - - const [type, setType] = createSignal("yearly"); - - return ( - <> -
-
-
-

- Commercial License -

-

- For professional use without cloud features. -

-
-
-

- {type() === "yearly" ? "$29/year" : "$58"} -

-
- {type() === "lifetime" && ( -

- billed once -

- )} - {type() === "lifetime" && ( -

- or, $29/year. -

- )} -
-
-
-
-
-
- - Switch to {type() === "yearly" ? "lifetime" : "yearly"} - - -
-
-
- -
-
-
-
-
    - {[ - "Commercial Use of Cap Recorder + Editor", - "Community Support", - ].map((feature) => ( -
  • -
    - -
    - - {feature} - -
  • - ))} -
-
-
-
-
-
- { - await generalSettingsStore.set({ - commercialLicense: { - activatedOn: Date.now(), - expiryDate: value.expiryDate ?? null, - refresh: value.refresh, - licenseKey: value.licenseKey, - }, - }); - }} - /> - - ); -} diff --git a/apps/desktop/src/routes/(window-chrome)/settings.tsx b/apps/desktop/src/routes/(window-chrome)/settings.tsx index 3aee9259737..c3f8864981b 100644 --- a/apps/desktop/src/routes/(window-chrome)/settings.tsx +++ b/apps/desktop/src/routes/(window-chrome)/settings.tsx @@ -46,6 +46,11 @@ export default function Settings(props: RouteSectionProps) { name: "Integrations", icon: IconLucideUnplug, }, + { + href: "license", + name: "License", + icon: IconLucideGift, + }, { href: "experimental", name: "Experimental", diff --git a/apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx b/apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx index c6740bcfae2..38b44c65f6b 100644 --- a/apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx +++ b/apps/desktop/src/routes/(window-chrome)/settings/experimental.tsx @@ -41,10 +41,10 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {
-

+

Experimental Features

-

+

These features are still in development and may not work as expected.

diff --git a/apps/desktop/src/routes/(window-chrome)/settings/license.tsx b/apps/desktop/src/routes/(window-chrome)/settings/license.tsx new file mode 100644 index 00000000000..af346be3863 --- /dev/null +++ b/apps/desktop/src/routes/(window-chrome)/settings/license.tsx @@ -0,0 +1,331 @@ +import { createRive } from "@aerofoil/rive-solid-canvas"; +import { Button } from "@cap/ui-solid"; +import { licenseContract } from "@cap/web-api-contract"; +import { useNavigate } from "@solidjs/router"; +import { createMutation, useQueryClient } from "@tanstack/solid-query"; +import * as tauriShell from "@tauri-apps/plugin-shell"; +import { ClientInferResponseBody } from "@ts-rest/core"; +import { + createResource, + createSignal, + Match, + Show, + Suspense, + Switch, +} from "solid-js"; +import { generalSettingsStore } from "~/store"; +import { createLicenseQuery } from "~/utils/queries"; +import { commands } from "~/utils/tauri"; +import { licenseApiClient } from "~/utils/web-api"; +import PricingRive from "../../../assets/rive/pricing.riv"; +import { Input } from "../../editor/ui"; + +export default function Page() { + const license = createLicenseQuery(); + const navigate = useNavigate(); + const queryClient = useQueryClient(); + + return ( +
+
+

Commercial License

+

+ Permits using Cap for commercial purposes, but without paying for + cloud features. + +
+ Need cloud features?{" "} + +
+

+
+ }> + +
+
+
+

+ Cap Pro License +

+
+

+ Your account is upgraded to{" "} + Cap Pro and + already includes a commercial license. +

+
+
+
+ + {(license) => ( +
+
+
+ +

+ Commercial License +

+
+
+ +
+                    {license().licenseKey}
+                  
+
+ + {(expiry) => ( +
+ +

+ {new Date(expiry()).toLocaleDateString()} +

+
+ )} +
+
+
+ +
+
+
+ )} + + +
+ ); +} + +function LicenseKeyActivate(props: { + onActivated: ( + value: ClientInferResponseBody< + (typeof licenseContract)["activateCommercialLicense"], + 200 + > & { licenseKey: string } + ) => void; +}) { + const [store] = createResource(() => generalSettingsStore.get()); + const queryClient = useQueryClient(); + + return ( + + + {(generalSettings) => { + const [licenseKey, setLicenseKey] = createSignal(""); + + const activateLicenseKey = createMutation(() => ({ + mutationFn: async (vars: { licenseKey: string }) => { + const resp = await licenseApiClient.activateCommercialLicense({ + headers: { + licensekey: vars.licenseKey, + instanceid: generalSettings().instanceId!, + }, + body: { reset: false }, + }); + + if (resp.status === 200) return resp.body; + if ( + typeof resp.body === "object" && + resp.body && + "message" in resp.body + ) + throw resp.body.message; + throw new Error((resp.body as any).toString()); + }, + onSuccess: (value, { licenseKey }) => { + props.onActivated({ ...value, licenseKey }); + queryClient.refetchQueries({ queryKey: ["bruh"] }); + }, + })); + + return ( +
+
+

Have a license key?

+ setLicenseKey(e.currentTarget.value)} + class="w-full bg-gray-3 border-gray-4" + /> +
+ +
+ +

+ {String(activateLicenseKey.error)} +

+
+
+
+ ); + }} +
+
+ ); +} + +type CommercialLicenseType = "yearly" | "lifetime"; +function CommercialLicensePurchase() { + const queryClient = useQueryClient(); + + const [type, setType] = createSignal("yearly"); + + const [isCommercialAnnual, setIsCommercialAnnual] = createSignal(true); + + const { rive: CommercialRive, RiveComponent: Commercial } = createRive( + () => ({ + src: PricingRive, + autoplay: true, + artboard: "commercial", + animations: ["card-stack"], + }) + ); + + const openCommercialCheckout = createMutation(() => ({ + mutationFn: async () => { + const resp = await licenseApiClient.createCommercialCheckoutUrl({ + body: { type: isCommercialAnnual() ? "yearly" : "lifetime" }, + }); + + if (resp.status === 200) { + commands.openExternalLink(resp.body.url); + } + }, + })); + + return ( + <> +
+
+ {/* Left Column */} +
{ + const riveInstance = CommercialRive(); + if (riveInstance) { + // Stop any current animations first + riveInstance.stop(); + // Play the enter animation + riveInstance.play("cards"); + } + }} + onMouseLeave={() => { + const riveInstance = CommercialRive(); + if (riveInstance) { + // Stop any current animations first + riveInstance.stop(); + // Play the leave animation + riveInstance.play("card-stack"); + } + }} + class="flex flex-col gap-4 items-center p-5 rounded-t-xl border md:rounded-tr-none md:rounded-tl-xl md:rounded-bl-xl border-gray-4 md:w-1/2 bg-gray-3" + > + +
+

+ Commercial License +

+

+ For commercial use +

+
+
+

+ {isCommercialAnnual() ? "$29" : "$58"} + .00 / +

+

+ {isCommercialAnnual() ? "billed annually" : "one-time payment"} +

+
+
setIsCommercialAnnual((v) => !v)} + class="px-3 py-2 text-center rounded-full border border-transparent transition-all duration-200 cursor-pointer w-fit bg-gray-5 hover:border-gray-400" + > +

+ Switch to {isCommercialAnnual() ? "lifetime" : "yearly"}:{" "} + + {isCommercialAnnual() ? "$58" : "$29"} + +

+
+ +
+ + {/* Right Column */} +
+
    + {[ + "Commercial Use of Cap Recorder + Editor", + "Community Support", + "Local-only features", + "Perpetual license option", + ].map((feature) => ( +
  • +
    + +
    + + {feature} + +
  • + ))} +
+
+
+
+ + { + await generalSettingsStore.set({ + commercialLicense: { + activatedOn: Date.now(), + expiryDate: value.expiryDate ?? null, + refresh: value.refresh, + licenseKey: value.licenseKey, + }, + }); + await queryClient.refetchQueries({ queryKey: ["bruh"] }); + }} + /> + + ); +} diff --git a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx index 01a8f93394b..178e105a21a 100644 --- a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx +++ b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx @@ -1,7 +1,7 @@ import { createRive } from "@aerofoil/rive-solid-canvas"; import { Button } from "@cap/ui-solid"; import { action, useAction } from "@solidjs/router"; -import { createMutation } from "@tanstack/solid-query"; +import { createMutation, useQueryClient } from "@tanstack/solid-query"; import { invoke } from "@tauri-apps/api/core"; import { listen } from "@tauri-apps/api/event"; import { getCurrentWindow, Window } from "@tauri-apps/api/window"; @@ -284,34 +284,32 @@ export default function Page() { {!upgradeComplete() && ( <> {license.data?.type === "commercial" ? ( -
+
-
-

- Your Commercial License -

-

- License details for Cap commercial use +

+

Commercial License

+

+ Your license details for Cap commercial use

-
-