Skip to content

Commit

Permalink
feat: 잘못된 코드수정 복원
Browse files Browse the repository at this point in the history
  • Loading branch information
lurgi committed Dec 24, 2024
1 parent 684c602 commit c183a73
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions frontend/src/components/recruitmentPost/ApplyForm/useAnswers.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import { Question } from '@customTypes/apply';
import { useState } from 'react';
import { useEffect, useState } from 'react';

interface AnswerFormData {
[key: string]: string[];
}

export const useAnswers = (questions: Question[]) => {
// const [answers, setAnswers] = useState<AnswerFormData>({});
// TODO: useLocalStorageState() 사용하기
const [answers, setAnswers] = useState<AnswerFormData>(
questions.reduce((acc, question) => ({ ...acc, [question.questionId]: [] }), {} as AnswerFormData),
);

// useEffect(() => {
// if (questions.length > 0) {
// const initialAnswers = questions.reduce(
// (acc, question) => ({ ...acc, [question.questionId]: [] }),
// {} as AnswerFormData,
// );
// setAnswers(initialAnswers);
// }
// }, [questions]);
useEffect(() => {
if (questions.length > 0) {
const initialAnswers = questions.reduce(
(acc, question) => ({ ...acc, [question.questionId]: [] }),
{} as AnswerFormData,
);
setAnswers(initialAnswers);
}
}, [questions]);

const handleText = (id: string, value: string) => {
setAnswers((prev) => ({ ...prev, [id]: [value] }));
Expand Down

0 comments on commit c183a73

Please sign in to comment.