Skip to content

Commit

Permalink
feat: 홈 유틸 함수 타입 수정 및 파일 명 수정 (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
suwonthugger committed Jan 23, 2025
1 parent 4dc5c66 commit b626b6e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/shared/utils/homePage/index.ts → src/shared/utils/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Dayjs } from 'dayjs';

import { CategoryWithTasks, DailyData, Task } from '@/shared/types/home';
import { GetCategoryTaskRes } from '@/shared/types/api/home';
import type { CategoriesType, TaskListType } from '@/shared/types/tasks';

export const getDailyCategoryTask = (selectedDate: Dayjs, data: DailyData[]) => {
export const getDailyCategoryTask = (selectedDate: Dayjs, data: GetCategoryTaskRes['data']) => {
const formattedDate = selectedDate.format('YYYY-MM-DD');

let matchingCategories: CategoryWithTasks[] = [];
let matchingCategories: CategoriesType = [];

data.forEach(({ date, categories }) => {
if (date === formattedDate) {
Expand All @@ -16,9 +17,9 @@ export const getDailyCategoryTask = (selectedDate: Dayjs, data: DailyData[]) =>
return matchingCategories;
};

export const splitTasksByCompletion = (tasks: Task[]) => {
let completedTasks: Task[] = [];
let ongoingTasks: Task[] = [];
export const splitTasksByCompletion = (tasks: TaskListType) => {
let completedTasks: TaskListType = [];
let ongoingTasks: TaskListType = [];

tasks.forEach((task) => {
if (task.isComplete) {
Expand All @@ -31,6 +32,6 @@ export const splitTasksByCompletion = (tasks: Task[]) => {
return { completedTasks, ongoingTasks };
};

export const isTaskExist = (dailyCategoryTask: CategoryWithTasks[]) => {
export const isTaskExist = (dailyCategoryTask: CategoriesType) => {
return dailyCategoryTask.some((categoryWithTasks) => categoryWithTasks.tasks.length > 0);
};

0 comments on commit b626b6e

Please sign in to comment.