-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[ CreateNote ] 레큐노트 생성 api 붙이기
- Loading branch information
Showing
13 changed files
with
467 additions
and
251 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { api } from '../../libs/api'; | ||
|
||
const getPresignedUrl = async () => { | ||
const { data } = await api.get('/api/images/note'); | ||
return data; | ||
}; | ||
|
||
export default getPresignedUrl; |
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,38 @@ | ||
// import { useNavigate } from 'react-router-dom'; | ||
|
||
import { api } from '../../libs/api'; | ||
import { postLecueNoteProps } from '../type/lecueNoteType'; | ||
|
||
const postLecueNote = ({ | ||
contents, | ||
color, | ||
fileName, | ||
bgColor, | ||
}: postLecueNoteProps) => { | ||
// const navigate = useNavigate(); | ||
|
||
const response = api | ||
.post( | ||
'/api/notes', | ||
{ | ||
bookId: 1, | ||
content: contents, | ||
textColor: color, | ||
background: fileName ? fileName : bgColor, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${import.meta.env.VITE_APP_TOKEN}`, | ||
}, | ||
}, | ||
) | ||
.then((res) => { | ||
console.log(res); | ||
// 나중에 주석코드를 활성화시킬 예정! | ||
// navigate(`lecue-book/${res.data.data.bookUuid}`); | ||
}); | ||
|
||
return response; | ||
}; | ||
|
||
export default postLecueNote; |
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,18 @@ | ||
import { api } from '../../libs/api'; | ||
import { putPresignedUrlProps } from '../type/lecueNoteType'; | ||
|
||
const putPresignedUrl = ({ | ||
presignedUrl, | ||
binaryFile, | ||
fileType, | ||
}: putPresignedUrlProps) => { | ||
const response = api.put(presignedUrl, binaryFile, { | ||
headers: { | ||
'Content-Type': fileType, | ||
}, | ||
}); | ||
|
||
return response; | ||
}; | ||
|
||
export default putPresignedUrl; |
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
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,14 @@ | ||
import { useQuery } from 'react-query'; | ||
|
||
import getPresignedUrl from '../api/getPresignedUrl'; | ||
|
||
const useGetPresignedUrl = () => { | ||
const { isLoading, error, data } = useQuery({ | ||
queryKey: ['get-presigned-url'], | ||
queryFn: () => getPresignedUrl(), | ||
}); | ||
|
||
return { isLoading, error, data }; | ||
}; | ||
|
||
export default useGetPresignedUrl; |
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,22 @@ | ||
import { AxiosError } from 'axios'; | ||
import { useMutation } from 'react-query'; | ||
|
||
import postLecueNote from '../api/postLecueNote'; | ||
import { postLecueNoteProps } from '../type/lecueNoteType'; | ||
|
||
const usePostLecueNote = () => { | ||
const mutation = useMutation({ | ||
mutationFn: ({ | ||
contents, | ||
color, | ||
fileName, | ||
bgColor, | ||
}: postLecueNoteProps) => { | ||
return postLecueNote({ contents, color, fileName, bgColor }); | ||
}, | ||
onError: (err: AxiosError) => console.log(err), | ||
}); | ||
return mutation; | ||
}; | ||
|
||
export default usePostLecueNote; |
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,21 @@ | ||
import { AxiosError } from 'axios'; | ||
import { useMutation } from 'react-query'; | ||
|
||
import putPresignedUrl from '../api/putPresignedUrl'; | ||
import { putPresignedUrlProps } from './../type/lecueNoteType'; | ||
|
||
const usePutPresignedUrl = () => { | ||
const mutation = useMutation({ | ||
mutationFn: ({ | ||
presignedUrl, | ||
binaryFile, | ||
fileType, | ||
}: putPresignedUrlProps) => { | ||
return putPresignedUrl({ presignedUrl, binaryFile, fileType }); | ||
}, | ||
onError: (err: AxiosError) => console.log(err), | ||
}); | ||
return mutation; | ||
}; | ||
|
||
export default usePutPresignedUrl; |
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.