diff --git a/plugins/payments-demo/src/locales/en.json b/plugins/payments-demo/src/locales/en.json index ed7089174..ce517dd73 100644 --- a/plugins/payments-demo/src/locales/en.json +++ b/plugins/payments-demo/src/locales/en.json @@ -15,7 +15,6 @@ "no_providers": "No payment provider is configured yet, so this item cannot be bought.", "buy": "Buy now", "owned": "You own this item", - "sign_in": "Sign in to buy", "view_purchase": "View purchase" }, "purchase": { diff --git a/plugins/payments-demo/src/pages/shop-page.tsx b/plugins/payments-demo/src/pages/shop-page.tsx index 0b8eba83d..a6ec85ea2 100644 --- a/plugins/payments-demo/src/pages/shop-page.tsx +++ b/plugins/payments-demo/src/pages/shop-page.tsx @@ -17,8 +17,8 @@ import { import { Skeleton } from "@vitnode/core/components/ui/skeleton"; import { definePluginRoute } from "@vitnode/core/routing"; import { useSessionQuery } from "@vitnode/core/tanstack/auth"; -import { HrefLink } from "@vitnode/core/tanstack/link"; -import { CheckIcon, CreditCardIcon, LogInIcon } from "lucide-react"; +import { HrefLink, useHrefNavigate } from "@vitnode/core/tanstack/link"; +import { CheckIcon, CreditCardIcon } from "lucide-react"; import React from "react"; import { useLocale, useTranslations } from "use-intl"; @@ -41,6 +41,7 @@ const ShopPage = () => { const t = useTranslations("payments-demo"); const locale = useLocale(); const session = useSessionQuery(); + const navigate = useHrefNavigate(); const signedIn = !!session.data?.user; const catalog = useQuery(catalogQueryOptions()); const purchases = useQuery({ @@ -58,6 +59,11 @@ const ShopPage = () => { entry => entry.itemId === item?.id, ); + // A guest signs in first and comes back here to buy. + const onSignInToBuy = async () => { + await navigate("/login?returnTo=%2Fpayments-demo"); + }; + const onBuy = async () => { if (!item || !selectedProvider) return; setIsPending(true); @@ -156,25 +162,15 @@ const ShopPage = () => {