Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/cashier-mini お釣りに負の数を表示させない #408

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pos/app/routes/cashier-mini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function CasherMini() {
documentSub({ converter: cashierStateConverter }),
);
const order = orderState?.edittingOrder;
const [charge, setCharge] = useState(0);
const submittedOrderId = orderState?.submittedOrderId;

const { data: preOrder } = useSWRSubscription(
Expand All @@ -41,6 +42,10 @@ export default function CasherMini() {
videoRef.current?.play();
}, [thanksShowing]);

useEffect(() => {
setCharge(order?.received - order?.billingAmount);
}, [order?.received, order?.billingAmount]);

return (
<>
<div
Expand All @@ -59,7 +64,7 @@ export default function CasherMini() {
className="h-3/5 w-full object-contain"
/>
</div>
<div className="wrap flex h-full flex-col bg-theme px-[50px] pt-[40px]">
<div className="wrap flex h-screen flex-col bg-theme px-[50px] pt-[40px]">
<p className="pb-[50px] font-serif text-5xl text-white">
No. <span className="text-6xl">{orderId}</span>
</p>
Expand All @@ -74,7 +79,7 @@ export default function CasherMini() {
合計: {order?.billingAmount ?? 0} 円
</p>
<p className="font-serif text-4xl text-white">
お釣り: {order?.getCharge()} 円
お釣り: {charge > 0 ? charge : 0} 円
</p>
</div>
</div>
Expand Down
Loading