nicer package layout, also in checkout step 1, fixed missing registration language strings, registration error handling, email verification redirect, email verification error handling and messaging,
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { Head, usePage } from "@inertiajs/react";
|
||||
import MarketingLayout from "@/layouts/mainWebsite";
|
||||
import type { CheckoutPackage, GoogleProfilePrefill } from "./checkout/types";
|
||||
import { CheckoutWizard } from "./checkout/CheckoutWizard";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import toast from "react-hot-toast";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface CheckoutWizardPageProps {
|
||||
package: CheckoutPackage;
|
||||
@@ -26,9 +29,11 @@ const CheckoutWizardPage: React.FC<CheckoutWizardPageProps> = ({
|
||||
googleAuth,
|
||||
paddle,
|
||||
}) => {
|
||||
const page = usePage<{ auth?: { user?: { id: number; email: string; name?: string; pending_purchase?: boolean } | null } }>();
|
||||
const page = usePage<{ auth?: { user?: { id: number; email: string; name?: string; pending_purchase?: boolean } | null }, flash?: { verification?: { status: string; title?: string; message?: string } } }>();
|
||||
const currentUser = page.props.auth?.user ?? null;
|
||||
const googleProfile = googleAuth?.profile ?? null;
|
||||
const { t: tAuth } = useTranslation('auth');
|
||||
const verificationFlash = page.props.flash?.verification;
|
||||
|
||||
|
||||
const dedupedOptions = React.useMemo(() => {
|
||||
@@ -43,11 +48,37 @@ const CheckoutWizardPage: React.FC<CheckoutWizardPageProps> = ({
|
||||
});
|
||||
}, [initialPackage, packageOptions]);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (params.get('verified') === '1') {
|
||||
toast.success(tAuth('verification.toast_success', 'Email verified successfully.'));
|
||||
params.delete('verified');
|
||||
const next = params.toString();
|
||||
const nextUrl = `${window.location.pathname}${next ? `?${next}` : ''}`;
|
||||
window.history.replaceState({}, '', nextUrl);
|
||||
}
|
||||
}, [tAuth]);
|
||||
|
||||
return (
|
||||
<MarketingLayout title="Checkout Wizard">
|
||||
<Head title="Checkout Wizard" />
|
||||
<div className="min-h-screen bg-muted/20 py-12">
|
||||
<div className="mx-auto w-full max-w-4xl px-4">
|
||||
{verificationFlash && (
|
||||
<Alert
|
||||
className={verificationFlash.status === 'success'
|
||||
? 'mb-6 border-emerald-200 bg-emerald-50 text-emerald-800'
|
||||
: 'mb-6 border-rose-200 bg-rose-50 text-rose-800'}
|
||||
variant={verificationFlash.status === 'success' ? 'default' : 'destructive'}
|
||||
>
|
||||
<AlertTitle>{verificationFlash.title}</AlertTitle>
|
||||
<AlertDescription>{verificationFlash.message}</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
<CheckoutWizard
|
||||
initialPackage={initialPackage}
|
||||
packageOptions={dedupedOptions}
|
||||
|
||||
Reference in New Issue
Block a user