Skip to content

Commit

Permalink
hide add new task card, but UI still need to be developed (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: Hong <hong@HongdeMacBook-Air.local>
Co-authored-by: Aug-8 <130132558+sol-wizard@users.noreply.github.com>
Co-authored-by: benjaminneoh <benjaminneoh6343@gmail.com>
  • Loading branch information
4 people authored Oct 7, 2024
1 parent a96bcd3 commit 72594ab
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions blotztask-ui/src/app/task-dayview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useEffect, useState } from 'react';
import { z } from 'zod';
import { taskDto } from './models/taskDto';
import { TaskDTO, taskDTOSchema } from './schema/schema';
import { Button } from '@/components/ui/button';
import { TaskForm } from './components/form';

// Define mock data
Expand Down Expand Up @@ -34,6 +35,9 @@ const validatedTasks = z.array(taskDTOSchema).parse(mockTasks);
export default function Dayview() {
const [tasks, setTasks] = useState<TaskDTO[]>(validatedTasks);

//add a state for add task button deciding to hide or show the form
const [isFormVisible, setIsFormVisible] = useState(false);

const handleCheckboxChange = (taskId) => {
setTasks((prevTasks) =>
prevTasks.map((t) => {
Expand All @@ -45,6 +49,10 @@ export default function Dayview() {
);
};

const toggleFormVisibility = () => {
setIsFormVisible(!isFormVisible);
};

useEffect(() => {
// Simulate fetching tasks
setTasks(validatedTasks);
Expand Down Expand Up @@ -86,12 +94,15 @@ export default function Dayview() {
))}

<div className="w-1/2">
<Card>
<CardHeader className="pb-1"></CardHeader>
<CardContent className="grid gap-1">
<TaskForm setTasks={setTasks} />
</CardContent>
</Card>
<Button onClick={toggleFormVisibility}>Add task</Button>
{isFormVisible && (
<Card>
<CardHeader className="pb-1"></CardHeader>
<CardContent className="grid gap-1">
<TaskForm setTasks={setTasks} />
</CardContent>
</Card>
)}
</div>
</div>
</div>
Expand Down

0 comments on commit 72594ab

Please sign in to comment.