-
Notifications
You must be signed in to change notification settings - Fork 3
Hofix/index page : 파일샘플 컴포넌트 수정 #88
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 5 commits
c912369
4673821
ad892a2
23473ec
477eaf3
cf1a241
daf1c9d
0704cc0
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import ImgCrewSample01 from './crew-sample-1.jpg'; | ||
| import ImgCrewSample02 from './crew-sample-2.jpg'; | ||
| import ImgCrewSample03 from './crew-sample-3.jpg'; | ||
|
|
||
| const ImgCrewSamples = [ | ||
| ImgCrewSample01, | ||
| ImgCrewSample02, | ||
| ImgCrewSample03, | ||
| ]; | ||
|
|
||
| export default ImgCrewSamples; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import ImgGatheringSample01 from './gathering-sample-1.jpg'; | ||
| import ImgGatheringSample02 from './gathering-sample-2.jpg'; | ||
| import ImgGatheringSample03 from './gathering-sample-3.jpg'; | ||
|
|
||
| const ImgGatheringSamples = [ | ||
| ImgGatheringSample01, | ||
| ImgGatheringSample02, | ||
| ImgGatheringSample03, | ||
| ]; | ||
|
|
||
| export default ImgGatheringSamples; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { fetchApi } from '@/src/utils/api'; | ||
| import { CrewCardInform, CrewCardInformResponse } from '@/src/types/crew-card'; | ||
|
|
||
| export async function getCrewList(page: number, limit: number): Promise<CrewCardInformResponse> { | ||
| try { | ||
| const response = await fetchApi<CrewCardInformResponse>( | ||
| `/crews?_page=${page + 1}&_limit=${limit}`, | ||
| { | ||
| method: 'GET', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }, | ||
| ); | ||
| if (!Array.isArray(response)) { | ||
| throw new Error('서버 응답이 올바른 형식이 아닙니다.'); | ||
| } | ||
| const data = response as CrewCardInform[]; | ||
| const hasNextPage = data.length === limit; | ||
|
|
||
| return { data, hasNextPage }; | ||
| } catch (error) { | ||
| throw new Error('크루 리스트를 불러오는데 실패했습니다.'); | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,20 +1,22 @@ | ||||||||||||||||||||||||
| 'use client'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||||
| import { StaticImageData } from 'next/image'; | ||||||||||||||||||||||||
| import FileInput from './file-input'; | ||||||||||||||||||||||||
| import FileSample from './file-sample'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export interface FileInputProps { | ||||||||||||||||||||||||
| value: File | null; | ||||||||||||||||||||||||
| onChange: (newValue: File | null) => void; | ||||||||||||||||||||||||
| sample: StaticImageData[]; | ||||||||||||||||||||||||
| onChange: (newValue: File | StaticImageData | null) => void; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export default function FileInputWrap({ value, onChange }: FileInputProps) { | ||||||||||||||||||||||||
| const [fileValue, setFileValue] = useState<File | null>(value); | ||||||||||||||||||||||||
| export default function FileInputWrap({ value, sample, onChange }: FileInputProps) { | ||||||||||||||||||||||||
| const [fileValue, setFileValue] = useState<File | StaticImageData | null>(value); | ||||||||||||||||||||||||
| const [isOtherSelected, setIsOtherSelected] = useState(false); | ||||||||||||||||||||||||
| const [isSampleSelected, setIsSampleSelected] = useState(false); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const handleChange = (inputValue: File | null) => { | ||||||||||||||||||||||||
| const handleChange = (inputValue: StaticImageData) => { | ||||||||||||||||||||||||
| setIsOtherSelected(false); | ||||||||||||||||||||||||
| setIsSampleSelected(true); | ||||||||||||||||||||||||
| setFileValue(inputValue); | ||||||||||||||||||||||||
|
|
@@ -30,21 +32,9 @@ export default function FileInputWrap({ value, onChange }: FileInputProps) { | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||
| <div className="container flex max-w-[1200px] gap-4"> | ||||||||||||||||||||||||
| <FileSample | ||||||||||||||||||||||||
| imgUrl="https://images.stockcake.com/public/a/7/6/a768d87b-1f99-4b50-9286-f1583af33522_large/team-huddle-celebration-stockcake.jpg" | ||||||||||||||||||||||||
| onChange={handleChange} | ||||||||||||||||||||||||
| isBlur={isOtherSelected} | ||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||
| <FileSample | ||||||||||||||||||||||||
| imgUrl="https://images.stockcake.com/public/a/a/0/aa0e5e46-987b-43ab-9e14-0012148d4d47_large/joyful-sports-gathering-stockcake.jpg" | ||||||||||||||||||||||||
| onChange={handleChange} | ||||||||||||||||||||||||
| isBlur={isOtherSelected} | ||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||
| <FileSample | ||||||||||||||||||||||||
| imgUrl="https://images.stockcake.com/public/2/4/0/240c891a-9e35-4490-8714-a1c135b0c645_large/team-celebration-time-stockcake.jpg" | ||||||||||||||||||||||||
| onChange={handleChange} | ||||||||||||||||||||||||
| isBlur={isOtherSelected} | ||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||
| <FileSample image={sample[0]} onChange={handleChange} isBlur={isOtherSelected} /> | ||||||||||||||||||||||||
| <FileSample image={sample[1]} onChange={handleChange} isBlur={isOtherSelected} /> | ||||||||||||||||||||||||
| <FileSample image={sample[2]} onChange={handleChange} isBlur={isOtherSelected} /> | ||||||||||||||||||||||||
|
Comment on lines
+35
to
+37
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. 배열 접근에 대한 안전성 검증이 필요합니다. 현재 구현은 다음과 같이 안전한 배열 접근을 구현하는 것을 추천드립니다: - <FileSample image={sample[0]} onChange={handleChange} isBlur={isOtherSelected} />
- <FileSample image={sample[1]} onChange={handleChange} isBlur={isOtherSelected} />
- <FileSample image={sample[2]} onChange={handleChange} isBlur={isOtherSelected} />
+ {sample.map((image, index) => (
+ <FileSample
+ key={index}
+ image={image}
+ onChange={handleChange}
+ isBlur={isOtherSelected}
+ />
+ ))}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||
| <FileInput value={fileValue} onChange={handleFileInput} isBlur={isSampleSelected} /> | ||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ export interface CreateGatheringRequestType { | |
| dateTime: string; | ||
| location: string; | ||
| totalCount: number; | ||
| imageUrl: File | null; // NOTE : 임시로 File로 설정 | ||
| imageUrl: File | StaticImageData | null; // NOTE : 임시로 File로 설정 | ||
|
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. 🛠️ Refactor suggestion StaticImageData 타입을 가져오도록 수정이 필요합니다. StaticImageData 타입을 사용하기 위해서는 next/image에서 해당 타입을 가져와야 합니다. 다음과 같이 수정해주세요: +import { StaticImageData } from 'next/image';
|
||
| } | ||
|
|
||
| export interface GatheringCardProps { | ||
|
|
||
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.
타입 불일치 문제가 있습니다!
valueprop이StaticImageData를 받을 수 있지만,onChange콜백은StaticImageData를 처리할 수 없습니다. 이는 런타임 오류를 발생시킬 수 있습니다.다음과 같이 수정하는 것을 제안합니다:
export interface FileInputProps { - value: File | StaticImageData | null; - onChange: (value: File | null) => void; + value: File | StaticImageData | null; + onChange: (value: File | StaticImageData | null) => void; isBlur: boolean; }📝 Committable suggestion