Skip to content

Commit 8b660c8

Browse files
버그 수정
1 parent 709341e commit 8b660c8

File tree

10 files changed

+51
-37
lines changed

10 files changed

+51
-37
lines changed

app/(service)/(chat)/conversations/[conversationID]/page.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

components/service/chatbot/ChatbotIntro.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Image from 'next/image';
44
import { ChevronDown } from 'lucide-react';
55
import { useEffect, useState } from 'react';
66
import { Category } from '@/types/category';
7-
import { getCategoryItems } from '@/apis/category';
7+
import { fetchAllCategories } from '@/apis/category';
88
import { useRouter, useSearchParams } from 'next/navigation';
99

1010
type Props = {
@@ -21,13 +21,14 @@ export const ChatbotIntro = ({ showSelectBox }: Props) => {
2121
const fetchCategories = async () => {
2222
try {
2323
setIsLoading(true);
24-
const categories = await getCategoryItems();
25-
setCategories(categories);
24+
const response = await fetchAllCategories();
25+
const loadedCategories = response.data;
26+
setCategories(loadedCategories);
2627

2728
// 카테고리 로드 후, 파라미터가 없고 카테고리가 있으면 첫 번째 카테고리로 설정
28-
if (categories.length > 0 && !searchParams.get('categoryId') && showSelectBox) {
29+
if (loadedCategories.length > 0 && !searchParams.get('categoryId') && showSelectBox) {
2930
const params = new URLSearchParams(searchParams.toString());
30-
params.set('categoryId', categories[0].id);
31+
params.set('categoryId', loadedCategories[0].id);
3132
router.push(`${window.location.pathname}?${params.toString()}`);
3233
}
3334
} catch (error) {

components/service/chatbot/SidebarItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import { useEffect, useState } from 'react';
44
import { FolderOpen, Pencil, Trash2, Check, X } from 'lucide-react';
5-
import Link from 'next/link';
65
import { useRouter } from 'next/navigation';
76
import { ActionButton } from '@/components/common/ActionButton';
87
import { CategoryWithStorages } from '@/types/storage';
98
import { getUser } from '@/actions/user';
10-
import { getCategoryItems } from '@/apis/category';
9+
import { fetchAllCategories } from '@/apis/category';
1110
import { getStorage } from '@/apis/storage';
1211
import { SidebarSkeleton } from './SidebarSkeleton';
1312
import { useSidebarStore } from '@/stores/sidebar';
@@ -60,7 +59,8 @@ export const SidebarItem = () => {
6059
const user = await getUser();
6160

6261
// 2. 카테고리 목록 가져오기
63-
const categories = await getCategoryItems();
62+
const response = await fetchAllCategories();
63+
const categories = response.data;
6464

6565
// 3. 각 카테고리별 스토리지 가져오기
6666
const categoryStoragesPromises = categories.map(async (category) => {

components/service/profile/ProfileModal/ProfileModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Button } from '@/components/ui/button';
1616
import { PencilLine } from 'lucide-react';
1717
import { toast } from 'sonner';
1818

19-
import { updateUserData, GenderEnum, ProfileRequest } from '@/apis/profile';
19+
import { updateUserData, ProfileRequest } from '@/apis/profile';
2020

2121
type Props = {
2222
id: string;

components/service/schedule/Schedule.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { TodoAndMemoSection } from './TodoAndMemoSection';
55
import { getTodAndMemoList } from '@/apis/todo';
66
import { getUser } from '@/actions/user';
77
import { Suspense } from 'react';
8-
import { getCategoryItems } from '@/apis/category';
8+
import { fetchAllCategories } from '@/apis/category';
99
import { redirect } from 'next/navigation';
1010
export const Schedule = async () => {
1111
const user = await getUser();
@@ -19,7 +19,8 @@ export const Schedule = async () => {
1919
redirect('/login');
2020
}
2121

22-
const categoryItems = await getCategoryItems();
22+
const response = await fetchAllCategories();
23+
const categoryItems = response.data;
2324

2425
return (
2526
<main className="flex flex-col gap-4 bg-beige-light">

components/service/schedule/TodoAndMemoSection/index.tsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import Card from '@/components/common/Card';
44
import ChatbotHelperBox from '@/components/shared/ToDo/ChatbotHelperBox';
55
import TodoItem from '@/components/shared/ToDo/TodoItem';
66
import TodoPopup from '@/components/shared/ToDo/TodoPopup';
7+
import { cn } from '@/lib/utils';
78
import { todoListData } from '@/mocks/data';
89
import { useModalStore } from '@/stores/modal';
910
import { useTodoEditStore } from '@/stores/todoEditStore';
11+
import { useMemoStore } from '@/stores/useMemoStore';
1012
import { useTodoListStore } from '@/stores/useTodoListStore';
1113
import { Memo } from '@/types/memo';
1214
import { Todo } from '@/types/todo';
@@ -18,9 +20,9 @@ type Props = {
1820
};
1921

2022
export const TodoAndMemoSection = ({ todos, memos }: Props) => {
21-
// const { todoList } = useTodoListStore();
2223
const { openModal } = useModalStore();
2324
const { setEditingTodo } = useTodoEditStore();
25+
const { memoList } = useMemoStore();
2426
const handleOpenTodoModal = () => {
2527
setEditingTodo(null);
2628
openModal({
@@ -46,16 +48,25 @@ export const TodoAndMemoSection = ({ todos, memos }: Props) => {
4648
</ActionButton>
4749
</div>
4850
</div>
49-
<div className="flex flex-col gap-4 h-[300px] overflow-y-auto scrollbar-hide">
50-
{memos.map((memo) => (
51-
<div
52-
key={memo.id}
53-
className="flex flex-col justify-center w-full h-[96px] bg-beige-light rounded-lg p-4"
54-
>
55-
<div className="text-xl font-bold text-secondary">{memo.title}</div>
56-
<div className="text-lg text-primary">{memo.content}</div>
57-
</div>
58-
))}
51+
<div
52+
className={cn(
53+
'flex flex-col gap-4 h-[300px] overflow-y-auto scrollbar-hide',
54+
memoList.length === 0 && 'h-full'
55+
)}
56+
>
57+
{memoList.length > 0 ? (
58+
memoList.map((memo) => (
59+
<div
60+
key={memo.id}
61+
className="flex flex-col justify-center w-full h-[96px] bg-beige-light rounded-lg p-4"
62+
>
63+
<div className="text-xl font-bold text-secondary">{memo.title}</div>
64+
<div className="text-lg text-primary">{memo.content}</div>
65+
</div>
66+
))
67+
) : (
68+
<p className="text-lg text-center text-secondary mb-2">메모를 추가해주세요!</p>
69+
)}
5970
</div>
6071

6172
{/* todo 섹션 */}

components/shared/ToDo/TodoPopup.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ export default function TodoPopup() {
132132
let updatedTodo = null;
133133

134134
if (editingTodo) {
135-
updatedTodo = await editTodo(editingTodo.id, user?.id || '', {
135+
updatedTodo = await editTodo(editingTodo.id, user?.id || '', selectedCategory, {
136136
categoryId: selectedCategory,
137137
content: todoInputs[0].text,
138138
startDate: formatDateToYYYYMMDD(startDate),
139139
endDate: formatDateToYYYYMMDD(endDate),
140140
isRepeat,
141-
weeks: selectedDays.map((d) => ({ id: d, weekName: d })),
141+
weeks: selectedDays.map((d) => ({ id: d, weekName: Week[d as keyof typeof Week] })),
142142
isCompleted: false,
143143
});
144144
setEditingTodo(null);
@@ -187,6 +187,7 @@ export default function TodoPopup() {
187187
weekName: Week[d as keyof typeof Week],
188188
})),
189189
isCompleted: false,
190+
category: selectedItem,
190191
},
191192
user?.id || '',
192193
categoryId
@@ -231,7 +232,7 @@ export default function TodoPopup() {
231232
const handleDelete = async () => {
232233
try {
233234
if (editingTodo) {
234-
await removeTodo(editingTodo.id, user?.id || '');
235+
await removeTodo(editingTodo.id, user?.id || '', selectedCategory);
235236
toast.success('할 일이 삭제되었어요!');
236237
}
237238

hooks/useAnalyzetoday.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function useAnalyzeToday(
3131
return;
3232
}
3333

34-
const res = await fetchAllAnalyzeToday(userId, startDate, endDate);
34+
const res = await fetchAllAnalyzeToday(userId);
3535

3636
if (res.status_code === 200 && res.data) {
3737
setAnalyzeToday(res.data);

hooks/useTodoPopup.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react';
2-
import { Todo } from '@/types/todo';
2+
import { Todo } from '@/types/todopopup';
33
import { createTodo, updateTodo, deleteTodo } from '@/apis/todopopup';
44

55
export const useTodoPopup = () => {
@@ -16,21 +16,26 @@ export const useTodoPopup = () => {
1616
}
1717
};
1818

19-
const editTodo = async (todoId: string, userId: string, updated: Partial<Todo>) => {
19+
const editTodo = async (
20+
todoId: string,
21+
userId: string,
22+
categoryId: string,
23+
updated: Partial<Todo>
24+
) => {
2025
try {
2126
setError(null);
22-
const editedTodo = await updateTodo(todoId, userId, updated);
27+
const editedTodo = await updateTodo(todoId, userId, categoryId, updated);
2328
return editedTodo;
2429
} catch (err) {
2530
setError(err instanceof Error ? err.message : '할 일을 수정하는데 실패했습니다.');
2631
throw err;
2732
}
2833
};
2934

30-
const removeTodo = async (todoId: string, userId: string) => {
35+
const removeTodo = async (todoId: string, userId: string, categoryId: string) => {
3136
try {
3237
setError(null);
33-
await deleteTodo(todoId, userId);
38+
await deleteTodo(todoId, userId, categoryId);
3439
} catch (err) {
3540
setError(err instanceof Error ? err.message : '할 일을 삭제하는데 실패했습니다.');
3641
throw err;

types/todo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type Todo = {
1717
startDate: string;
1818
endDate: string;
1919
isCompleted: boolean;
20-
isRepeat?: boolean;
20+
isRepeat: boolean;
2121
weeks?: Week[];
2222
category?: Category;
2323
isDone?: boolean;

0 commit comments

Comments
 (0)