import { Box, Button, Paper, Stack, Step, StepLabel, Stepper, Table, TableBody, TableCell, TableRow, Typography, } from "@mui/material"; import { HasChildren } from "@types"; import { mailRequest } from "api/app/receipt-issuing-order"; import { getPrefName } from "codes/prefcode"; import useAPICall from "hooks/useAPICall"; import useApp from "hooks/useApp"; import useSnackbarCustom from "hooks/useSnackbarCustom"; import { useMemo, useState } from "react"; import useInputMailStep from "./hooks/useInputMailStep"; type TableRowCustomProps = { title: string; value: string; }; const TableRowCustom = ({ title, value }: TableRowCustomProps) => { return ( {title} {value} ); }; type SectionProps = { title: string; subtitle?: string; } & HasChildren; const Section = ({ title, subtitle, children }: SectionProps) => { return ( {title} {subtitle && {subtitle}} {children} ); }; export default function MailOrder() { const { tokenResult, token, navigateToHome, fetch, receiptIssuingOrder: order, } = useApp(); const { error } = useSnackbarCustom(); const [mode, setMode] = useState<"input" | "confirm" | "done">("input"); const input = useInputMailStep({ onNext: () => { setMode("confirm"); }, onPrev: () => { navigateToHome(); }, }); const requestMailAPI = useAPICall({ apiMethod: mailRequest, onSuccess: () => { fetch(); setMode("done"); }, onFailed: () => { error("登録失敗"); }, }); const currentStep = useMemo(() => { if (mode === "input") return 0; if (mode === "confirm") return 1; if (mode === "done") return 2; }, [mode]); const handleConfirm = () => { if (!order) return; requestMailAPI.callAPI({ access_token: token, timestamp: order.updated_at, ...input.values(), }); }; if (tokenResult !== "ok") { return null; } return ( <> 領収証郵送依頼
郵送先情報入力 確認 完了 {mode === "input" && input.element} {mode === "confirm" && ( 郵送先情報確認
郵送先に間違いがないか確認してください。 投函まで数営業日を要しますのでご了承ください。
)} {mode === "done" && ( 郵送依頼を受付いたしました。 到着までしばらくお待ちください。 )}
); }