Skip to content

Commit

Permalink
refactor: 사진 업로드 토스트 로직 수정
Browse files Browse the repository at this point in the history
- 파일 입력을 ESC로 취소했을 경우 토스트 표시 X
- firstImage가 없고 기존 이미지가 있으면 기존 이미지 표시
  • Loading branch information
WaiNaat committed Sep 12, 2023
1 parent 1454d3d commit 83e7bb2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/src/pages/NewDictionaryPlantRequest/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ const Form = (props: FormProps) => {
};

const setImageIfValid: React.ChangeEventHandler<HTMLInputElement> = ({ target: { files } }) => {
if (!files) {
if (!files || files.length === 0) {
setImage(null);
return;
}

const firstImage = getFirstImage(files);
if (!firstImage) addToast('warning', '5MB 이하의 사진을 올려주세요!');
setImage(firstImage);
setImage(firstImage ? firstImage : image);
};

const isValidForm = isFormValid();
Expand Down

0 comments on commit 83e7bb2

Please sign in to comment.