From d815dff62ed2b88a9ca78807cef0fd4c2edd4a8c Mon Sep 17 00:00:00 2001 From: rai <96561881+r4ai@users.noreply.github.com> Date: Wed, 20 Nov 2024 01:23:57 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20Header=E3=81=AE=E3=83=87=E3=82=B6?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=92=E6=94=B9=E5=96=84=20(#49)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/atoms/button/MenuIconButton.tsx | 8 ++++++-- app/routes/header.tsx | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/components/atoms/button/MenuIconButton.tsx b/app/components/atoms/button/MenuIconButton.tsx index cecf308..12d9556 100644 --- a/app/components/atoms/button/MenuIconButton.tsx +++ b/app/components/atoms/button/MenuIconButton.tsx @@ -12,9 +12,13 @@ export const MenuIconButton: FC = memo(({ onOpen }) => { } - size="sm" - variant="unstyled" + size="lg" + variant="ghost" display={{ base: "block", lg: "none" }} + _hover={{ + cursor: "pointer", + bg: "blackAlpha.100", + }} onClick={onOpen} /> ) diff --git a/app/routes/header.tsx b/app/routes/header.tsx index d9b4809..40d3a50 100644 --- a/app/routes/header.tsx +++ b/app/routes/header.tsx @@ -1,4 +1,4 @@ -import { Flex, Heading, Text, useDisclosure } from "@chakra-ui/react" +import { Heading, HStack, Text, useDisclosure } from "@chakra-ui/react" import { Link, useNavigate } from "@remix-run/react" import { useCallback } from "react" import { MenuIconButton } from "~/components/atoms/button/MenuIconButton" @@ -31,7 +31,13 @@ export default function Header() { return ( <> - + @@ -40,7 +46,7 @@ export default function Header() { - + Date: Wed, 20 Nov 2024 21:09:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E6=B3=A8=E6=96=87=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=AB=E3=83=A1=E3=83=A2=E6=A9=9F=E8=83=BD=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20(#43)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organisms/kitchen/OrderCard.tsx | 37 +++++++++++++----- app/crud/crud_orders.ts | 2 + app/routes/kitchen.tsx | 17 +++++--- app/routes/reception.tsx | 20 +++++++++- app/type/typedetail.ts | 1 + app/type/typeorder.ts | 1 + bun.lockb | Bin 373363 -> 373363 bytes .../migration.sql | 2 + prisma/schema.prisma | 1 + 9 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 prisma/migrations/20241120041352_add_memo_to_orders/migration.sql diff --git a/app/components/organisms/kitchen/OrderCard.tsx b/app/components/organisms/kitchen/OrderCard.tsx index 4690e54..a1f8e6b 100644 --- a/app/components/organisms/kitchen/OrderCard.tsx +++ b/app/components/organisms/kitchen/OrderCard.tsx @@ -3,18 +3,22 @@ import { Form } from "@remix-run/react" import { FC, memo } from "react" import PropTypes from "prop-types" +type OrderItem = { + productName: string + quantity: number +} + type Props = { orderTime: string orderId: number - productNames: (string | null | undefined)[] + orderItems: OrderItem[] status: string - quantities: (number | null | undefined)[] tableNumber: number + memo?: string } export const OrderCard: FC = memo((props) => { - const { orderTime, orderId, productNames, status, quantities, tableNumber } = - props + const { orderTime, orderId, orderItems, status, tableNumber, memo } = props return ( = memo((props) => { > {orderTime} - {productNames.map((name, index) => ( - - {name}--数量:{quantities[index]} - + {orderItems.map((item, index) => ( + + + {item.productName}--数量:{item.quantity} + + ))} ------------------------- テーブル番号:{tableNumber} + {memo && memo.trim() !== "" && ( + + ※注文メモ:{memo} + + )} ステータス:{status} {status === "accept" ? (
@@ -74,8 +85,14 @@ OrderCard.displayName = "OrderCard" OrderCard.propTypes = { orderTime: PropTypes.string.isRequired, orderId: PropTypes.number.isRequired, - productNames: PropTypes.arrayOf(PropTypes.string).isRequired, + orderItems: PropTypes.arrayOf( + PropTypes.shape({ + productName: PropTypes.string.isRequired, + quantity: PropTypes.number.isRequired, + memo: PropTypes.string, + }).isRequired, + ).isRequired, status: PropTypes.string.isRequired, - quantities: PropTypes.arrayOf(PropTypes.number).isRequired, tableNumber: PropTypes.number.isRequired, + memo: PropTypes.string, } diff --git a/app/crud/crud_orders.ts b/app/crud/crud_orders.ts index e814293..a93a0ec 100644 --- a/app/crud/crud_orders.ts +++ b/app/crud/crud_orders.ts @@ -7,11 +7,13 @@ const prisma = new PrismaClient() export async function createOrder(data: { table_number: number status: string + memo?: string }) { const order = await prisma.orders.create({ data: { table_number: data.table_number, status: data.status, + memo: data.memo || "", }, }) return order diff --git a/app/routes/kitchen.tsx b/app/routes/kitchen.tsx index a78b4d8..5bdbed7 100644 --- a/app/routes/kitchen.tsx +++ b/app/routes/kitchen.tsx @@ -62,10 +62,15 @@ export default function Kitchen() { const filteredProducts = products.filter((product) => productIds.includes(product.product_id), ) - const productNames = filteredProducts.map( - (product) => product.product_name, - ) - const quantities = filteredDetails.map((detail) => detail.quantity) + const orderItems = filteredDetails.map((detail) => { + const product = filteredProducts.find( + (p) => p.product_id === detail.product_id, + ) + return { + productName: product?.product_name || "", + quantity: detail.quantity, + } + }) const createTime = new Date(order.createTime).toLocaleString( "ja-JP", @@ -84,10 +89,10 @@ export default function Kitchen() { ) diff --git a/app/routes/reception.tsx b/app/routes/reception.tsx index 5a715b3..efd7dea 100644 --- a/app/routes/reception.tsx +++ b/app/routes/reception.tsx @@ -10,9 +10,9 @@ import { ModalCloseButton, ModalContent, ModalFooter, - ModalOverlay, Stack, Text, + Textarea, useDisclosure, VStack, Wrap, @@ -51,6 +51,7 @@ export default function Reception() { const { products: products } = useLoaderData() const [order, setOrder] = useState([]) const [total, setTotal] = useState(0) + const [orderMemo, setOrderMemo] = useState("") // const [decision, setDecision] = useState(false) const actionData = useActionData() const { showMessage } = useMessage() @@ -77,6 +78,7 @@ export default function Reception() { if (actionData?.success === true) { setOrder([]) setTotal(0) + setOrderMemo("") // setDecision(false) showMessage({ title: "注文しました", status: "success" }) onClose() @@ -147,6 +149,10 @@ export default function Reception() { setTableNumber(e.target.value) } + const handleMemoChange = (memo: string) => { + setOrderMemo(memo) + } + return (
@@ -193,7 +199,6 @@ export default function Reception() {
- @@ -224,6 +229,14 @@ export default function Reception() { bg="gray.300" /> + 注文メモ: +