Skip to content

Commit

Permalink
fix:#5 key값 타입에러 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
dalzzy committed Jan 4, 2025
1 parent 0ee4679 commit da85b40
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
51 changes: 25 additions & 26 deletions src/components/SignUp/BirthdayGenderStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const BirthdayGenderStep: React.FC<{ onNext: () => void }> = ({ onNext }) => {

const { year, month, day, gender } = signupState;

const birthInputFields: {
label: string;
key: keyof typeof signupState;
maxLength: number;
width: string;
}[] = [
{ label: '년', key: 'year', maxLength: 4, width: '100px' },
{ label: '월', key: 'month', maxLength: 2, width: '40px' },
{ label: '일', key: 'day', maxLength: 2, width: '40px' },
];

const handleInputChange = (key: string, value: string) => {
setSignupState((prev) => ({
...prev,
Expand All @@ -41,7 +52,7 @@ const BirthdayGenderStep: React.FC<{ onNext: () => void }> = ({ onNext }) => {
setSignupState((prev) => ({ ...prev, gender }));
};

const handleBlur = (key: string) => {
const handleBlur = (key: keyof typeof signupState) => {
setTouched((prev) => ({
...prev,
[key]: true,
Expand Down Expand Up @@ -78,31 +89,19 @@ const BirthdayGenderStep: React.FC<{ onNext: () => void }> = ({ onNext }) => {
</Description>
<InputWrapper>
<InputContainer>
<SignUpInput
type="text"
maxLength={4}
width="100px"
onChange={(e) => handleInputChange('year', e.target.value)}
onBlur={() => handleBlur('year')}
/>
<Text></Text>

<SignUpInput
type="text"
maxLength={2}
width="40px"
onChange={(e) => handleInputChange('month', e.target.value)}
onBlur={() => handleBlur('month')}
/>
<Text></Text>
<SignUpInput
type="text"
maxLength={2}
width="40px"
onChange={(e) => handleInputChange('day', e.target.value)}
onBlur={() => handleBlur('day')}
/>
<Text></Text>
{birthInputFields.map(({ label, key, maxLength, width }) => (
<>
<SignUpInput
type="text"
maxLength={maxLength}
width={width}
value={signupState[key]}
onChange={(e) => handleInputChange(key, e.target.value)}
onBlur={() => handleBlur(key)}
/>
<Text>{label}</Text>
</>
))}
</InputContainer>
{errorMessage && <InputErrorMessage message={errorMessage} />}
</InputWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/recoil/atoms/userAtom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export const signupAtom = atom({
mbti: '',
nickname: '',
studentId: '',
profilePhoto: null,
profilePhoto: undefined,
},
});

0 comments on commit da85b40

Please sign in to comment.