-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'Soongcharo-FE/dev'
- Loading branch information
Showing
22 changed files
with
329 additions
and
34 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import axios from 'axios'; | ||
|
||
const client = axios.create({ | ||
baseURL: 'http://13.124.148.165:8080/', | ||
}); | ||
|
||
export default client; |
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 client from './client'; | ||
|
||
const postFile = async (blob: Blob) => { | ||
const formData = new FormData(); | ||
|
||
formData.append('file', blob, blob.name); | ||
formData.append('type', blob.type); | ||
|
||
// for (const item of formData.values()) { | ||
// console.log(item); | ||
// } | ||
|
||
const response = await client.post('/test/file', formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
}); | ||
|
||
return response.data.filePath; | ||
}; | ||
|
||
export default postFile; |
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,30 @@ | ||
import { PostQuestionWriteResponse, QuestionWriteRequest } from '@/types/questionWrite.type'; | ||
import client from './client'; | ||
|
||
const postQuestionWrite = async ({ | ||
title, | ||
content, | ||
fileIds, | ||
field, | ||
tag, | ||
}: QuestionWriteRequest): Promise<PostQuestionWriteResponse> => { | ||
const response = await client.post( | ||
'/user/question', | ||
{ | ||
title, | ||
content, | ||
fileIds, | ||
field, | ||
tag, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: | ||
'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJha211QGdtYWlsLmNvbSIsInJvbGVzIjpbIlJPTEVfVVNFUiJdLCJpYXQiOjE2OTU2MjY5NzAsImV4cCI6MTY5NTcxMzM3MH0.Qp-tus5vuO7r1wTsIQJAp_T80zQePo96y_LLH7w89OU', | ||
}, | ||
}, | ||
); | ||
return response.data; | ||
}; | ||
|
||
export default postQuestionWrite; |
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,8 @@ | ||
import '@toast-ui/editor/dist/toastui-editor.css'; | ||
import { Viewer } from '@toast-ui/react-editor'; | ||
|
||
const MarkdownViewer = () => { | ||
return <Viewer initialValue="#hello react editor world!" el="dkdkd" />; | ||
}; | ||
|
||
export default MarkdownViewer; |
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,20 @@ | ||
import postQuestionWrite from '@/apis/postQuestionWrite'; | ||
import { AxiosError } from 'axios'; | ||
import { useRouter } from 'next/router'; | ||
import { useMutation } from 'react-query'; | ||
|
||
const usePostQuestionWrite = () => { | ||
const router = useRouter(); | ||
return useMutation(postQuestionWrite, { | ||
onSuccess: () => { | ||
router.push('/'); | ||
}, | ||
onError: (error) => { | ||
const Error = error as AxiosError; | ||
|
||
console.log(Error); | ||
}, | ||
}); | ||
}; | ||
|
||
export default usePostQuestionWrite; |
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,40 @@ | ||
import { FieldType, QuestionWriteRequest } from '@/types/questionWrite.type'; | ||
import { RefObject, useState } from 'react'; | ||
import { Editor } from '@toast-ui/react-editor'; | ||
|
||
const useQuestionWrite = () => { | ||
const [writeForm, setWriteForm] = useState<QuestionWriteRequest>({ | ||
title: '', | ||
content: '', | ||
field: [], | ||
fileIds: [], | ||
tag: [], | ||
}); | ||
|
||
const handleTitle = (value: string) => { | ||
setWriteForm({ ...writeForm, title: value }); | ||
}; | ||
|
||
const handleContent = (editorRef: RefObject<Editor>) => { | ||
const data = editorRef?.current?.getInstance().getMarkdown(); | ||
setWriteForm({ ...writeForm, content: data as string }); | ||
}; | ||
|
||
const handleField = (value: FieldType[]) => { | ||
setWriteForm({ ...writeForm, field: [...value] }); | ||
}; | ||
|
||
const handleTag = (value: string[]) => { | ||
setWriteForm({ ...writeForm, tag: value }); | ||
}; | ||
|
||
return { | ||
writeForm, | ||
handleTitle, | ||
handleContent, | ||
handleField, | ||
handleTag, | ||
}; | ||
}; | ||
|
||
export default useQuestionWrite; |
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.