Skip to content

Commit

Permalink
マージ用
Browse files Browse the repository at this point in the history
  • Loading branch information
Astalum committed Nov 3, 2024
1 parent 483be3c commit 31bc5e1
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions pos/app/routes/cashier-mini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import bellSound from "~/assets/bell.mp3";
import logoSVG from "~/assets/cafeore.svg";
import logoMotion from "~/assets/cafeore_logo_motion.webm";
import { useOrderStat } from "~/components/functional/useOrderStat";
import {
Table,
TableBody,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "~/components/ui/table";
import { cn } from "~/lib/utils";

export const meta: MetaFunction = () => {
Expand All @@ -27,6 +36,7 @@ export default function CasherMini() {
);
const order = orderState?.edittingOrder;
const submittedOrderId = orderState?.submittedOrderId;
const [queuedItems, setQueuedItems] = useState(new Map());

const { data: preOrder } = useSWRSubscription(
["orders", submittedOrderId ?? "none"],
Expand Down Expand Up @@ -75,6 +85,20 @@ export default function CasherMini() {
return " ";
}, [isOperational, submittedOrderId]);

useEffect(() => {
if (order?.items?.length === 0) return;
const item = order?.items?.slice(-1)[0].name;
const updatedItems = new Map(queuedItems);
if (item in queuedItems) {
updatedItems[item] += 1;
setQueuedItems(updatedItems);
} else {
updatedItems.set(item, 1);
setQueuedItems(updatedItems);
}
[order?.items];
});

return (
<>
<div
Expand Down Expand Up @@ -123,22 +147,19 @@ export default function CasherMini() {
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-[100px]">Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead>Method</TableHead>
<TableHead className="text-right">Amount</TableHead>
<TableHead className="w-[100px]">商品名</TableHead>
<TableHead>杯数</TableHead>
<TableHead className="text-right">金額</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.invoice}>
<TableCell className="font-medium">
{invoice.invoice}
</TableCell>
<TableCell>{invoice.paymentStatus}</TableCell>
<TableCell>{invoice.paymentMethod}</TableCell>
{queuedItems?.forEach((name, cups) => (
<TableRow key={name}>
<TableCell className="font-medium">{name}</TableCell>
<TableCell>{cups}</TableCell>
<TableCell className="text-right">
{invoice.totalAmount}
{order?.items.find((item) => item.name === name)
?.price * cups}
</TableCell>
</TableRow>
))}
Expand All @@ -159,7 +180,8 @@ export default function CasherMini() {
合計: {order?.billingAmount ?? 0}
</p>
<p className="font-serif text-4xl text-white">
お釣り: {charge > 0 ? charge : 0}
{/* お釣り: {charge > 0 ? charge : 0} 円 */}
お釣り: {0}
</p>
</div>
</div>
Expand Down

0 comments on commit 31bc5e1

Please sign in to comment.