Skip to content

Commit

Permalink
refactor: 상수 사용 및 타입 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
lurgi committed Aug 7, 2024
1 parent 10ddabf commit 722e2c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions frontend/src/hooks/useDashboardCreateForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function useDashboardCreateForm(): UseDashboardCreateFormReturn {
const setQuestionOptions = (index: number) => (options: Option[]) => {
setApplyState((prevState) => {
const questionsCopy = [...prevState];
questionsCopy[index].choices = options.map(({ value }, i) => ({ choice: value, order_index: i }));
questionsCopy[index].choices = options.map(({ value }, i) => ({ choice: value, orderIndex: i }));
return questionsCopy;
});
};
Expand All @@ -89,7 +89,7 @@ export default function useDashboardCreateForm(): UseDashboardCreateFormReturn {

const setQuestionPrev = (index: number) => () => {
setApplyState((prevState) => {
if (index > 3) {
if (index > initialApplyState.length) {
const questionsCopy = [...prevState];
const temp = questionsCopy[index];
questionsCopy[index] = questionsCopy[index - 1];
Expand All @@ -102,7 +102,7 @@ export default function useDashboardCreateForm(): UseDashboardCreateFormReturn {

const setQuestionNext = (index: number) => () => {
setApplyState((prevState) => {
if (index >= 3 && index < prevState.length - 1) {
if (index >= initialApplyState.length && index < prevState.length - 1) {
const questionsCopy = [...prevState];
const temp = questionsCopy[index];
questionsCopy[index] = questionsCopy[index + 1];
Expand All @@ -114,7 +114,7 @@ export default function useDashboardCreateForm(): UseDashboardCreateFormReturn {
};

const deleteQuestion = (index: number) => {
if (index < 3) return;
if (index < initialApplyState.length) return;
setApplyState((prevState) => prevState.filter((_, i) => i !== index));
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/types/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export interface Question {
question: string;
choices: {
choice: string;
order_index: number;
orderIndex: number;
}[];
required: boolean;
}
Expand All @@ -21,5 +21,5 @@ export type StepState = 'recruitmentForm' | 'applyForm' | 'finished';

export interface QuestionOption {
choice: string;
order_index: number;
orderIndex: number;
}

0 comments on commit 722e2c4

Please sign in to comment.