Skip to content

Commit

Permalink
change: 不要なdate, startTime,endTimeを削除
Browse files Browse the repository at this point in the history
  • Loading branch information
gohan5858 committed Oct 27, 2024
1 parent 490db72 commit 03262d6
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions task_yell/src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,11 @@ type Todo = {
type Event = {
id: number;
title: string;
start: Date;
end: Date;
description: string;
date: Date;
startTime: string;
endTime: string;
category: Category;
priority: Priority;
start: Date;
end: Date;
location: string;
invitees: string;
isTask: boolean;
Expand All @@ -104,14 +101,16 @@ function EventCreator({
onSave,
onCancel,
initialTitle = "",
targetDate,
}: {
onSave: (event: Event) => void;
onCancel: () => void;
initialTitle?: string;
targetDate: Date;
}) {
const [title, setTitle] = useState(initialTitle);
const [description, setDescription] = useState("");
const [date] = useState<Date | undefined>(new Date());
const [selectedDate] = useState<Date>(targetDate);
const [startTime] = useState("10:00");
const [endTime] = useState("11:00");
const [location, setLocation] = useState("");
Expand All @@ -122,18 +121,15 @@ function EventCreator({
const [isLocked, setIsLocked] = useState(false);

const handleSave = () => {
if (date) {
if (targetDate) {
const newEvent: Event = {
id: Date.now(),
title,
start: new Date(`${format(selectedDate, "yyyy-MM-dd")}T${startTime}`),
end: new Date(`${format(selectedDate, "yyyy-MM-dd")}T${endTime}`),
description,
date,
startTime,
endTime,
category,
priority,
start: new Date(`${format(date, "yyyy-MM-dd")}T${startTime}`),
end: new Date(`${format(date, "yyyy-MM-dd")}T${endTime}`),
location,
invitees,
isTask,
Expand All @@ -148,7 +144,9 @@ function EventCreator({
<div className="w-2/5">
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-md p-2">
<h3 className="text-sm font-semibold mb-2">
{format(date || new Date(), "yyyy年MM月dd日 (E)", { locale: ja })}
{format(targetDate || new Date(), "yyyy年MM月dd日 (E)", {
locale: ja,
})}
</h3>
<div className="space-y-1">
{Array.from({ length: 24 }).map((_, hour) => (
Expand Down Expand Up @@ -179,11 +177,11 @@ function EventCreator({
</div>

{isTask ? (
<DateTimeInput className="w-full" />
<DateTimeInput className="w-full" props={{ date: targetDate }} />
) : (
<div className="flex flex-col gap-2">
<DateTimeInput className="w-full" />
<DateTimeInput className="w-full" />
<DateTimeInput className="w-full" props={{ date: targetDate }} />
<DateTimeInput className="w-full" props={{ date: targetDate }} />
</div>
)}

Expand Down Expand Up @@ -810,6 +808,7 @@ export default function Home() {
setIsEventModalOpen(false);
}}
initialTitle={draggedStickyNote ? draggedStickyNote.title : ""}
targetDate={selectedDate}
/>
</DialogContent>
</Dialog>
Expand Down

0 comments on commit 03262d6

Please sign in to comment.