Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/common/CheckList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import Plus from '@assets/icons/plus.svg?react';
import BookMarkIcon from '@assets/icons/bookmark.svg?react';
import { useUpdateTodoMutation } from '@hook/todo/useUpdateTodoMutation.ts';

type ChecklistItem = string | { id?: number; text: string };
type ChecklistItem = string | { id?: number; text: string; saveCount?: number };

interface CheckListProps {
lists: ChecklistItem[];
checkedIds?: number[];
className?: string;
onChange?: (checkedIds: number[]) => void;
showAddButton?: boolean;
saveCount?: number;
}

const CheckList = ({
Expand All @@ -34,7 +35,7 @@ const CheckList = ({
const isMyToPage = location.pathname.startsWith('/mytodo/list');
const { mutate: updateTodo } = useUpdateTodoMutation();
const normalized = lists.map((item) =>
typeof item === 'string' ? { text: item } : item
typeof item === 'string' ? { text: item, saveCount: 0 } : item
);

const [editIndex, setEditIndex] = useState<number | null>(null);
Expand Down Expand Up @@ -264,7 +265,9 @@ const CheckList = ({
<>
<div className="mr-3 flex items-center gap-1 text-gray-500">
<BookMarkIcon className="h-[18px] w-[18px]" />
<span className="text-sm font-B03-SB">999</span>
<span className="text-sm font-B03-SB">
{item.saveCount ?? 0}
</span>
</div>
<button
onClick={() => handleEdit(idx)}
Expand Down
2 changes: 2 additions & 0 deletions src/hook/useJobQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ export interface EachTodos {
completed: boolean;
isMemoExist: boolean;
isPublic: boolean;
saveCount?: number;
isSaved?: boolean;
},
];
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/otherTodoList/OtherTodoListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const OtherTodoListPage = () => {
clickText: '타인의 할 일 페이지 진입 시',
source_page: location.pathname,
});
}, []);
}, [location.pathname]);
const navigate = useNavigate();
const { todoGroupId } = useParams<{ todoGroupId: string }>();
const {
Expand Down Expand Up @@ -103,6 +103,8 @@ const OtherTodoListPage = () => {
title: todo.title,
completed: todo.completed,
isPublic: todo.isPublic,
saveCount: todo.saveCount,
isSaved: todo.isSaved,
}))}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/otherTodoList/components/OtherTodoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const OtherTodoCard = ({ todos }: TodoCardProps) => {
const isAdded =
typeof added[item.todoId] === 'boolean'
? added[item.todoId]
: item.isSaved || false;
: (item.isSaved ?? false);

return (
<li
Expand Down