Skip to content

Commit

Permalink
fix: 파일 업로드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chaeseungyun committed Sep 11, 2024
1 parent ca15101 commit 751feba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@
font-weight: 500;
background-color: #175c8e;
color: white;
cursor: pointer;
}
}
5 changes: 4 additions & 1 deletion src/page/Auth/Signup/components/fileUploadModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useRef } from 'react';
import { createPortal } from 'react-dom';
import styles from './fileUploadModal.module.scss';

Expand All @@ -7,6 +8,7 @@ interface FileUploadModalProps {
}

export default function FileUploadModal({ onClose, onUpload }: FileUploadModalProps) {
const fileInputRef = useRef<HTMLInputElement>(null);
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (event.target.files) {
onUpload(event.target.files);
Expand Down Expand Up @@ -36,6 +38,7 @@ export default function FileUploadModal({ onClose, onUpload }: FileUploadModalPr
onChange={handleFileChange}
style={{ display: 'none' }}
id="file-upload"
ref={fileInputRef}
/>
<button
type="button"
Expand All @@ -47,7 +50,7 @@ export default function FileUploadModal({ onClose, onUpload }: FileUploadModalPr
<button
type="button"
className={styles['upload-button--upload']}
onClick={() => document.getElementById('file-upload')?.click()}
onClick={() => fileInputRef.current?.click()}
>
첨부하기
</button>
Expand Down
7 changes: 7 additions & 0 deletions src/page/Auth/Signup/components/ownerInfoStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FileUploadModal from 'page/Auth/Signup/components/fileUploadModal';
import useUploadFile from 'query/upload';
import { isKoinError, sendClientError } from '@bcsdlab/koin';
import showToast from 'utils/ts/showToast';
import { toast } from 'react-toastify';
import styles from './ownerInfoStep.module.scss';

interface OwnerInfo {
Expand Down Expand Up @@ -45,6 +46,10 @@ export default function OwnerInfoStep({ onSearch, setIsStepComplete }: OwnerInfo
const response = await uploadFiles(formData);
const { file_urls: fileUrls } = response.data;
const formattedUrls = fileUrls.map((url: string) => ({ file_url: url }));
if (formattedUrls.length + uploadedFiles.length > 5) {
toast.error('파일은 최대 5개 등록할 수 있습니다');
return;
}
setUploadedFiles((prev) => [...prev, ...formattedUrls]);
setFileNames((prev) => [...prev, ...names]);
setValue('attachment_urls', [...uploadedFiles, ...formattedUrls]);
Expand Down Expand Up @@ -157,6 +162,8 @@ export default function OwnerInfoStep({ onSearch, setIsStepComplete }: OwnerInfo
},
})}
placeholder="숫자만 입력해주세요."
type="text"
inputMode="numeric"
onChange={handleCompanyNumberChange}
/>
{errors.company_number && <span className={styles['error-message']}>{errors.company_number.message}</span>}
Expand Down

0 comments on commit 751feba

Please sign in to comment.