Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
88 lines
3.6 KiB
TypeScript
88 lines
3.6 KiB
TypeScript
"use client";
|
|
|
|
import { Label } from "@/app/components/ui/label";
|
|
import { RadioGroup, RadioGroupItem } from "@/app/components/ui/radio-group";
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
|
|
import { Input } from "@/app/components/ui/input";
|
|
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
|
|
|
// Reusable payout fields: the payout method radio, and for MANUAL, the
|
|
// "Returned by" channel select + reference input. Copy for structural labels
|
|
// goes through t(); display labels for radios and channels are passed as props
|
|
// so callers (RaiseRefundAction, CancelShipmentAction) can customise them.
|
|
|
|
export interface ChannelLabel {
|
|
value: string;
|
|
label: string;
|
|
}
|
|
|
|
export function PayoutFields({ member, acornsLabel, manualLabel, method, onMethod, channels, channel, onChannel, reference, onReference }: {
|
|
member: boolean;
|
|
/** Override for the ACORNS radio label. When absent, falls back to t("PayoutAcorns"). */
|
|
acornsLabel?: string;
|
|
/** Override for the MANUAL radio label. When absent, falls back to t("PayoutManual"). */
|
|
manualLabel?: string;
|
|
method: "ACORNS" | "MANUAL";
|
|
onMethod: (m: "ACORNS" | "MANUAL") => void;
|
|
/** MANUAL channel options. When present, only shown for MANUAL. */
|
|
channels?: ChannelLabel[];
|
|
channel?: string;
|
|
onChannel?: (c: string) => void;
|
|
reference?: string;
|
|
onReference?: (r: string) => void;
|
|
}) {
|
|
const t = useT();
|
|
const aLabel = acornsLabel ?? t("PayoutAcorns");
|
|
const mLabel = manualLabel ?? t("PayoutManual");
|
|
|
|
return (
|
|
<div className="flex flex-col gap-2">
|
|
<Label>{t("PayoutMethod")}</Label>
|
|
{member ? (
|
|
<RadioGroup aria-label={t("PayoutMethod")} className="flex gap-4" value={method} onValueChange={v => onMethod(v as "ACORNS" | "MANUAL")}>
|
|
<div className="flex items-center gap-2">
|
|
<RadioGroupItem id="payout-acorns" value="ACORNS" />
|
|
<Label htmlFor="payout-acorns">{aLabel}</Label>
|
|
</div>
|
|
<div className="flex items-center gap-2">
|
|
<RadioGroupItem id="payout-manual" value="MANUAL" />
|
|
<Label htmlFor="payout-manual">{mLabel}</Label>
|
|
</div>
|
|
</RadioGroup>
|
|
) : (
|
|
<RadioGroup aria-label={t("PayoutMethod")} className="flex gap-4" value={method} onValueChange={v => onMethod(v as "ACORNS" | "MANUAL")}>
|
|
<div className="flex items-center gap-2">
|
|
<RadioGroupItem id="payout-manual-guest" value="MANUAL" />
|
|
<Label htmlFor="payout-manual-guest">{mLabel}</Label>
|
|
</div>
|
|
</RadioGroup>
|
|
)}
|
|
|
|
{method === "MANUAL" && channels && onChannel && (
|
|
<div className="grid gap-3 sm:grid-cols-2">
|
|
<div className="flex flex-col gap-1">
|
|
<Label>{t("PayoutChannel")}</Label>
|
|
<Select value={channel} onValueChange={c => onChannel(c)}>
|
|
<SelectTrigger aria-label={t("PayoutChannel")}><SelectValue placeholder={t("ShipSelectPlaceholder")} /></SelectTrigger>
|
|
<SelectContent>
|
|
{channels.map(c => <SelectItem key={c.value} value={c.value}>{c.label}</SelectItem>)}
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
{onReference && (
|
|
<div className="flex flex-col gap-1">
|
|
<Label htmlFor="payout-reference">{t("PayoutReference")}</Label>
|
|
<Input
|
|
id="payout-reference"
|
|
value={reference ?? ""}
|
|
maxLength={100}
|
|
onChange={e => onReference(e.target.value)}
|
|
/>
|
|
</div>
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|