From f5e54de6388446074ca3c3b7ee5a275b7f6a0e73 Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 12 Nov 2023 08:48:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?New=20:=20=EC=95=84=EC=9D=B4=EC=BD=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/assets/icons/CameraIcon.svg | 8 ++++++++ client/src/assets/icons/PinIcon.svg | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 client/src/assets/icons/CameraIcon.svg create mode 100644 client/src/assets/icons/PinIcon.svg diff --git a/client/src/assets/icons/CameraIcon.svg b/client/src/assets/icons/CameraIcon.svg new file mode 100644 index 0000000..1ef635f --- /dev/null +++ b/client/src/assets/icons/CameraIcon.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/client/src/assets/icons/PinIcon.svg b/client/src/assets/icons/PinIcon.svg new file mode 100644 index 0000000..63c1bd1 --- /dev/null +++ b/client/src/assets/icons/PinIcon.svg @@ -0,0 +1,8 @@ + + + + + + + + From 3f083b5bd7f74cc6af133bdaaae003fa512853c0 Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 12 Nov 2023 08:48:44 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Refactor=20:=20=EA=B8=80=EC=93=B0=EA=B8=B0?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B3=A0=EB=8F=84=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/(protectedRoute)/new-post/page.tsx | 152 ++++++++++++------ client/src/app/@Modal/(.)new-post/page.tsx | 5 +- 2 files changed, 107 insertions(+), 50 deletions(-) diff --git a/client/src/app/(protectedRoute)/new-post/page.tsx b/client/src/app/(protectedRoute)/new-post/page.tsx index 4212d0b..fbc3133 100644 --- a/client/src/app/(protectedRoute)/new-post/page.tsx +++ b/client/src/app/(protectedRoute)/new-post/page.tsx @@ -15,10 +15,11 @@ import GoBackIcon from "@/assets/icons/GoBackIcon.svg"; import InputSearchIcon from "@/assets/icons/InputSearchIcon.svg"; import AlcholeSearchIcon from "@/assets/icons/AlcholeSearchIcon.svg"; import { useRouter } from "next/navigation"; -import { ChangeEvent, useEffect, useState } from "react"; -import { useUserInfoQuery } from "@/queries/auth/useUserInfoQuery"; +import { ChangeEvent, useEffect, useMemo, useState } from "react"; import axios from "@/libs/axios"; import HOME from "@/const/clientPath"; +import CameraIcon from "@/assets/icons/CameraIcon.svg"; +import PinIcon from "@/assets/icons/PinIcon.svg"; export default function NewpostPage() { const [formValue, setFormValue] = useState({ @@ -77,11 +78,21 @@ export default function NewpostPage() { }); }); }; - const [userTypedTag, setUserTypedTag] = useState(); + const [userTypedTag, setUserTypedTag] = useState(""); const [file, setFile] = useState(); + const [fileUrl, setFileUrl] = useState(); + + useEffect(() => { + if (!file) { + return; + } + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onloadend = () => setFileUrl(reader.result); + }, [file]); return ( - <> + router.back()}> @@ -90,7 +101,11 @@ export default function NewpostPage() { 포스팅 - + 공유 @@ -104,11 +119,6 @@ export default function NewpostPage() { gap: 2, p: 2, }} - component="form" - onSubmit={(e) => { - e.preventDefault(); - submitHandler(); - }} > { + e.target.value.length <= 200 && changeHadler(e); + }} value={formValue.postContent} rows={6} /> @@ -139,51 +151,93 @@ export default function NewpostPage() { 200자 - {formValue.tagList.map((tag) => { - return {tag}; - })} - + + {formValue.tagList.map((tag) => { + return #{tag}; + })} + + { + e.preventDefault(); + setFormValue((prev) => { + if (!userTypedTag) return prev; + return { ...prev, tagList: [...prev.tagList, userTypedTag] }; + }); + setUserTypedTag(""); + }} + sx={{ display: "flex", gap: 1 }} + > setUserTypedTag(target.value)} value={userTypedTag} - > - + size="small" + sx={{ flexShrink: 1 }} + /> + - - + )} + + + + { + if (e.target.files) { + setFile(e.target.files[0]); + } + }} + /> + + + + + - + ); } diff --git a/client/src/app/@Modal/(.)new-post/page.tsx b/client/src/app/@Modal/(.)new-post/page.tsx index 37ae82c..2dfd2bc 100644 --- a/client/src/app/@Modal/(.)new-post/page.tsx +++ b/client/src/app/@Modal/(.)new-post/page.tsx @@ -1,10 +1,13 @@ import AuthProtectorlayout from "@/app/(protectedRoute)/layout"; +import NewpostPage from "@/app/(protectedRoute)/new-post/page"; import ModalWrapper from "@/components/ModalWrapper"; const NewPostPage = () => { return ( - {"페이지"} + + + ); };