Skip to content

Commit

Permalink
deleteItem実装
Browse files Browse the repository at this point in the history
  • Loading branch information
Lailai0477 committed Sep 3, 2024
1 parent 1fb4e20 commit b2f0c7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/routes/items/action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type ClientActionFunction } from "@remix-run/react";
import { deleteItem } from "./actions/deleteItem";

import { addItem } from "./actions/addItem";

Expand All @@ -7,8 +8,8 @@ export const action: ClientActionFunction = async (args) => {
switch (request.method) {
case "POST":
return addItem(args);
// case "DELETE":
// return deleteItem(args);
case "DELETE":
return deleteItem(args);
default:
console.error("Invalid method", request.method);
return new Response(null, { status: 405 });
Expand Down
4 changes: 2 additions & 2 deletions app/routes/items/actions/deleteItem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { parseWithZod } from "@conform-to/zod";
import { json, type ClientActionFunction } from "@remix-run/react";
import { z } from "zod";
import { itemRepository } from "~/repositories/item";

export const deleteItem: ClientActionFunction = async ({ request }) => {
const formData = await request.formData();
Expand All @@ -15,8 +16,7 @@ export const deleteItem: ClientActionFunction = async ({ request }) => {

const { itemId } = submission.value;

// todo: implement delete item
console.error("Not implemented: delete item", itemId);
await itemRepository.delete(itemId);

return new Response(null, { status: 204 });
};

0 comments on commit b2f0c7c

Please sign in to comment.