Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 프로필 사진 undefined로 서버에 전송되는 이슈 해결 #366

Merged
merged 8 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"react-router-dom": "^6.23.1"
},
"devDependencies": {
"@hookform/devtools": "^4.3.1",
"@tanstack/eslint-plugin-query": "^5.35.6",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
Expand Down
3 changes: 2 additions & 1 deletion src/views/ApplyPage/components/DefaultSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ProfileImage = ({ disabled, pic }: ProfileImageProps) => {
setError,
formState: { errors },
} = useFormContext();
const [image, setImage] = useState('');
const [image, setImage] = useState<string | null>('');

const hasImage = image !== 'max-size' && (pic || image);

Expand All @@ -60,6 +60,7 @@ const ProfileImage = ({ disabled, pic }: ProfileImageProps) => {
reader.onloadend = () => {
clearErrors('picture');
setImage(reader.result as string);
setValue('picture', imageFile);
};
};

Expand Down
3 changes: 2 additions & 1 deletion src/views/ApplyPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { track } from '@amplitude/analytics-browser';
import { DevTool } from '@hookform/devtools';
import { useCallback, useEffect, useRef, useState } from 'react';
import { FormProvider, useForm } from 'react-hook-form';
import { useNavigate } from 'react-router-dom';
Expand Down Expand Up @@ -235,7 +236,7 @@ const ApplyPage = ({ onSetComplete }: ApplyPageProps) => {

const answers = JSON.stringify(answersValue);
const formValues: ApplyRequest = {
picture: picture?.[0],
picture,
pictureUrl: errors.picture ? undefined : applicantDraft?.pic,
part,
address,
Expand Down
Loading