-
Notifications
You must be signed in to change notification settings - Fork 4
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
[1.5차 QA] 선물 등록 완료 버튼 관련 버그 수정(기본 이미지 문제, 로딩 뷰 처리) #393
Changes from all commits
8c9dac4
adbd6bd
d24965c
a5ef882
a3514f1
4152d15
0408000
d103556
936faa6
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ const initialAddGiftInfo: AddGiftInfo = { | |
name: '', | ||
cost: 0, | ||
imageUrl: '', | ||
url: ',', | ||
url: '', | ||
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. 앗! 여기있었군요 ㅋㅋㅋㅋ쉼표 고친 것 너무 좋습니다! 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. ㅋㅋㅋ숨겨져 있던 오타 드디어 해결~! |
||
}; | ||
|
||
const AddGiftContext = createContext<AddGiftInfoContext>({ | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,6 @@ | ||||||||||||||||||||||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||||||||||||||||||||||
import { post } from '../../../apis/client'; | ||||||||||||||||||||||
import { GiftPostRequestType } from '../../../types/gift'; | ||||||||||||||||||||||
import { AddGiftInfo, GiftPostRequestType } from '../../../types/gift'; | ||||||||||||||||||||||
import { useNavigate } from 'react-router-dom'; | ||||||||||||||||||||||
import { MY_GIFT_QUERY_KEY } from './useGetMyGift'; | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
@@ -12,6 +12,8 @@ export const usePostGift = ( | |||||||||||||||||||||
roomId: number, | ||||||||||||||||||||||
targetDate: string, | ||||||||||||||||||||||
setStep: React.Dispatch<React.SetStateAction<number>>, | ||||||||||||||||||||||
updateAddGiftInfo: (newInfo: Partial<AddGiftInfo>) => void, | ||||||||||||||||||||||
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. 추후에는 props로 받는 방법 이외에,
Suggested change
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. 피드백 감사합니다~! 큐에이 하면서도 저 부분 때문에 귀찮아지더라고요ㅠ 그래서 giftee name 관련 context를 추가할 때는 제안해주신 방식과 같은 방식으로 직접 불러오는 방식으로 구현했습니다. 이 부분은 나중에 싹 리팩토링 하겠습니다~! |
||||||||||||||||||||||
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>, | ||||||||||||||||||||||
) => { | ||||||||||||||||||||||
const navigate = useNavigate(); | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
@@ -24,6 +26,8 @@ export const usePostGift = ( | |||||||||||||||||||||
queryClient.invalidateQueries({ queryKey: [MY_GIFT_QUERY_KEY[0], roomId] }); | ||||||||||||||||||||||
navigate(`/add-gift/${roomId}/${targetDate}`); | ||||||||||||||||||||||
setStep(0); | ||||||||||||||||||||||
setIsLoading(false); | ||||||||||||||||||||||
updateAddGiftInfo({ name: '', cost: 0, imageUrl: '', url: '' }); | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
onError: (error) => { | ||||||||||||||||||||||
console.log('선물 등록 에러!!', error.message); | ||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
const useConvertURLtoFile = async (url: string) => { | ||
const response = await fetch(url); | ||
const data = await response.blob(); | ||
const ext = url.split('.').pop(); // url 구조에 맞게 수정할 것 | ||
const filename = url.split('/').pop(); // url 구조에 맞게 수정할 것 | ||
const metadata = { type: `image/${ext}` }; | ||
return new File([data], filename!, metadata); | ||
import { AddGiftInfo } from '../types/gift'; | ||
|
||
interface convertURLtoFileProps { | ||
url: string; | ||
setStep: React.Dispatch<React.SetStateAction<number>>; | ||
setModalStatus: React.Dispatch<React.SetStateAction<boolean>>; | ||
updateAddGiftInfo: (newInfo: Partial<AddGiftInfo>) => void; | ||
} | ||
|
||
const useConvertURLtoFile = async ({ | ||
url, | ||
setStep, | ||
setModalStatus, | ||
updateAddGiftInfo, | ||
}: convertURLtoFileProps) => { | ||
console.log('들어오고 있는 url', url); | ||
try { | ||
const response = await fetch(url); | ||
|
||
if (response.status === 302) { | ||
return setStep(3); | ||
} | ||
|
||
const data = await response.blob(); | ||
// const extensions = url.split('.').pop(); | ||
const filename = url.split('/').pop(); | ||
const metadata = { type: `image/*` }; | ||
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. 여기서는 위에 예외처리 해준 이미지 파일들처럼 지정안해줘도 되나요~?! 왜 위에 except 제가 리뷰남긴 부분은 이미지 타입을 4가지로 지정한 이유는 에러 발생하지 않는 유형이겠죠?! 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. 두 가지 이유 때문에 이 부분은 따로 변경하지 않았습니다!
|
||
const convertedOgFile = new File([data], filename!, metadata); | ||
return { convertedOgFile }; | ||
} catch (error) { | ||
console.error('error?', error); | ||
updateAddGiftInfo({ imageUrl: '' }); | ||
setModalStatus(true); | ||
setStep(3); | ||
return { convertedOgFile: null }; | ||
} | ||
}; | ||
|
||
export default useConvertURLtoFile; |
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.
accept가 다양해졌네요..! 이미지에 heic도 있군요.!
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.
오 저도 이렇게 heic도 추가하겠습니다 !! 감사합니다
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.
넵 폰 이미지 때문에 추가했어요!