3. モデルを実装する-判定結果でUIを制御する// Presentational:概念の型だけを受け取り、 statusの値は知らない
type Props = {
phase: DisplayPhase; cancel: CancelDecision; onCancel: () => void;
};
const reasonLabel = {
fulfillmentStarted: "出荷準備が始まったため、キャンセルできません ",
alreadyCancelled: "この注文はキャンセル済みです ",
} satisfies Record;
export const OrderDetail = ({ phase, cancel, onCancel }: Props) => (
注文をキャンセル
{!cancel.can &&
{reasonLabel[cancel.reason]}
}
);