-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: 이미지 첨부 기능 구현 및 리스트 생성 제출 API 연동 (#17)
* Chore: 불필요 코드 및 파일 삭제, 타입 수정 * Refactor: 프리뷰 컴포넌트 image, link 용도별 타입 분리 및 수정 * Feat: 이미지 업로드 버튼에 파일첨부 기능 추가 * Feat: 헤더 완료버튼에 submit 함수 연결 및 데이터 api별 분리 * Fix: 프리뷰 이미지 초기 렌더링시 src 없음 오류 해결 * feat: 이미지 업로드 api 연동 * Fix: Merge 충돌 해결 * Fix: 중복 파일 삭제 * Chore: 주석 및 불필요코드 삭제 * Feat: 리액트 쿼리 사용하여 리스트 생성 전 과정 실행 기능 추가 * Fix: 프리뷰에 링크 도메인 노출 오류로 기능 제거 * Refactor: 헤더 다음 버튼 비활성화 기능 추가 및 카테고리 기본값 설정 변경 * Feat: 헤더 컴포넌트화 (유진님의 리스트 헤더 가져오기) * HOTFIX: 빌드 오류 해결 위한 미사용 코드 제거 * Fix: useEffect 디펜던시 리스트 수정
- Loading branch information
1 parent
c3b990f
commit 88ced21
Showing
21 changed files
with
741 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import axiosInstance from '@/lib/axios/axiosInstance'; | ||
import { ListCreateType } from '@/lib/types/listType'; | ||
import { ListCreateType, ListIdType } from '@/lib/types/listType'; | ||
|
||
export const createList = async (data: ListCreateType) => { | ||
const response = await axiosInstance.post<ListCreateType>('/lists', data); | ||
const response = await axiosInstance.post<ListIdType>('/lists', data); | ||
|
||
return response.data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import axiosInstance from '@/lib/axios/axiosInstance'; | ||
import { ItemImagesType, PresignedUrlListType } from '@/lib/types/listType'; | ||
import axios from 'axios'; | ||
|
||
interface uploadItemImagesProps { | ||
listId: number; | ||
imageData: ItemImagesType; | ||
imageFileList: File[]; | ||
} | ||
|
||
export const uploadItemImages = async ({ listId, imageData, imageFileList }: uploadItemImagesProps) => { | ||
imageData.listId = listId; | ||
|
||
//PresignedUrl 생성 요청 | ||
const response = await axiosInstance.post<PresignedUrlListType>('/lists/upload-url', imageData); | ||
|
||
//PresignedUrl에 이미지 업로드 | ||
for (let i = 0; i < response.data.length; i++) { | ||
const result = await axios.put(response.data[i].presignedUrl, imageFileList[i], { | ||
headers: { | ||
'Content-Type': imageFileList[i]?.type, | ||
}, | ||
}); | ||
if (result.status !== 200) return; | ||
} | ||
|
||
//서버에 성공 완료 알림 | ||
if (imageFileList.length !== 0) { | ||
await axiosInstance.post('/lists/upload-complete', imageData); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const header = style({ | ||
width: '100%', | ||
height: '90px', | ||
paddingLeft: '20px', | ||
paddingRight: '20px', | ||
|
||
position: 'sticky', | ||
top: '0', | ||
left: '0', | ||
zIndex: '10', | ||
|
||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
|
||
backgroundColor: '#fff', | ||
|
||
borderBottom: '1px solid rgba(0, 0, 0, 0.10)', | ||
}); | ||
|
||
export const headerTitle = style({ | ||
fontSize: '2rem', | ||
}); | ||
|
||
export const headerNextButton = style({ | ||
fontSize: '1.6rem', | ||
color: '#AFB1B6', | ||
cursor: 'default', | ||
}); | ||
|
||
export const headerNextButtonActive = style({ | ||
fontSize: '1.6rem', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import BackIcon from '/public/icons/back.svg'; | ||
import * as styles from './Header.css'; | ||
|
||
interface HeaderProps { | ||
onBackClick: () => void; | ||
isSubmitActive: boolean; | ||
onSubmitClick: () => void; | ||
} | ||
|
||
function Header({ onBackClick, isSubmitActive, onSubmitClick }: HeaderProps) { | ||
return ( | ||
<div className={styles.header}> | ||
<button onClick={onBackClick}> | ||
<BackIcon alt="뒤로가기 버튼" /> | ||
</button> | ||
<h1 className={styles.headerTitle}>리스트 생성</h1> | ||
<button | ||
className={isSubmitActive ? styles.headerNextButtonActive : styles.headerNextButton} | ||
disabled={!isSubmitActive} | ||
onClick={onSubmitClick} | ||
> | ||
완료 | ||
</button> | ||
</div> | ||
); | ||
} | ||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const label = style({ | ||
cursor: 'pointer', | ||
}); | ||
|
||
export const input = style({ | ||
display: 'none', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ReactNode } from 'react'; | ||
import ImageIcon from '/public/icons/attach_image.svg'; | ||
import * as styles from './ImageUploader.css'; | ||
|
||
interface ImageUploaderProps { | ||
index: number; | ||
children: ReactNode; | ||
} | ||
|
||
export default function ImageUploader({ index, children }: ImageUploaderProps) { | ||
return ( | ||
<> | ||
<label className={styles.label} htmlFor={`${index}-image`}> | ||
<ImageIcon /> | ||
</label> | ||
{children} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.