Skip to content

Commit 0b2e001

Browse files
committed
chore: wanTODOを編集するダイアログを分離
1 parent 2f13d6e commit 0b2e001

File tree

2 files changed

+60
-32
lines changed

2 files changed

+60
-32
lines changed

task_yell/src/app/home/page.tsx

+6-32
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import { EventCreator } from "@/components/event-creator";
4747
import { Event, Todo, StickyNote } from "@/components/types";
4848
import { priorityColors } from "@/components/priority-colors";
4949
import { Navigation } from "@/components/navigation";
50+
import { EditWantodoDialog } from "@/components/edit-wantodo-dialog";
5051

5152
export default function Home() {
5253
const [todos] = useState<Todo[]>([]);
@@ -607,38 +608,11 @@ export default function Home() {
607608
)}
608609
</AnimatePresence>
609610

610-
<Dialog
611-
open={!!editingStickyNote}
612-
onOpenChange={() => setEditingStickyNote(null)}
613-
>
614-
<DialogContent>
615-
<DialogHeader>
616-
<DialogTitle>wanTODOを編集</DialogTitle>
617-
</DialogHeader>
618-
{editingStickyNote && (
619-
<div className="space-y-4">
620-
<Input
621-
type="text"
622-
value={editingStickyNote.title}
623-
onChange={(e) =>
624-
setEditingStickyNote({
625-
...editingStickyNote,
626-
title: e.target.value,
627-
})
628-
}
629-
placeholder="タイトルを入力"
630-
/>
631-
<Button
632-
onClick={() =>
633-
editingStickyNote && updateStickyNote(editingStickyNote)
634-
}
635-
>
636-
更新
637-
</Button>
638-
</div>
639-
)}
640-
</DialogContent>
641-
</Dialog>
611+
<EditWantodoDialog
612+
editingStickyNote={editingStickyNote}
613+
setEditingStickyNote={setEditingStickyNote}
614+
updateStickyNote={updateStickyNote}
615+
/>
642616

643617
<Dialog open={isEventModalOpen} onOpenChange={setIsEventModalOpen}>
644618
<DialogContent className="max-w-3xl">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import {
5+
Dialog,
6+
DialogContent,
7+
DialogHeader,
8+
DialogTitle,
9+
} from "@/components/ui/dialog";
10+
import { Input } from "@/components/ui/input";
11+
import { StickyNote } from "./types";
12+
13+
type Props = {
14+
editingStickyNote: StickyNote | null;
15+
setEditingStickyNote: (stickyNote: StickyNote | null) => void;
16+
updateStickyNote: (stickyNote: StickyNote) => void;
17+
}
18+
19+
export function EditWantodoDialog({ editingStickyNote, setEditingStickyNote, updateStickyNote }: Props) {
20+
return (
21+
<Dialog
22+
open={!!editingStickyNote}
23+
onOpenChange={() => setEditingStickyNote(null)}
24+
>
25+
<DialogContent>
26+
<DialogHeader>
27+
<DialogTitle>wanTODOを編集</DialogTitle>
28+
</DialogHeader>
29+
{editingStickyNote && (
30+
<div className="space-y-4">
31+
<Input
32+
type="text"
33+
value={editingStickyNote.title}
34+
onChange={(e) =>
35+
setEditingStickyNote({
36+
...editingStickyNote,
37+
title: e.target.value,
38+
})
39+
}
40+
placeholder="タイトルを入力"
41+
/>
42+
<Button
43+
onClick={() =>
44+
editingStickyNote && updateStickyNote(editingStickyNote)
45+
}
46+
>
47+
更新
48+
</Button>
49+
</div>
50+
)}
51+
</DialogContent>
52+
</Dialog>
53+
)
54+
}

0 commit comments

Comments
 (0)