68 lines
2.7 KiB
TypeScript
68 lines
2.7 KiB
TypeScript
"use client";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
RECTIFICATION_BEFORE_CHANGE_LABEL,
|
|
RECTIFICATION_OFFER_CONTINUE_LABEL,
|
|
RECTIFICATION_OFFER_OPENED_COPY,
|
|
RECTIFICATION_OFFER_START_LABEL,
|
|
rectificationOfferCardCopy,
|
|
rectificationReturnDividerText,
|
|
rectificationRevisitLabel,
|
|
type RectificationOfferRecord,
|
|
type RectificationReturnRecord,
|
|
} from "@/lib/rectification-in-chat";
|
|
|
|
/**
|
|
* The card under a consultation answer that offered birth-time rectification
|
|
* (BUG-1248). The server decided it may be shown and wrote the price; the
|
|
* click opens the case (the charge comes with the first answered question).
|
|
* A card whose case is open says so and offers to go back in; a card whose
|
|
* case has returned is gone (the divider below says what happened).
|
|
*/
|
|
export function RectificationOfferCard({
|
|
offer,
|
|
disabled,
|
|
onStart,
|
|
}: Readonly<{ offer: RectificationOfferRecord; disabled: boolean; onStart: () => void }>) {
|
|
if (offer.status === "returned") return null;
|
|
// 「已经开始」 / 继续核对 only after the case is bound. autoOpen still shows
|
|
// the ordinary offer and 「开始核对出生时间」 until status is opened.
|
|
const opened = offer.status === "opened";
|
|
return (
|
|
<div className="rectification-offer-card" role="group" aria-label="核对出生时间">
|
|
<p>{opened ? RECTIFICATION_OFFER_OPENED_COPY : rectificationOfferCardCopy(offer)}</p>
|
|
<Button type="button" variant={opened ? "outline" : "default"} size="sm" disabled={disabled} onClick={onStart}>
|
|
{opened ? RECTIFICATION_OFFER_CONTINUE_LABEL : RECTIFICATION_OFFER_START_LABEL}
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Where the reader came back from rectification (BUG-1250). Re-asking with the
|
|
* new time is a button and an ordinary consultation turn: nothing is sent, and
|
|
* nothing is charged, until it is clicked.
|
|
*/
|
|
export function RectificationReturnDivider({
|
|
record,
|
|
disabled,
|
|
onRevisit,
|
|
}: Readonly<{ record: RectificationReturnRecord; disabled: boolean; onRevisit: (question: string) => void }>) {
|
|
return (
|
|
<div className="rectification-return-divider" role="note">
|
|
<p className="rectification-return-divider__line">{rectificationReturnDividerText(record)}</p>
|
|
{record.adopted ? (
|
|
<Button type="button" variant="outline" size="sm" disabled={disabled} onClick={() => onRevisit(record.sourceQuestion)}>
|
|
{rectificationRevisitLabel(record.sourceQuestion)}
|
|
</Button>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/** The small line above an answer written with the birth time before the change (P2). */
|
|
export function BeforeBirthTimeChangeLabel() {
|
|
return <p className="message-before-change">{RECTIFICATION_BEFORE_CHANGE_LABEL}</p>;
|
|
}
|