From 9ff261764c24a3a70973101c85e607e32e83503f Mon Sep 17 00:00:00 2001 From: seocylucky Date: Sat, 5 Aug 2023 07:24:21 +0900 Subject: [PATCH 01/21] =?UTF-8?q?[#18]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/signin.tsx | 77 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/pages/signin.tsx b/pages/signin.tsx index 8033495..dbe8f26 100644 --- a/pages/signin.tsx +++ b/pages/signin.tsx @@ -1,7 +1,82 @@ import type { NextPage } from 'next'; +import { styled } from 'styled-components'; +import Spacing from '../components/reusable/Spacing'; +import theme from '../styles/theme'; +import TextInput from '../components/reusable/TextInput'; +import SquareBtn from '../components/reusable/Buttons/SquareBtn'; +import Link from 'next/link'; +import { useState } from 'react'; const Signin: NextPage = () => { - return

Signin Page

; + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + + return ( + + + 로그인 + + 숭차로에서 다양한 지식과 답변을 공유해보세요. + + 이메일 + + + + 비밀번호 + + + + + + + 비밀번호 찾기 + | + 회원가입 + + + + ); }; export default Signin; + +const Container = styled.div` + width: 640px; + margin: 0 auto; +`; + +const SigninTitle = styled.div` + color: var(--black, #1d1d1d); + font-size: 48px; + font-style: normal; + font-weight: 600; + line-height: normal; +`; + +const SigninText = styled.div` + font-size: ${theme.fontStyles.Text_M.fontSize}px; + font-weight: ${theme.fontStyles.Text_M.fontWeight}; + color: ${theme.colors.gray3}; +`; + +const SubText = styled.div` + font-size: ${theme.fontStyles.Text_L.fontSize}px; + font-weight: ${theme.fontStyles.Text_L.fontWeight}; + color: ${theme.colors.black}; +`; + +const BtnContainer = styled.div` + display: flex; + flex-direction: row; + justify-content: space-between; +`; +const FindFlex = styled.div` + display: flex; + flex-direction: row; + gap: 24px; + align-items: center; + + color: ${theme.colors.gray2}; + font-size: ${theme.fontStyles.Text_M.fontSize}px; + font-weight: ${theme.fontStyles.Text_M.fontWeight}; +`; From 4d8ac20b678570b3ee4a31e3dfe80331f48353ab Mon Sep 17 00:00:00 2001 From: intersoom Date: Fri, 29 Sep 2023 21:13:23 +0900 Subject: [PATCH 02/21] rename: questionWrite.type -> question.type --- types/question.type.ts | 35 +++++++++++++++++++++++++++++++++++ types/questionWrite.type.ts | 15 --------------- 2 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 types/question.type.ts delete mode 100644 types/questionWrite.type.ts diff --git a/types/question.type.ts b/types/question.type.ts new file mode 100644 index 0000000..b855493 --- /dev/null +++ b/types/question.type.ts @@ -0,0 +1,35 @@ +export interface QuestionWriteRequest { + title: string; + content: string; + fileIds: number[]; + field: FieldType[]; + tag: string[]; +} + +export type FieldType = 'BACKEND' | 'DESIGN' | 'FRONTEND' | 'MOBILE' | 'PRODUCT_MANAGER' | 'SCHOOL'; + +export interface PostQuestionWriteResponse { + body: object; + statusCode: string; + statusCodeValue: number; +} + +export interface AnswerType { + id: number; + content: string; + postTime: string; + memberId: number; + likes: number; +} + +export interface GetQuestionResponse { + title: string; + content: string; + field: FieldType[]; + tag: string[]; + memberId: number; + hits: number; + likes: number; + answerList: AnswerType[]; + imageUrls: string[]; +} diff --git a/types/questionWrite.type.ts b/types/questionWrite.type.ts deleted file mode 100644 index 7cf1c7f..0000000 --- a/types/questionWrite.type.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface QuestionWriteRequest { - title: string; - content: string; - fileIds: number[]; - field: FieldType[]; - tag: string[]; -} - -export type FieldType = 'BACKEND' | 'DESIGN' | 'FRONTEND' | 'MOBILE' | 'PRODUCT_MANAGER'; - -export interface PostQuestionWriteResponse { - body: object; - statusCode: string; - statusCodeValue: number; -} From 1071b2d8c1fad75d88dfbf5ea5ecdcb5848ed17e Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:10:08 +0900 Subject: [PATCH 03/21] =?UTF-8?q?feat:=20getQuestion=20api=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=ED=95=A8=EC=88=98=20=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/getQuestion.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 apis/getQuestion.ts diff --git a/apis/getQuestion.ts b/apis/getQuestion.ts new file mode 100644 index 0000000..fc51d10 --- /dev/null +++ b/apis/getQuestion.ts @@ -0,0 +1,9 @@ +import { GetQuestionResponse } from '@/types/question.type'; +import client from './client'; + +const getQuestion = async (id: number): Promise => { + const response = await client.get(`/user/question/${id}`); + return response.data; +}; + +export default getQuestion; From aa74e6c63e82b8a4ad12a6852bde3cb9d5501786 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:10:33 +0900 Subject: [PATCH 04/21] =?UTF-8?q?feat:=20postAnswer=20api=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=ED=95=A8=EC=88=98=20=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/postAnswer.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 apis/postAnswer.ts diff --git a/apis/postAnswer.ts b/apis/postAnswer.ts new file mode 100644 index 0000000..0d516da --- /dev/null +++ b/apis/postAnswer.ts @@ -0,0 +1,26 @@ +import { AnswerWriteRequest, PostAnswerWriteResponse } from '@/types/answer.type'; +import client from './client'; + +const postAnswer = async ({ + questionId, + fileIds, + content, +}: AnswerWriteRequest): Promise => { + const response = await client.post( + '/user/answer', + { + questionId, + fileIds, + content, + }, + { + headers: { + Authorization: + 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJha211QGdtYWlsLmNvbSIsInJvbGVzIjpbXSwiaWF0IjoxNjk1OTgyNTI1LCJleHAiOjE2OTYwNjg5MjV9.N5UWZD4xvULjHk7EaKblTM7kJwEdZrQ3cfII1jZMuAE', + }, + }, + ); + return response.data; +}; + +export default postAnswer; From ea995bbfc6482c6ea32c7df74b19310c02bc18b4 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:12:07 +0900 Subject: [PATCH 05/21] =?UTF-8?q?refactor:=20initialValue=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/reusable/MarkDown/MarkdownEditor.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/reusable/MarkDown/MarkdownEditor.tsx b/components/reusable/MarkDown/MarkdownEditor.tsx index bed1967..f607bab 100644 --- a/components/reusable/MarkDown/MarkdownEditor.tsx +++ b/components/reusable/MarkDown/MarkdownEditor.tsx @@ -21,7 +21,7 @@ const MarkdownEditor = ({ onChange }: MarkdownEditorProps) => { onChange(editorRef)} - // initialValue="hello react editor world!" + initialValue="" previewStyle="tab" height="600px" initialEditType="markdown" From cee9b3cfef973886b4687110c4b83220cd7f0609 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:12:32 +0900 Subject: [PATCH 06/21] =?UTF-8?q?feat:=20MarkDownViewer=20=EC=A0=9C?= =?UTF-8?q?=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/reusable/MarkDown/MarkdownViewer.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/reusable/MarkDown/MarkdownViewer.tsx b/components/reusable/MarkDown/MarkdownViewer.tsx index 70beb36..d9bfc40 100644 --- a/components/reusable/MarkDown/MarkdownViewer.tsx +++ b/components/reusable/MarkDown/MarkdownViewer.tsx @@ -1,8 +1,12 @@ import '@toast-ui/editor/dist/toastui-editor.css'; import { Viewer } from '@toast-ui/react-editor'; -const MarkdownViewer = () => { - return ; +interface MarkdownViewerProps { + content?: string; +} + +const MarkdownViewer = ({ content }: MarkdownViewerProps) => { + return ; }; export default MarkdownViewer; From bc73eaf84c892d055c4f723f60d5bf09d6c2f9f1 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:14:32 +0900 Subject: [PATCH 07/21] =?UTF-8?q?feat:=20useGetQuestionRead=20=ED=9B=85=20?= =?UTF-8?q?=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/useGetQuestionRead.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 hooks/useGetQuestionRead.ts diff --git a/hooks/useGetQuestionRead.ts b/hooks/useGetQuestionRead.ts new file mode 100644 index 0000000..a991a78 --- /dev/null +++ b/hooks/useGetQuestionRead.ts @@ -0,0 +1,9 @@ +import getQuestion from '@/apis/getQuestion'; +import { GetQuestionResponse } from '@/types/question.type'; +import { useQuery } from 'react-query'; + +const useGetQuestionRead = (id: number) => { + return useQuery(['getQuestion', id], () => getQuestion(id)); +}; + +export default useGetQuestionRead; From 51baaf38b0e1c6817c8b9a6241ec2e42962f16e6 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:23:15 +0900 Subject: [PATCH 08/21] =?UTF-8?q?feat:=20usePostAnswer=20=ED=9B=85=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hooks/usePostAnswer.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 hooks/usePostAnswer.ts diff --git a/hooks/usePostAnswer.ts b/hooks/usePostAnswer.ts new file mode 100644 index 0000000..c34ed08 --- /dev/null +++ b/hooks/usePostAnswer.ts @@ -0,0 +1,22 @@ +import postAnswer from '@/apis/postAnswer'; +import { queryClient } from '@/pages/_app'; +import { AxiosError } from 'axios'; +import { useRouter } from 'next/router'; +import { useMutation } from 'react-query'; + +const usePostAnswer = (pId: number) => { + const router = useRouter(); + return useMutation(postAnswer, { + onSuccess: () => { + queryClient.invalidateQueries(['getQuestion']); + router.push(`/questionRead/${pId}`); + }, + onError: (error) => { + const Error = error as AxiosError; + + console.log(Error); + }, + }); +}; + +export default usePostAnswer; From f5751499ad3dcbc8f6c88e8d08fd083b962dc4a2 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:23:54 +0900 Subject: [PATCH 09/21] =?UTF-8?q?rename:=20questio.type=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EB=AA=85=20=EC=88=98=EC=A0=95=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/postQuestionWrite.ts | 4 ++-- hooks/useQuestionWrite.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apis/postQuestionWrite.ts b/apis/postQuestionWrite.ts index 5dbe5a4..02e1ec2 100644 --- a/apis/postQuestionWrite.ts +++ b/apis/postQuestionWrite.ts @@ -1,4 +1,4 @@ -import { PostQuestionWriteResponse, QuestionWriteRequest } from '@/types/questionWrite.type'; +import { PostQuestionWriteResponse, QuestionWriteRequest } from '@/types/question.type'; import client from './client'; const postQuestionWrite = async ({ @@ -20,7 +20,7 @@ const postQuestionWrite = async ({ { headers: { Authorization: - 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJha211QGdtYWlsLmNvbSIsInJvbGVzIjpbIlJPTEVfVVNFUiJdLCJpYXQiOjE2OTU2MjY5NzAsImV4cCI6MTY5NTcxMzM3MH0.Qp-tus5vuO7r1wTsIQJAp_T80zQePo96y_LLH7w89OU', + 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJha211QGdtYWlsLmNvbSIsInJvbGVzIjpbXSwiaWF0IjoxNjk1OTgyNTI1LCJleHAiOjE2OTYwNjg5MjV9.N5UWZD4xvULjHk7EaKblTM7kJwEdZrQ3cfII1jZMuAE', }, }, ); diff --git a/hooks/useQuestionWrite.ts b/hooks/useQuestionWrite.ts index 5c3427b..a84fe64 100644 --- a/hooks/useQuestionWrite.ts +++ b/hooks/useQuestionWrite.ts @@ -1,4 +1,4 @@ -import { FieldType, QuestionWriteRequest } from '@/types/questionWrite.type'; +import { FieldType, QuestionWriteRequest } from '@/types/question.type'; import { RefObject, useState } from 'react'; import { Editor } from '@toast-ui/react-editor'; From 6d36af9b457d488f06470f59c34b4d9c7e6c697f Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:24:16 +0900 Subject: [PATCH 10/21] feat: queryClient export --- pages/_app.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index 475995d..80d849a 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -15,9 +15,10 @@ type AppPropsWithLayout = AppProps & { Component: NextPageWithLayout; }; +export const queryClient = new QueryClient(); + const MyApp = ({ Component, pageProps }: AppPropsWithLayout) => { const getLayout = Component.getLayout ?? ((page) => page); - const queryClient = new QueryClient(); return ( From 27924c342285bf99935dfaf8f48ce95595149fb1 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:24:47 +0900 Subject: [PATCH 11/21] =?UTF-8?q?feat:=20Api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/questionRead/[pid].tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pages/questionRead/[pid].tsx b/pages/questionRead/[pid].tsx index 7b3d865..528d50b 100644 --- a/pages/questionRead/[pid].tsx +++ b/pages/questionRead/[pid].tsx @@ -1,24 +1,27 @@ import theme from '@/styles/theme'; -// import { useRouter } from 'next/router'; import styled from 'styled-components'; import Spacing from '@/components/reusable/Spacing'; +import { useRouter } from 'next/router'; +import useGetQuestionRead from '@/hooks/useGetQuestionRead'; import Search from '../../components/reusable/Search'; import Question from './atoms/Question'; import Answer from './atoms/Answer'; import MyAnswer from './atoms/MyAnswer'; const QuestionRead = () => { - // const router = useRouter(); - // const { pid } = router.query; + const router = useRouter(); + const { pid } = router.query; + + const { data } = useGetQuestionRead(Number(pid) as number); return ( - - - + + + ); }; From d6de0a67f48358ebc01ff76caae71291308bcff7 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:25:07 +0900 Subject: [PATCH 12/21] =?UTF-8?q?feat:=20answer=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/questionRead/atoms/Answer.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pages/questionRead/atoms/Answer.tsx b/pages/questionRead/atoms/Answer.tsx index 50c9d3c..82c5e89 100644 --- a/pages/questionRead/atoms/Answer.tsx +++ b/pages/questionRead/atoms/Answer.tsx @@ -1,17 +1,23 @@ import theme from '@/styles/theme'; import styled from 'styled-components'; import Spacing from '@/components/reusable/Spacing'; +import { AnswerType } from '@/types/question.type'; import AnswerBox from './AnswerBox'; -const Answer = () => { - const AnswerBoxes = ['경영 마스터', '박숭실']; - +const Answer = ({ answers }: { answers?: AnswerType[] }) => { return ( - {AnswerBoxes.map((item, idx) => ( + {answers?.map((item, idx) => ( <> - - {idx < AnswerBoxes.length - 1 && } + {/* userName 수정 예정 */} + + {idx < answers.length - 1 && } ))} From 25f7a7d78ba427a5f56116c94e3ca00fcd48be9d Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:26:43 +0900 Subject: [PATCH 13/21] =?UTF-8?q?feat:=20answerBox=20viewer=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/questionRead/atoms/AnswerBox.tsx | 33 ++++++++++---------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/pages/questionRead/atoms/AnswerBox.tsx b/pages/questionRead/atoms/AnswerBox.tsx index 41d8a15..d18b412 100644 --- a/pages/questionRead/atoms/AnswerBox.tsx +++ b/pages/questionRead/atoms/AnswerBox.tsx @@ -1,13 +1,22 @@ import Spacing from '@/components/reusable/Spacing'; import theme from '@/styles/theme'; +import dynamic from 'next/dynamic'; +import dateConvertor from '@/utils/dateConverter'; import styled from 'styled-components'; interface AnswerBoxProps { // 추후 데이터 넘어오는 방식에 따라서 변경 예정 userName: string; + content: string; + postTime: string; + likes: number; } -const AnswerBox = ({ userName }: AnswerBoxProps) => { +const Viewer = dynamic(() => import('../../../components/reusable/MarkDown/MarkdownViewer'), { + ssr: false, +}); + +const AnswerBox = ({ userName, content, postTime }: AnswerBoxProps) => { return ( @@ -19,28 +28,10 @@ const AnswerBox = ({ userName }: AnswerBoxProps) => { - 경영학을 심도깊게 배우고자 하는 경우, 다음과 같은 인강 사이트와 공부 방법, 그리고 추천 - 도서를 고려해볼 수 있습니다.
-
- 인강 사이트:
- 1. Coursera (https://www.coursera.org/): Coursera는 유명 대학의 경영학 강의를 비롯한 다양한 - 온라인 강의를 제공합니다. 경영학에 관련된 강좌들을 찾아보고, 강의 퀄리티와 교수진을 확인하여 - 선택할 수 있습니다.
2. edX (https://www.edx.org/): edX도 Coursera와 마찬가지로 - 세계적인 대학들의 경영학 관련 강의를 제공합니다. 고품질의 강의와 다양한 주제를 제공하므로 - 참고해보세요.
3. Harvard Business School Online (https://online.hbs.edu/): 하버드 - 비즈니스 스쿨에서 운영하는 온라인 강의 플랫폼으로, 다양한 경영 관련 강의를 제공합니다. - 전문적이고 광범위한 주제를 다루므로 심도깊게 학습할 수 있습니다.
-
- 공부 방법:
1. 체계적인 계획 수립: 경영학의 다양한 분야를 다루기 위해 체계적인 학습 - 계획을 수립해야 합니다. 주제를 구분하고 순서를 정하여 조금씩 꾸준히 학습하도록 계획해보세요. -
- 2. 참고 자료 활용: 강의 외에도 경영학에 대한 참고 자료들을 활용하세요. 논문, 서적, 학술지 - 등을 통해 심층적인 이해를 도모할 수 있습니다.
- 3. 실전 적용: 이론을 학습한 후, 실제 비즈니스 상황에 적용해보세요. 케이스 스터디, 프로젝트, - 시뮬레이션 등을 통해 경영 이론을 실전에 적용하며 실력을 향상시킬 수 있습니다. +
- 07/07 + {dateConvertor(postTime)}
); }; From cf62b63b6dec3fe1ba11846e4754172186b118d1 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:27:06 +0900 Subject: [PATCH 14/21] =?UTF-8?q?feat:=20myanswer=20api=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/questionRead/atoms/MyAnswer.tsx | 32 ++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/pages/questionRead/atoms/MyAnswer.tsx b/pages/questionRead/atoms/MyAnswer.tsx index 84c4a9d..c49ed58 100644 --- a/pages/questionRead/atoms/MyAnswer.tsx +++ b/pages/questionRead/atoms/MyAnswer.tsx @@ -1,8 +1,11 @@ import SquareBtn from '@/components/reusable/Buttons/SquareBtn'; import MarkdownEditorSkeleton from '@/components/reusable/MarkDown/MarkdownEditorSkeleton'; import Spacing from '@/components/reusable/Spacing'; +import usePostAnswer from '@/hooks/usePostAnswer'; import theme from '@/styles/theme'; +import { Editor } from '@toast-ui/react-editor'; import dynamic from 'next/dynamic'; +import { RefObject, useEffect, useState } from 'react'; import styled from 'styled-components'; const MarkdownEditor = dynamic( @@ -15,7 +18,23 @@ const MarkdownEditor = dynamic( }, ); -const MyAnswer = () => { +interface MyAnswerProps { + pId: number; +} + +const MyAnswer = ({ pId }: MyAnswerProps) => { + const [answerContent, setAnswerContent] = useState(''); + + const handleContent = (editorRef: RefObject) => { + const data = editorRef?.current?.getInstance().getMarkdown(); + setAnswerContent(data as string); + }; + + const { mutate: postAnswer, isSuccess } = usePostAnswer(pId); + + useEffect(() => { + setAnswerContent(''); + }, [isSuccess]); return ( @@ -34,9 +53,16 @@ const MyAnswer = () => { - + - 답변 게시 + { + postAnswer({ content: answerContent, fileIds: [], questionId: pId }); + }} + > + 답변 게시 + ); From 96c4162d31afe667d3215861f2675bf3473436ae Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:27:21 +0900 Subject: [PATCH 15/21] =?UTF-8?q?feat:=20Question=20api=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/questionRead/atoms/Question.tsx | 97 +++++++++++++++------------ 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/pages/questionRead/atoms/Question.tsx b/pages/questionRead/atoms/Question.tsx index 586bcdb..5fb3140 100644 --- a/pages/questionRead/atoms/Question.tsx +++ b/pages/questionRead/atoms/Question.tsx @@ -1,57 +1,70 @@ import Spacing from '@/components/reusable/Spacing'; import Tag from '@/components/reusable/Tag'; import theme from '@/styles/theme'; +import { GetQuestionResponse } from '@/types/question.type'; +import fieldConverter from '@/utils/fieldConverter'; +import dateConvertor from '@/utils/dateConverter'; import dynamic from 'next/dynamic'; - import styled from 'styled-components'; const Viewer = dynamic(() => import('../../../components/reusable/MarkDown/MarkdownViewer'), { ssr: false, }); -const Question = () => { +interface QuestionProps { + data?: GetQuestionResponse; +} + +const Question = ({ data }: QuestionProps) => { return ( - - - -

학교 생활

-
- - -

공부법

-
- - -

경영학

-
-
- - - - {`Q. ${'경영학 인강이나 공부 방법'}`} - 신고 - - - - - {/* 경영학을 심도깊게 기초부터 배우고 싶은데요! -
- 강의, 퀄리티, 내용, 교수진이 괜찮은 인강 사이트 & 공부 방법이 궁금합니다! -
- 공부하기 좋은 서적도 추천해주시면 감사하겠습니다 */} -
- - - 슝슝이 - - 4시간 전 - - {`조회수 ${100}`} - - -
-
+ {data ? ( + + + {data.field?.map((item) => ( + <> + +

{fieldConverter(item)}

+
+ + + ))} + {data.tag?.map((item, index) => + index < data.tag.length - 1 ? ( + <> + +

{item}

+
+ + + ) : ( + +

{item}

+
+ ), + )} +
+ + + + {`Q. ${data.title}`} + 신고 + + + {data.content && } + + + {data.memberName} + + {/* 수정 필요 */} + {dateConvertor(data.postTime)} + + {`조회수 ${data.hits}`} + + + +
+ ) : null}
); }; From 6f4939935af0a4c1863f7ddfa038d20cbff6c01d Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:28:02 +0900 Subject: [PATCH 16/21] =?UTF-8?q?rename:=20question.type=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EB=AA=85=20=EC=88=98=EC=A0=95=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/questionWrite/atoms/FieldSelector.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/questionWrite/atoms/FieldSelector.tsx b/pages/questionWrite/atoms/FieldSelector.tsx index e547770..0935de3 100644 --- a/pages/questionWrite/atoms/FieldSelector.tsx +++ b/pages/questionWrite/atoms/FieldSelector.tsx @@ -5,7 +5,7 @@ import ToggleBtn from '@/components/reusable/Buttons/ToggleBtn'; import { useRecoilState } from 'recoil'; import fieldListState from '@/states/fieldListState'; import { useState } from 'react'; -import { FieldType } from '@/types/questionWrite.type'; +import { FieldType } from '@/types/question.type'; import QuestionTitle from './QuestionTitle'; interface FieldSelectorProps { From 22e3aef7eca1caf51219e516894457277c452cb0 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:34:39 +0900 Subject: [PATCH 17/21] rename: answerWrite.type -> answer.type --- types/answer.type.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 types/answer.type.ts diff --git a/types/answer.type.ts b/types/answer.type.ts new file mode 100644 index 0000000..e26ae27 --- /dev/null +++ b/types/answer.type.ts @@ -0,0 +1,11 @@ +export interface AnswerWriteRequest { + questionId: number; + content: string; + fileIds: number[]; +} + +export interface PostAnswerWriteResponse { + body: object; + statusCode: string; + statusCodeValue: number; +} From f15526029136068906f2b1d64770213307336aaa Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:35:17 +0900 Subject: [PATCH 18/21] =?UTF-8?q?feat:=20api=20=EC=88=98=EC=A0=95=EC=97=90?= =?UTF-8?q?=20=EB=94=B0=EB=A5=B8=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/question.type.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/question.type.ts b/types/question.type.ts index b855493..cac535d 100644 --- a/types/question.type.ts +++ b/types/question.type.ts @@ -28,6 +28,8 @@ export interface GetQuestionResponse { field: FieldType[]; tag: string[]; memberId: number; + memberName: string; + postTime: string; hits: number; likes: number; answerList: AnswerType[]; From 4b6338339bfdee566e40e45f0c07d5925cf8faa0 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:35:38 +0900 Subject: [PATCH 19/21] =?UTF-8?q?feat:=20=EB=82=A0=EC=A7=9C=EB=B3=80?= =?UTF-8?q?=ED=99=98=ED=95=A8=EC=88=98=20=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/dateConverter.ts | 78 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 utils/dateConverter.ts diff --git a/utils/dateConverter.ts b/utils/dateConverter.ts new file mode 100644 index 0000000..dcd7019 --- /dev/null +++ b/utils/dateConverter.ts @@ -0,0 +1,78 @@ +const SimpleDateTimeFormat = (date: Date, pattern: string) => { + const dateString = pattern.replace(/(yyyy|MM|dd|HH|mm|ss|SSS)/g, (match) => { + let matchString = ''; + switch (match) { + case 'yyyy': + matchString = String(date.getFullYear()); + break; + case 'MM': + matchString = String(date.getMonth() + 1); + break; + case 'dd': + matchString = String(date.getDate()); + break; + case 'HH': + matchString = String(date.getHours()); + break; + case 'mm': + matchString = String(date.getMinutes()); + break; + case 'ss': + matchString = String(date.getSeconds()); + break; + case 'SSS': + matchString = String(date.getMilliseconds()); + break; + default: + matchString = match; + break; + } + if (match == 'SSS') { + if (Number(matchString) < 10) { + matchString = `00${matchString}`; + } else if (Number(matchString) < 100) { + matchString = `0${matchString}`; + } + } else if (typeof matchString === 'number' && matchString < 10) { + matchString = `0${matchString}`; + } + return matchString; + }); + + return dateString; +}; + +const dateConvertor = (date: string) => { + const writeDate = new Date(date); + + // 초 (밀리초) + const seconds = 1; + // 분 + const minute = seconds * 60; + // 시 + const hour = minute * 60; + // 일 + const day = hour * 24; + + const today = new Date(); + const elapsedTime = Math.trunc((today.getTime() - writeDate.getTime()) / 1000); + + let elapsedText = ''; + if (elapsedTime < seconds) { + elapsedText = '방금 전'; + } else if (elapsedTime < minute) { + elapsedText = `${elapsedTime}초 전`; + } else if (elapsedTime < hour) { + elapsedText = `${Math.trunc(elapsedTime / minute)}분 전`; + } else if (elapsedTime < day) { + elapsedText = `${Math.trunc(elapsedTime / hour)}시간 전`; + } else if (elapsedTime < day * 15) { + elapsedText = `${Math.trunc(elapsedTime / day)}일 전`; + } else { + elapsedText = SimpleDateTimeFormat(writeDate, 'yyyy.M.d'); + } + + return elapsedText; +}; + +export default dateConvertor; From 011b174723b6dbd023ac1587af23374a369ceac7 Mon Sep 17 00:00:00 2001 From: intersoom Date: Mon, 2 Oct 2023 15:36:01 +0900 Subject: [PATCH 20/21] =?UTF-8?q?feat:=20=ED=95=84=EB=93=9C=20api=20?= =?UTF-8?q?=EC=9A=A9=EC=96=B4=20->=20=ED=99=94=EB=A9=B4=20=EC=9A=A9?= =?UTF-8?q?=EC=96=B4=20=EB=B3=80=ED=99=98=20=ED=95=A8=EC=88=98=20=EC=A0=9C?= =?UTF-8?q?=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/fieldConverter.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 utils/fieldConverter.ts diff --git a/utils/fieldConverter.ts b/utils/fieldConverter.ts new file mode 100644 index 0000000..06ca992 --- /dev/null +++ b/utils/fieldConverter.ts @@ -0,0 +1,22 @@ +import { FieldType } from '@/types/question.type'; + +const fieldConverter = (field: FieldType) => { + switch (field) { + case 'BACKEND': + return '백엔드'; + case 'FRONTEND': + return '프론트엔드'; + case 'DESIGN': + return '디자인'; + case 'MOBILE': + return '모바일'; + case 'PRODUCT_MANAGER': + return '기획 / PM'; + case 'SCHOOL': + return '학교 생활'; + default: + return field; + } +}; + +export default fieldConverter; From 19a92c748a4290a52a71160d41d536d672d5c619 Mon Sep 17 00:00:00 2001 From: seocylucky Date: Tue, 3 Oct 2023 17:48:47 +0900 Subject: [PATCH 21/21] =?UTF-8?q?Etc:=20lint=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + pages/signin.tsx | 13 +++++++------ yarn.lock | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1f9549e..f38137b 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "babel-plugin-styled-components": "^2.1.4", "eslint": "^8.45.0", "eslint-config-next": "13.4.11", + "eslint-import-resolver-node": "^0.3.9", "next": "13.4.11", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/pages/signin.tsx b/pages/signin.tsx index dbe8f26..ee93949 100644 --- a/pages/signin.tsx +++ b/pages/signin.tsx @@ -1,15 +1,15 @@ import type { NextPage } from 'next'; import { styled } from 'styled-components'; +import Link from 'next/link'; +// import { useState } from 'react'; +import TextInput from '@/components/reusable/Inputs/TextInput'; import Spacing from '../components/reusable/Spacing'; import theme from '../styles/theme'; -import TextInput from '../components/reusable/TextInput'; import SquareBtn from '../components/reusable/Buttons/SquareBtn'; -import Link from 'next/link'; -import { useState } from 'react'; const Signin: NextPage = () => { - const [email, setEmail] = useState(''); - const [password, setPassword] = useState(''); + // const [email, setEmail] = useState(''); + // const [password, setPassword] = useState(''); return ( @@ -27,13 +27,14 @@ const Signin: NextPage = () => { - + 로그인 비밀번호 찾기 | 회원가입 + ); }; diff --git a/yarn.lock b/yarn.lock index 71da287..b8875fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2497,6 +2497,15 @@ eslint-import-resolver-node@^0.3.6, eslint-import-resolver-node@^0.3.7: is-core-module "^2.11.0" resolve "^1.22.1" +eslint-import-resolver-node@^0.3.9: + version "0.3.9" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz#d4eaac52b8a2e7c3cd1903eb00f7e053356118ac" + integrity sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g== + dependencies: + debug "^3.2.7" + is-core-module "^2.13.0" + resolve "^1.22.4" + eslint-import-resolver-typescript@^3.4.0, eslint-import-resolver-typescript@^3.5.2: version "3.5.5" resolved "https://registry.yarnpkg.com/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.5.5.tgz#0a9034ae7ed94b254a360fbea89187b60ea7456d" @@ -3159,6 +3168,13 @@ is-core-module@^2.11.0, is-core-module@^2.9.0: dependencies: has "^1.0.3" +is-core-module@^2.13.0: + version "2.13.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.0.tgz#bb52aa6e2cbd49a30c2ba68c42bf3435ba6072db" + integrity sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ== + dependencies: + has "^1.0.3" + is-date-object@^1.0.1: version "1.0.5" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.5.tgz#0841d5536e724c25597bf6ea62e1bd38298df31f" @@ -4053,6 +4069,15 @@ resolve@^1.14.2, resolve@^1.22.1: path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" +resolve@^1.22.4: + version "1.22.6" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.6.tgz#dd209739eca3aef739c626fea1b4f3c506195362" + integrity sha512-njhxM7mV12JfufShqGy3Rz8j11RPdLy4xi15UurGJeoHLfJpVXKdh3ueuOqbYUcDZnffr6X739JBo5LzyahEsw== + dependencies: + is-core-module "^2.13.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + resolve@^2.0.0-next.4: version "2.0.0-next.4" resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.4.tgz#3d37a113d6429f496ec4752d2a2e58efb1fd4660"