-
Notifications
You must be signed in to change notification settings - Fork 0
[#93] post 여러 가지 제한 걸기 #94
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
Changes from all commits
e4dcbc3
43b435f
d4b1e10
c9ad85e
49369a9
6fd7ccc
29fc353
1560e94
326391d
3f2c417
7326925
2a7142c
c219820
7d104db
3e0f57e
350f452
281ef86
65b554c
b14e55c
4378645
7ed9558
a7845a1
32e7662
614839b
3c579b2
85023db
9cb4330
7232f91
f0d7875
226eef6
1d3c207
4675380
0c16ec7
72d672a
3aa966b
5119326
a653a22
7569ca0
7b1eacd
126f5cf
6682728
2846142
217eeab
0102abc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import * as c from '../style.css'; | |
| import SelectedPhoto from '../../uploadedPhoto'; | ||
| import UploadFile from '../../UploadFile'; | ||
| import { useStep5Store } from '@/features/post/stores/Step5Store'; | ||
| import { ALLOWED_EXTENSIONS, MAX_DESC, MAX_SIZE_BYTES, MAX_SIZE_MB, MAX_TITLE } from '@/libs/constants'; | ||
|
|
||
| const Step5 = () => { | ||
| const fileStore = useStep5Store(state => state.files); | ||
|
|
@@ -23,7 +24,22 @@ const Step5 = () => { | |
|
|
||
| const fileArray = Array.from(files); | ||
|
|
||
| const updatedFiles = [...fileStore, ...fileArray]; | ||
| const validFiles = fileArray.filter(file => { | ||
| // TODO: alert 어떻게 띄워줄지 디자인 요청 | ||
| const ext = file.name.split('.').pop()?.toLowerCase(); | ||
| console.log(ext); | ||
| if (!ext || !ALLOWED_EXTENSIONS.includes(ext)) { | ||
| alert(`"${file.name}"은(는) 지원하지 않는 확장자입니다.`); | ||
| return false; | ||
| } | ||
| if (file.size > MAX_SIZE_BYTES) { | ||
| alert(`"${file.name}"은(는) ${MAX_SIZE_MB}MB를 초과합니다.`); | ||
| return false; | ||
| } | ||
| return true; | ||
| }); | ||
|
|
||
| const updatedFiles = [...fileStore, ...validFiles]; | ||
| fileSetter(updatedFiles); | ||
| }; | ||
|
|
||
|
|
@@ -44,18 +60,24 @@ const Step5 = () => { | |
| <header className={c.Head}>상품 소개를 작성해 주세요</header> | ||
| <div className={c.Content}> | ||
| <div className={c.DetailContent}> | ||
| 상품명을 입력해 주세요 | ||
| <InputField value={titleStore} setValue={titleSetter}></InputField> | ||
| 상품명을 입력해 주세요 ({titleStore.length}/{MAX_TITLE}) | ||
| <InputField value={titleStore} setValue={titleSetter} maxLength={MAX_TITLE}></InputField> | ||
| </div> | ||
| <div className={c.DetailContent}> | ||
| 상품 설명을 입력해 주세요 | ||
| 상품 설명을 입력해 주세요 ({descStore.length}/{MAX_DESC}) | ||
| <div className={s.ProductDesc}> | ||
| <MultilineInputfield onChange={handleDesc} value={descStore} /> | ||
| <div className={s.SelectPhotoContainer}> | ||
| <UploadFile onChange={handleImageUploaded} /> | ||
| {images.map((file, index) => ( | ||
| <SelectedPhoto key={index} file={file} onClick={() => removeUploadedImage(index)} /> | ||
| ))} | ||
| <MultilineInputfield onChange={handleDesc} value={descStore} maxLength={MAX_DESC} /> | ||
| <div className={s.PhotoLimit}> | ||
| <div className={s.SelectPhotoContainer}> | ||
| <UploadFile onChange={handleImageUploaded} /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 UploadFile 까보면 파일 input에 accept?인가? 그런 속성 있을건데 근데 얘도 우회할 수 있어서 위 같은 validation 로직을 유지하긴 해야돼요
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 굿 새롭게 알게 된 사실 |
||
| {images.map((file, index) => ( | ||
| <SelectedPhoto key={index} file={file} onClick={() => removeUploadedImage(index)} /> | ||
| ))} | ||
| </div> | ||
| <div className={s.AlertText}> | ||
| <span className="mgc_alert_octagon_fill"></span> | ||
| 사진은 최대 6장까지 등록이 가능해요. | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,8 @@ | ||
| export const MAX_PRICE = 999999; | ||
| export const MAX_LOCATION = 100; | ||
| export const MAX_TITLE = 64; | ||
| export const MAX_DESC = 1000; | ||
| export const ALLOWED_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp']; | ||
| export const MAX_SIZE_MB = 5; | ||
| export const MAX_SIZE_BYTES = MAX_SIZE_MB * 1024 * 1024; | ||
| export const MAX_FILE_LENGTH = 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인정 알럿창 필요함
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
알럿