Skip to content

Commit

Permalink
”すべて削除”ボタンを画面から削除 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
BruCandy authored Nov 22, 2024
1 parent 874091b commit 1633073
Showing 1 changed file with 3 additions and 50 deletions.
53 changes: 3 additions & 50 deletions app/routes/kitchen.tsx
Original file line number Diff line number Diff line change
@@ -1,45 +1,22 @@
import {
Button,
Input,
Modal,
ModalBody,
ModalContent,
ModalOverlay,
useDisclosure,
Wrap,
WrapItem,
} from "@chakra-ui/react"
import { Wrap, WrapItem } from "@chakra-ui/react"
import { PrismaClient } from "@prisma/client"
import {
ActionFunction,
ActionFunctionArgs,
SerializeFrom,
} from "@remix-run/node"
import { Form, json, useFetcher, useLoaderData } from "@remix-run/react"
import { json, useFetcher, useLoaderData } from "@remix-run/react"
import { useEffect, useState } from "react"
import { OrderCard } from "~/components/organisms/kitchen/OrderCard"
import { deleteAllDetails } from "~/crud/crud_details"
import { deleteAllOrders, updateOrderStatus } from "~/crud/crud_orders"
import { updateOrderStatus } from "~/crud/crud_orders"

export default function Kitchen() {
const initialData = useLoaderData<typeof loader>()

const { isOpen, onOpen, onClose } = useDisclosure()

const { orders } = useKitchenData(initialData)

return (
<>
<Button
colorScheme="red"
onClick={onOpen}
position="relative"
top="-2"
right="-850"
mb="4"
>
すべて削除
</Button>
<Wrap>
{orders.map((order) => {
const createTime = new Date(order.createTime).toLocaleString(
Expand Down Expand Up @@ -74,25 +51,6 @@ export default function Kitchen() {
)
})}
</Wrap>

<Modal isOpen={isOpen} onClose={onClose} motionPreset="slideInBottom">
<ModalOverlay />
<ModalContent pb={2}>
<ModalBody mx={4}>
<p>本当にすべて削除しますか?</p>
<br />
<Form method="post">
<Input type="hidden" name="_method" value="delete_all" />
<Button w="100%" type="submit">
はい
</Button>
</Form>
<Button w="100%" onClick={onClose}>
いいえ
</Button>
</ModalBody>
</ModalContent>
</Modal>
</>
)
}
Expand Down Expand Up @@ -136,11 +94,6 @@ export const action: ActionFunction = async ({
updateOrderStatus(order_id, "finish")
}

return { success: true }
} else if (method === "delete_all") {
deleteAllDetails()
deleteAllOrders()

return { success: true }
} else {
return { success: false }
Expand Down

0 comments on commit 1633073

Please sign in to comment.