Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: #94 ERD와 Swagger를 참고하여 타입 재정의
Browse files Browse the repository at this point in the history
Seok93 committed Aug 29, 2024
1 parent c4a9782 commit aff2f31
Showing 9 changed files with 40 additions and 48 deletions.
3 changes: 2 additions & 1 deletion src/components/modal/project/ModalProjectForm.tsx
Original file line number Diff line number Diff line change
@@ -5,10 +5,11 @@ import type { Project } from '@/types/ProjectType';

type ModalProjectFormProps = {
formId: string;
projectId?: Project['projectId'];
onSubmit: SubmitHandler<Project>;
};

export default function ModalProjectForm({ formId, onSubmit }: ModalProjectFormProps) {
export default function ModalProjectForm({ formId, projectId, onSubmit }: ModalProjectFormProps) {
const { handleSubmit } = useForm<Project>();
return (
<form id={formId} className="mb-10 flex grow flex-col justify-center" onSubmit={handleSubmit(onSubmit)}>
2 changes: 1 addition & 1 deletion src/components/modal/team/ModalTeamForm.tsx
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import type { Team } from '@/types/TeamType';

type ModalTeamFormProps = {
formId: string;
teamId: Team['teamId'];
teamId?: Team['teamId'];
onSubmit: SubmitHandler<Team>;
};

4 changes: 2 additions & 2 deletions src/components/task/kanban/TaskItemList.tsx
Original file line number Diff line number Diff line change
@@ -23,9 +23,9 @@ export default function TaskItemList({ statusId, colorCode, tasks }: TaskItemLis
{...taskDropProvided.droppableProps}
>
{tasks.map((task) => {
const { taskId, name, order } = task;
const { taskId, name, sortOrder } = task;
const draggableId = generatePrefixId(taskId, DND_DRAGGABLE_PREFIX.TASK);
const index = order - 1;
const index = sortOrder - 1;
return <TaskItem key={taskId} draggableId={draggableId} colorCode={colorCode} index={index} name={name} />;
})}
{taskDropProvided.placeholder}
46 changes: 24 additions & 22 deletions src/mocks/mockData.ts
Original file line number Diff line number Diff line change
@@ -460,8 +460,6 @@ export const PROJECT_DUMMY: Project[] = [
content: '상담용 챗봇을 만드는 프로젝트',
startDate: null,
endDate: null,
createAt: new Date('2023-11-01'),
updateAt: new Date('2023-11-01'),
},
{
projectId: 2,
@@ -470,8 +468,6 @@ export const PROJECT_DUMMY: Project[] = [
content: '팀원을 모아 프로젝트를 진행하며, 진척도를 관리하는 프로젝트',
startDate: new Date('2024-05-15 00:00:00'),
endDate: new Date('2024-09-01 00:00:00'),
createAt: new Date('2024-05-15'),
updateAt: new Date('2024-05-15'),
},
{
projectId: 3,
@@ -480,8 +476,6 @@ export const PROJECT_DUMMY: Project[] = [
content: '이벤트/모임을 등록하여 참여자를 모집하는 프로젝트',
startDate: new Date('2023-06-05 00:00:00'),
endDate: new Date('2023-09-12 00:00:00'),
createAt: new Date('2023-06-05'),
updateAt: new Date('2023-06-05'),
},
] as const;

@@ -569,7 +563,7 @@ export const TASK_DUMMY: Task[] = [
name: 'task 상태 추가 모달 작업하기',
sortOrder: 1,
statusId: 6,
userId: 1,
userId: [1],
content: '',
files: [],
startDate: '2024-06-22',
@@ -580,7 +574,7 @@ export const TASK_DUMMY: Task[] = [
name: 'project layout 작성하기',
sortOrder: 2,
statusId: 6,
userId: 3,
userId: [3],
content: '',
files: [],
startDate: '2024-06-18',
@@ -591,7 +585,7 @@ export const TASK_DUMMY: Task[] = [
name: 'tailwindcss 설정하기',
sortOrder: 3,
statusId: 6,
userId: 9,
userId: [9],
content: '',
files: [],
startDate: '2024-06-14',
@@ -603,7 +597,7 @@ export const TASK_DUMMY: Task[] = [
name: 'API 명세서 작성하기',
sortOrder: 2,
statusId: 5,
userId: 1,
userId: [1],
content: '',
files: [],
startDate: '2024-06-27',
@@ -614,7 +608,7 @@ export const TASK_DUMMY: Task[] = [
name: 'DnD 기술 조사하기',
sortOrder: 1,
statusId: 5,
userId: 3,
userId: [3],
content: `# AITalk\n## 주제\nDnD 기술 조사하기\n\n※\`DnD\`란 Drag and Drop의 약자다\n\n## 라이브러리 선정\n[react-beautiful-dnd](https://github.com/atlassian/react-beautiful-dnd) 등과 같이 다양한 라이브러리 중 어느 것을 선정할 것인가?`,
files: [],
startDate: '2024-06-27',
@@ -626,7 +620,7 @@ export const TASK_DUMMY: Task[] = [
name: '할일 추가 모달 구현하기',
sortOrder: 1,
statusId: 4,
userId: 1,
userId: [1],
content: '',
files: [],
startDate: '2024-06-26',
@@ -637,7 +631,7 @@ export const TASK_DUMMY: Task[] = [
name: 'ID 찾기 페이지 작성하기',
sortOrder: 2,
statusId: 4,
userId: 3,
userId: [3],
content: '',
files: [],
startDate: '2024-07-03',
@@ -648,7 +642,7 @@ export const TASK_DUMMY: Task[] = [
name: 'DnD 구현하기',
sortOrder: 3,
statusId: 4,
userId: 9,
userId: [9],
content: '',
files: [],
startDate: '2024-06-30',
@@ -668,7 +662,8 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
taskId: 6,
name: '할일 추가 모달 구현하기',
sortOrder: 1,
userId: 1,
statusId: 1,
userId: [1],
content: '',
files: [],
startDate: '2024-06-26',
@@ -678,7 +673,8 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
taskId: 7,
name: 'ID 찾기 페이지 작성하기',
sortOrder: 2,
userId: 3,
statusId: 1,
userId: [3],
content: '',
files: [],
startDate: '2024-07-03',
@@ -688,7 +684,8 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
taskId: 8,
name: 'DnD 구현하기',
sortOrder: 3,
userId: 9,
statusId: 1,
userId: [9],
content: '',
files: [],
startDate: '2024-06-30',
@@ -706,7 +703,8 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
taskId: 5,
name: 'DnD 기술 조사하기',
sortOrder: 1,
userId: 3,
statusId: 2,
userId: [3],
content: `# AITalk\n## 주제\nDnD 기술 조사하기\n\n※\`DnD\`란 Drag and Drop의 약자다\n\n## 라이브러리 선정\n[react-beautiful-dnd](https://github.com/atlassian/react-beautiful-dnd) 등과 같이 다양한 라이브러리 중 어느 것을 선정할 것인가?`,
files: [],
startDate: '2024-06-27',
@@ -716,7 +714,8 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
taskId: 4,
name: 'API 명세서 작성하기',
sortOrder: 2,
userId: 1,
statusId: 2,
userId: [1],
content: '',
files: [],
startDate: '2024-06-27',
@@ -734,7 +733,8 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
taskId: 1,
name: 'task 상태 추가 모달 작업하기',
sortOrder: 1,
userId: 1,
statusId: 3,
userId: [1],
content: '',
files: [],
startDate: '2024-06-22',
@@ -744,7 +744,8 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
taskId: 2,
name: 'project layout 작성하기',
sortOrder: 2,
userId: 3,
statusId: 3,
userId: [3],
content: '',
files: [],
startDate: '2024-06-18',
@@ -754,7 +755,8 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
taskId: 3,
name: 'tailwindcss 설정하기',
sortOrder: 3,
userId: 9,
statusId: 3,
userId: [9],
content: '',
files: [],
startDate: '2024-06-14',
4 changes: 2 additions & 2 deletions src/pages/project/CalendarPage.tsx
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@ function getCalendarTask(statusTasks: TaskListWithStatus[]) {
const calendarTasks: TaskWithStatus[] = [];

statusTasks.forEach((statusTask) => {
const { statusId, name: statusName, colorCode, sortOrder: statusOrder, tasks } = statusTask;
const { name: statusName, colorCode, sortOrder: statusOrder, tasks } = statusTask;
tasks.forEach((task) => {
calendarTasks.push({ statusId, statusName, colorCode, statusOrder, ...task });
calendarTasks.push({ statusName, colorCode, statusOrder, ...task });
});
});

4 changes: 2 additions & 2 deletions src/pages/project/KanbanPage.tsx
Original file line number Diff line number Diff line change
@@ -13,10 +13,10 @@ function createChangedStatus(statusTasks: TaskListWithStatus[], dropResult: Drop
if (!destination) throw Error('Error: DnD destination is null');

const newStatusTasks = deepClone(statusTasks);
const stausTask = newStatusTasks[source.index];
const statusTask = newStatusTasks[source.index];

newStatusTasks.splice(source.index, 1);
newStatusTasks.splice(destination.index, 0, stausTask);
newStatusTasks.splice(destination.index, 0, statusTask);
newStatusTasks.forEach((status, index) => (status.sortOrder = index + 1));

return newStatusTasks;
3 changes: 1 addition & 2 deletions src/types/ProjectStatusType.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ToDo: API 설계 완료시 데이터 타입 변경할 것
export type ProjectStatus = {
statusId: number;
projectId: number;
@@ -7,6 +6,6 @@ export type ProjectStatus = {
sortOrder: number;
};

export type ProjectStatusForm = Pick<ProjectStatus, 'colorCode' | 'name'>;
export type ProjectStatusForm = Pick<ProjectStatus, 'name' | 'colorCode'>;

export type UsableColor = Pick<ProjectStatus, 'colorCode'> & { isUsable: boolean };
2 changes: 0 additions & 2 deletions src/types/ProjectType.tsx
Original file line number Diff line number Diff line change
@@ -6,6 +6,4 @@ export type Project = {
content: string;
startDate: Date | null;
endDate: Date | null;
createAt: Date;
updateAt: Date;
};
20 changes: 6 additions & 14 deletions src/types/TaskType.tsx
Original file line number Diff line number Diff line change
@@ -9,28 +9,20 @@ type StatusKeyMapping = {
sortOrder: 'statusOrder';
};

// ToDo: API 설계 완료시 데이터 타입 변경할 것
export type Task = {
taskId: number;
name: string;
userId: number;
userId: number[];
statusId: number;
name: string;
content: string;
startDate: string;
endDate: string;
files: string[];
sortOrder: number;
};

// ToDo: Task 추가 모달 작업시 같이 정의할 것
export type TaskForm = {
name: string;
content: string;
userId: number[];
startDate: string;
endDate: string;
statusId: number;
};
export type TaskForm = Omit<Task, 'taskId' | 'files'>;

export type TaskWithStatus = RenameKeys<Omit<ProjectStatus, 'projectId'>, StatusKeyMapping> & Task;

export type TaskWithStatus = RenameKeys<Omit<ProjectStatus, 'projectId'>, StatusKeyMapping> & Omit<Task, 'statusId'>;
export type TaskListWithStatus = Omit<ProjectStatus, 'projectId'> & { tasks: Omit<Task, 'statusId'>[] };
export type TaskListWithStatus = Omit<ProjectStatus, 'projectId'> & { tasks: Task[] };

0 comments on commit aff2f31

Please sign in to comment.