Skip to content

Commit 7f3db83

Browse files
committed
fix: resolve conflict
2 parents 2fddcc7 + 5d563fb commit 7f3db83

File tree

6 files changed

+39
-21
lines changed

6 files changed

+39
-21
lines changed

src/components/Task/Task.tsx

+16-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Task = (props: ITask) => {
1717

1818
const { t } = useTranslation();
1919

20-
// const { open } = usePopup();
20+
const { open } = usePopup();
2121

2222
const toggleHandler = (e: MouseEvent<HTMLElement>) => {
2323
e.preventDefault();
@@ -26,21 +26,21 @@ const Task = (props: ITask) => {
2626

2727
const deleteHandler = (e: MouseEvent<HTMLElement>) => {
2828
e.preventDefault();
29-
// open({
30-
// message: t('delete_task', { title: title }),
31-
// title: t('delete'),
32-
// buttons: [
33-
// {
34-
// type: 'destructive',
35-
// text: t('delete'),
36-
// id: 'confirm',
37-
// },
38-
// {
39-
// type: 'cancel',
40-
// },
41-
// ],
42-
// onConfirm: () => deleteTask({ id }),
43-
// });
29+
open({
30+
message: t('delete_task', { title: title }),
31+
title: t('delete'),
32+
buttons: [
33+
{
34+
type: 'destructive',
35+
text: t('delete'),
36+
id: 'confirm',
37+
},
38+
{
39+
type: 'cancel',
40+
},
41+
],
42+
onConfirm: () => deleteTask({ id }),
43+
});
4444
};
4545

4646
return (

src/containers/CategoryForm/CategoryForm.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useMemo } from 'react';
1717
import { yupResolver } from '@hookform/resolvers/yup';
1818
import Header from '@/components/Header';
1919
import { useBackButton } from '@/hooks/useBackButton';
20+
import NotFound from '@/components/NotFound';
2021

2122
interface IProps {
2223
type: IFormType;
@@ -70,6 +71,8 @@ const CategoryForm = ({ type }: IProps) => {
7071

7172
if (isLoading) return 'loading...';
7273

74+
if (!category && type === 'edit') return <NotFound />;
75+
7376
return (
7477
<div>
7578
<Header>

src/containers/TaskForm/TaskForm.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { yupResolver } from '@hookform/resolvers/yup';
1717
import { useCreateTask, useEditTask, useTask } from '@/hooks/api/task';
1818
import Header from '@/components/Header';
1919
import { useBackButton } from '@/hooks/useBackButton';
20+
import NotFound from '@/components/NotFound';
2021

2122
interface IProps {
2223
type: IFormType;
@@ -86,10 +87,16 @@ const TaskForm = ({ type }: IProps) => {
8687

8788
if (isLoading) return 'loading...';
8889

90+
if (!task && type === 'edit') return <NotFound />;
91+
8992
return (
9093
<div>
9194
<Header>
92-
<h1>{t('new_task')}</h1>
95+
<h1>
96+
{type === 'create'
97+
? t('new_task')
98+
: t('edit_task', { title: task?.title || '' })}
99+
</h1>
93100
</Header>
94101
<div className={styles.taskForm}>
95102
<FormProvider {...methods}>

src/containers/TodoListForm/TodoListForm.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from '@/hooks/api/todo-list';
1616
import Header from '@/components/Header';
1717
import { useBackButton } from '@/hooks/useBackButton';
18+
import NotFound from '@/components/NotFound';
1819

1920
interface IProps {
2021
type: IFormType;
@@ -69,10 +70,16 @@ const TodoListForm = ({ type }: IProps) => {
6970

7071
if (isLoading) return 'loading...';
7172

73+
if (!todoList && type === 'edit') return <NotFound />;
74+
7275
return (
7376
<div>
7477
<Header>
75-
<h1>{t('new_todo_list')}</h1>
78+
<h1>
79+
{type === 'create'
80+
? t('new_todo_list')
81+
: t('edit_todo_list', { title: todoList?.title || '' })}
82+
</h1>
7683
</Header>
7784
<div className={styles.todoListForm}>
7885
<FormProvider {...methods}>

src/pages/api/todoList/[id].ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default withAuthorization(async function handler(
2929

3030
case 'PUT':
3131
// Handle HTTP PUT request (update a todoList)
32-
const { title, categoryId } = req.body; // Extract updated todoList data from the request body
32+
const { title, categoryId, description } = req.body; // Extract updated todoList data from the request body
3333

3434
// Validate the extracted data using the todoListSchema
3535
await todoListSchema.validate({
@@ -40,7 +40,7 @@ export default withAuthorization(async function handler(
4040
// Update the todoList in the database
4141
await prisma.todoList.update({
4242
where: { id: idAsString },
43-
data: { title, categoryId },
43+
data: { title, categoryId, description },
4444
});
4545

4646
res.status(201).json('success'); // Respond with a success message

src/pages/api/todoList/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default withAuthorization(async function handler(
1313
switch (req.method) {
1414
case 'POST':
1515
// Handle HTTP POST request (create a new todoList)
16-
const { title, categoryId } = req.body; // Extract todoList data from the request body
16+
const { title, categoryId, description } = req.body; // Extract todoList data from the request body
1717

1818
// Validate the extracted data using the todoListSchema
1919
await todoListSchema.validate({ title, categoryId });
@@ -24,6 +24,7 @@ export default withAuthorization(async function handler(
2424
userId,
2525
title,
2626
categoryId,
27+
description,
2728
},
2829
});
2930

0 commit comments

Comments
 (0)