-
Notifications
You must be signed in to change notification settings - Fork 2
feat : 편지작성, 랜덤편지 구현 90% 완료, 편지상세는 이후에 테스트 #67
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 12 commits
7e6ea74
20fca5f
ca17d65
45c3331
de81b51
de15a93
aa02f24
e6385d8
4cdad07
a78f3ee
bf7f2f5
2abdb8c
0f00424
d0a3845
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 |
|---|---|---|
| @@ -1,17 +1,70 @@ | ||
| import client from './client'; | ||
|
|
||
| const getRandomLetters = async ( | ||
| setRandomLettersState: React.Dispatch<React.SetStateAction<RandomLetters[]>>, | ||
| category: string | null, | ||
| ) => { | ||
| const getRandomLetters = async (category: string | null) => { | ||
| try { | ||
| const res = await client.get(`/api/random/${category}`); | ||
| const res = await client.get(`/api/random-letters/${category}`); | ||
| if (!res) throw new Error('랜덤 편지 데이터를 가져오는 도중 에러가 발생했습니다.'); | ||
| setRandomLettersState(res.data.data); | ||
| console.log(res); | ||
| return res; | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| export { getRandomLetters }; | ||
| const postRandomLettersApprove = async (approveRequest: ApproveRequest, callBack?: () => void) => { | ||
| try { | ||
| console.log('엔드포인트 : /api/random-letters/approve'); | ||
| console.log('request', approveRequest); | ||
| const res = await client.post('/api/random-letters/approve', approveRequest); | ||
| if (!res) throw new Error('랜덤편지 매칭수락 도중 에러가 발생했습니다.'); | ||
|
Collaborator
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.
이런 식으로요! |
||
| if (callBack) callBack(); | ||
| return res; | ||
| } catch (error) { | ||
| console.error(error); | ||
|
Collaborator
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 getRandomLetterMatched = async (callBack?: () => void) => { | ||
| try { | ||
| const res = await client.post('/api/random-letters/valid-table'); | ||
| if (!res) | ||
| throw new Error('랜덤 편지 최종 매칭 시간 검증 데이터를 가자오는 도중 에러가 발생했습니다.'); | ||
| if (callBack) callBack(); | ||
| console.log(res); | ||
| return res; | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| const getRandomLetterCoolTime = async (callBack?: () => void) => { | ||
| try { | ||
| const res = await client.post('/api/random-letters/valid'); | ||
| if (!res) | ||
| throw new Error('랜덤 편지 최종 매칭 시간 검증 데이터를 가자오는 도중 에러가 발생했습니다.'); | ||
| if (callBack) callBack(); | ||
| console.log(res); | ||
| return res; | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| const deleteRandomLetterMatching = async () => { | ||
| try { | ||
| const res = await client.delete('/api/random-letters/matching/cancel'); | ||
| if (!res) throw new Error('매칭 취소 도중 에러가 발생했습니다.'); | ||
| console.log(res); | ||
| return res; | ||
| } catch (error) { | ||
| console.log(error); | ||
| } | ||
| }; | ||
|
|
||
| export { | ||
| getRandomLetters, | ||
| postRandomLettersApprove, | ||
| getRandomLetterCoolTime, | ||
| getRandomLetterMatched, | ||
| deleteRandomLetterMatching, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,37 @@ | ||
| // import { AxiosResponse } from 'axios'; | ||
| import client from './client'; | ||
|
|
||
| const postLetter = async (data: LetterRequest, callBack?: () => void) => { | ||
| const postLetter = async (data: LetterRequest) => { | ||
| try { | ||
| const res = await client.post('/api/letters', data); | ||
| if (callBack) callBack(); | ||
| if (!res) throw new Error('편지 전송과정중에서 오류가 발생했습니다.'); | ||
| console.log(`api 주소 : /api/letters, 전송타입 : post`); | ||
| return res; | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| const postFirstReply = async (data: FirstReplyRequest) => { | ||
| try { | ||
| const res = await client.post('/api/random-letters/matching', data); | ||
| if (!res) throw new Error('최초 답장 전송과정중에서 오류가 발생했습니다.'); | ||
| console.log(`api 주소 : /api/random-letters/matching, 전송타입 : post`); | ||
| console.log(res); | ||
| return res; | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| const getPrevLetter = async ( | ||
| letterId: string, | ||
| setPrevLetterState: React.Dispatch<React.SetStateAction<PrevLetter[]>>, | ||
| callBack?: () => void, | ||
| ) => { | ||
| const getPrevLetter = async (letterId: string) => { | ||
| try { | ||
| const res = await client.get(`/api/letters/${letterId}/previous`); | ||
| setPrevLetterState(res.data.data); | ||
| if (callBack) callBack(); | ||
| console.log(res); | ||
| return res; | ||
| } catch (error) { | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
||
| export { postLetter, getPrevLetter }; | ||
| export { postLetter, postFirstReply, getPrevLetter }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
| import { Link } from 'react-router'; | ||
| import { Link, useNavigate } from 'react-router'; | ||
|
|
||
| import { AlarmIcon, ArrowLeftIcon, PersonIcon } from '@/assets/icons'; | ||
|
|
||
| const Header = () => { | ||
| // TODO: 뒤로 가기 버튼이 보이는 조건 추가 | ||
| // TODO: 스크롤 발생 시, 어떻게 보여져야 하는지 | ||
| const navigate = useNavigate(); | ||
| return ( | ||
| <header className="fixed top-0 z-40 flex h-16 w-full max-w-150 items-center justify-between p-5"> | ||
| <ArrowLeftIcon className="h-6 w-6 text-white" /> | ||
| <button onClick={() => navigate(-1)}> | ||
| <ArrowLeftIcon className="h-6 w-6 text-white" /> | ||
| </button> | ||
|
Collaborator
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. 저도 늘 까먹지만 |
||
| <div className="flex items-center gap-3"> | ||
| <Link to="/mypage/notifications"> | ||
| <AlarmIcon className="h-6 w-6 text-white" /> | ||
|
|
||
|
Collaborator
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 comment
The reason will be displayed to describe this comment to others. Learn more.
테스트용
console.log는 나중에 한 번에 삭제하거나 해야겠네용