From 7ce025e43993164bb1283e41c9b51279c6f1971b Mon Sep 17 00:00:00 2001 From: haksoo Date: Tue, 17 Dec 2024 10:45:15 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=8C=B1=20=EA=B2=8C=EC=8B=9C=EA=B8=80?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/_app.tsx | 6 +++--- pages/addboard.tsx | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 pages/addboard.tsx diff --git a/pages/_app.tsx b/pages/_app.tsx index 6fa9382..48411d4 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,13 +1,13 @@ import type { AppProps } from 'next/app'; -import DarkModeToggle from '@/components/DarkmodeToggle'; - +// TODO - 나중에 주석 풀어야 함 +// import DarkModeToggle from '@/components/DarkmodeToggle'; import '@/styles/globals.css'; export default function App({ Component, pageProps }: AppProps) { return ( <> - + {/* */} ); diff --git a/pages/addboard.tsx b/pages/addboard.tsx new file mode 100644 index 0000000..3b56faf --- /dev/null +++ b/pages/addboard.tsx @@ -0,0 +1,10 @@ +export default function Addboard() { + return ( +
+
gnb
+
+

게시글 작성

+
+
+ ); +} From 35fcbe3e0a444fc7b4c611346fe18666339b0c9f Mon Sep 17 00:00:00 2001 From: haksoo Date: Wed, 18 Dec 2024 14:35:54 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=94=A8=20=EA=B5=AC=EC=A1=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EA=B8=B0=EB=B3=B8=20=EA=B8=B0=EB=8A=A5=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/_app.tsx | 6 +-- pages/addboard.tsx | 92 +++++++++++++++++++++++++++++++++++++++++++++- styles/globals.css | 2 +- 3 files changed, 94 insertions(+), 6 deletions(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index 48411d4..6fa9382 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,13 +1,13 @@ import type { AppProps } from 'next/app'; -// TODO - 나중에 주석 풀어야 함 -// import DarkModeToggle from '@/components/DarkmodeToggle'; +import DarkModeToggle from '@/components/DarkmodeToggle'; + import '@/styles/globals.css'; export default function App({ Component, pageProps }: AppProps) { return ( <> - {/* */} + ); diff --git a/pages/addboard.tsx b/pages/addboard.tsx index 3b56faf..44aaa1c 100644 --- a/pages/addboard.tsx +++ b/pages/addboard.tsx @@ -1,9 +1,97 @@ +import { FormEvent, useState } from 'react'; + +import Button from '@/components/Button'; +import TextEditor from '@/components/TextEditor'; + +// 제목 글자수 제한 +const MAX_TITLE = 30; + +// HTML에서 Text만 추출하는 함수 +function extractContent(str: string) { + return str.replace(/<[^>]*>/g, '').trim(); +} + +/** + * 게시글 등록하기 페이지 + */ export default function Addboard() { + const [title, setTitle] = useState(''); + const [content, setContent] = useState(''); + + const submitDisabled = title.length === 0 || content.length === 0; + const textContent = extractContent(content); + + const handleInputChange = (e: React.ChangeEvent) => { + // console.log('handleChange:e:', e); + setTitle(e.target.value); + }; + const handleContentChange = (value: string) => { + // console.log('value:', value); + setContent(value); + }; + const handleSubmit = (e: FormEvent) => { + e.preventDefault(); + console.log('form submit!'); + // TODO - API 연결 및 처리 + }; + return (
-
gnb
+
GNB 영역
+
-

게시글 작성

+
+
+
+

+ 게시물 등록하기 +

+ +
+ +
+ 등록일2000. 00. 00. +
+ +
+
+ + +
+ {title.length}/ + {MAX_TITLE} +
+
+ +

+ 공백포함 : 총 {textContent.length}자 | 공백제외 총{' '} + {textContent.replaceAll(' ', '').length}자 +

+ +
+ +
+
+
+ +
+ +
+
); diff --git a/styles/globals.css b/styles/globals.css index 0a9cdfe..9e4123f 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -69,7 +69,7 @@ body { @apply border-0; } .ql-toolbar.ql-snow { - @apply order-last rounded-full border-gray-200 text-gray-400; + @apply order-last rounded-3xl border-gray-200 text-gray-400; } .ql-snow .ql-stroke { stroke: var(--gray-400); From 3e4b8a49ec1689e8f84b60ced2d0aa7eb21e3c01 Mon Sep 17 00:00:00 2001 From: haksoo Date: Wed, 18 Dec 2024 15:08:16 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=94=A8=20=EA=B8=80=EC=9E=91=EC=84=B1?= =?UTF-8?q?=20api=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20-=20=EC=9D=B8=EC=A6=9D?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC=20=EB=90=98=EB=A9=B4=20=EA=B7=B8=EB=95=8C?= =?UTF-8?q?=20=EB=8B=A4=EC=8B=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/addboard.tsx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/pages/addboard.tsx b/pages/addboard.tsx index 44aaa1c..742ac2e 100644 --- a/pages/addboard.tsx +++ b/pages/addboard.tsx @@ -1,3 +1,4 @@ +import instance from 'lib/axios-client'; import { FormEvent, useState } from 'react'; import Button from '@/components/Button'; @@ -29,10 +30,19 @@ export default function Addboard() { // console.log('value:', value); setContent(value); }; - const handleSubmit = (e: FormEvent) => { + const handleSubmit = async (e: FormEvent) => { e.preventDefault(); - console.log('form submit!'); - // TODO - API 연결 및 처리 + console.log('submit work!'); + // API 연결 및 처리 + // TODO - 로그인 및 인증되면 그때 다시 테스트 + instance + .post('/articles', { + image: '', + content, + title, + }) + .then((res) => console.log('subtmi:res:', res)) + .catch((err) => console.log('submit:err:', err)); }; return ( @@ -46,7 +56,11 @@ export default function Addboard() {

게시물 등록하기

- @@ -55,7 +69,11 @@ export default function Addboard() { 등록일2000. 00. 00. -
+