Skip to content

Commit

Permalink
Chore: #101 프로젝트 상태 타입 정의 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Seok93 committed Sep 4, 2024
1 parent 3967b28 commit 5be40f3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export default function ModalProjectStatusForm({ formId, project, statusId, onSu
<DuplicationCheckInput
id="name"
label="상태명"
value={watch('name')}
value={watch('statusName')}
placeholder="상태명을 입력하세요."
errors={errors.name?.message}
register={register('name', STATUS_VALIDATION_RULES.STATUS_NAME(nameList))}
errors={errors.statusName?.message}
register={register('statusName', STATUS_VALIDATION_RULES.STATUS_NAME(nameList))}
/>
<h3 className="text-large">색상</h3>
<section className="grid grid-cols-8 gap-4">
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/query/useStatusQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { getStatusList } from '@services/statusService';
import type { Project } from '@/types/ProjectType';
import type { ProjectStatus, UsableColor } from '@/types/ProjectStatusType';

function getStatusNameList(statusList: ProjectStatus[], excludedName?: ProjectStatus['name']) {
const statusNameList = statusList.map((projectStatus) => projectStatus.name);
function getStatusNameList(statusList: ProjectStatus[], excludedName?: ProjectStatus['statusName']) {
const statusNameList = statusList.map((projectStatus) => projectStatus.statusName);

const statusNameSet = new Set(statusNameList);
if (excludedName && statusNameSet.has(excludedName)) {
Expand Down Expand Up @@ -61,8 +61,8 @@ export default function useStatusQuery(projectId: Project['projectId'], statusId
});

const status = statusList.find((status) => status.statusId === statusId);
const initialValue = { name: status?.name || '', color: status?.colorCode || '' };
const nameList = getStatusNameList(statusList, status?.name);
const initialValue = { name: status?.statusName || '', colorCode: status?.colorCode || '' };
const nameList = getStatusNameList(statusList, status?.statusName);
const colorList = getStatusColorList(statusList, status?.colorCode);
const usableColorList = getUsableStatusColorList(statusList, status?.colorCode);

Expand Down
26 changes: 13 additions & 13 deletions src/mocks/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,72 +485,72 @@ export const STATUS_DUMMY: ProjectStatus[] = [
{
statusId: 1,
projectId: 1,
name: '할일',
statusName: '할일',
colorCode: PROJECT_STATUS_COLORS.RED,
sortOrder: 1,
},
{
statusId: 2,
projectId: 1,
name: '진행중',
statusName: '진행중',
colorCode: PROJECT_STATUS_COLORS.YELLOW,
sortOrder: 2,
},
{
statusId: 3,
projectId: 1,
name: '완료',
statusName: '완료',
colorCode: PROJECT_STATUS_COLORS.GREEN,
sortOrder: 3,
},
// 프로젝트2 상태
{
statusId: 4,
projectId: 2,
name: '할일',
statusName: '할일',
colorCode: PROJECT_STATUS_COLORS.RED,
sortOrder: 1,
},
{
statusId: 5,
projectId: 2,
name: '진행중',
statusName: '진행중',
colorCode: PROJECT_STATUS_COLORS.YELLOW,
sortOrder: 2,
},
{
statusId: 6,
projectId: 2,
name: '완료',
statusName: '완료',
colorCode: PROJECT_STATUS_COLORS.GREEN,
sortOrder: 3,
},
// 프로젝트3 상태
{
statusId: 7,
projectId: 3,
name: 'To Do',
statusName: 'To Do',
colorCode: PROJECT_STATUS_COLORS.YELLOW,
sortOrder: 1,
},
{
statusId: 8,
projectId: 3,
name: 'In Progress',
statusName: 'In Progress',
colorCode: PROJECT_STATUS_COLORS.ORANGE,
sortOrder: 2,
},
{
statusId: 9,
projectId: 3,
name: 'In Review',
statusName: 'In Review',
colorCode: PROJECT_STATUS_COLORS.RED,
sortOrder: 3,
},
{
statusId: 10,
projectId: 3,
name: 'Done',
statusName: 'Done',
colorCode: PROJECT_STATUS_COLORS.BLUE,
sortOrder: 4,
},
Expand Down Expand Up @@ -654,7 +654,7 @@ export const TASK_DUMMY: Task[] = [
export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
{
statusId: 1,
name: 'To Do',
statusName: 'To Do',
colorCode: '#c83c00',
sortOrder: 1,
tasks: [
Expand Down Expand Up @@ -695,7 +695,7 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
},
{
statusId: 2,
name: 'In Progress',
statusName: 'In Progress',
colorCode: '#dab700',
sortOrder: 2,
tasks: [
Expand Down Expand Up @@ -725,7 +725,7 @@ export const TASK_SPECIAL_DUMMY: TaskListWithStatus[] = [
},
{
statusId: 3,
name: 'Done',
statusName: 'Done',
colorCode: '#237700',
sortOrder: 3,
tasks: [
Expand Down
4 changes: 2 additions & 2 deletions src/types/ProjectStatusType.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export type ProjectStatus = {
statusId: number;
projectId: number;
name: string;
statusName: string;
colorCode: string;
sortOrder: number;
};

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

export type UsableColor = Pick<ProjectStatus, 'colorCode'> & { isUsable: boolean };

0 comments on commit 5be40f3

Please sign in to comment.