Files
cozsweet-frontend-nextjs/src/app/tip/tip-page-client.tsx
T

33 lines
837 B
TypeScript

"use client";
import { useSearchParams } from "next/navigation";
import type { PayChannel } from "@/data/dto/payment";
import {
DEFAULT_TIP_COFFEE_TYPE,
resolveTipCoffeeType,
TIP_COFFEE_TYPE_PARAM,
} from "@/lib/tip/tip_coffee";
import { TipScreen } from "./tip-screen";
function toPayChannel(value: string | null): PayChannel | null {
if (value === "ezpay" || value === "stripe") return value;
return null;
}
export function TipPageClient() {
const searchParams = useSearchParams();
const coffeeType =
resolveTipCoffeeType(searchParams.get(TIP_COFFEE_TYPE_PARAM)) ??
DEFAULT_TIP_COFFEE_TYPE;
return (
<TipScreen
coffeeType={coffeeType}
shouldResumePendingOrder={searchParams.get("paymentReturn") === "1"}
initialPayChannel={toPayChannel(searchParams.get("payChannel"))}
/>
);
}