-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from kimsayhi/Next-김세환-sprint10
[김세환] sprint10
- Loading branch information
Showing
37 changed files
with
902 additions
and
102 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"cSpell.words": ["sortmobile"] | ||
"cSpell.words": ["addboard", "addfile", "sortmobile"] | ||
} |
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 axios from "@/lib/axios"; | ||
|
||
interface Params<T> { | ||
data: T; | ||
token: string; | ||
} | ||
|
||
export const postNewArticle = async ({ data, token }: Params<object>) => { | ||
const res = await axios.post("/articles", data, { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}); | ||
}; | ||
|
||
export const postUploadImage = async ({ data, token }: Params<File>) => { | ||
const formData = new FormData(); | ||
formData.append("image", data); | ||
try { | ||
const res = await axios.post("/images/upload", formData, { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
return res.data; | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}; |
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,24 @@ | ||
import axios from "@/lib/axios"; | ||
|
||
interface PostArticleCommentParams { | ||
articleId: number; | ||
data: string; | ||
token: string; | ||
} | ||
|
||
export const postArticleComment = async ({ | ||
articleId, | ||
data, | ||
token, | ||
}: PostArticleCommentParams) => { | ||
try { | ||
const body = { | ||
content: data, | ||
}; | ||
const res = await axios.post(`/articles/${articleId}/comments`, body, { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}; |
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 axios from "@/lib/axios"; | ||
import { access } from "fs"; | ||
|
||
interface AuthData { | ||
email: string; | ||
password: string; | ||
} | ||
|
||
interface ResponseData { | ||
accessToken: string; | ||
refreshToken: string; | ||
} | ||
|
||
export const postSignIn = async (authData: AuthData) => { | ||
const res = await axios.post("/auth/signIn", authData); | ||
const { accessToken, refreshToken }: ResponseData = res.data; | ||
return { accessToken, refreshToken }; | ||
}; |
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,51 @@ | ||
import Button from "@/components/ui/Button"; | ||
import FileInput from "@/components/ui/FileInput"; | ||
import Input from "@/components/ui/Input"; | ||
import TextArea from "@/components/ui/TextArea"; | ||
import useAddBoard from "@/hooks/useAddBoard"; | ||
|
||
export default function AddBoardForm() { | ||
const { | ||
inputValues, | ||
onChangeInput, | ||
onSubmitForm, | ||
onChangeFileInput, | ||
isInputValid, | ||
} = useAddBoard(); | ||
return ( | ||
<form className="m-container mt-[70px] pt-4"> | ||
<div className="flex justify-between"> | ||
<span className="font-bold text-xl">게시글 쓰기</span> | ||
<Button | ||
className="btn w-[74px] h-[42px]" | ||
onClick={onSubmitForm} | ||
activeBtn={isInputValid} | ||
> | ||
등록 | ||
</Button> | ||
</div> | ||
<Input | ||
name="title" | ||
placeholder="제목을 입력해주세요" | ||
type="input" | ||
label="*제목" | ||
value={inputValues.title} | ||
onChange={onChangeInput} | ||
/> | ||
<TextArea | ||
name="content" | ||
placeholder="내용을 입력해 주세요" | ||
label="*내용" | ||
value={inputValues.content} | ||
onChange={onChangeInput} | ||
/> | ||
<FileInput | ||
value="" | ||
onChange={onChangeFileInput} | ||
name="image" | ||
label="이미지" | ||
image={inputValues.image} | ||
/> | ||
</form> | ||
); | ||
} |
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
Oops, something went wrong.