diff --git a/frontend/src/Pages/myslide.tsx b/frontend/src/Pages/myslide.tsx index cb1e0bac83439c8f217adbe8fd0a031d1b9dd1b0..78b32ec643748024868d4738be7aced32328cef2 100644 --- a/frontend/src/Pages/myslide.tsx +++ b/frontend/src/Pages/myslide.tsx @@ -48,7 +48,7 @@ export function MySlide({ slides}: num) { {slides.slice(page - 1, page + 2).map((slide) => (
-
+
{slide}
diff --git a/frontend/src/auth/login.tsx b/frontend/src/auth/login.tsx index c5c3eed0b4e897187d9944e53ef31bc040c9fe4c..3374530e0eceaaf3d5b16224d71e320555d26c47 100644 --- a/frontend/src/auth/login.tsx +++ b/frontend/src/auth/login.tsx @@ -35,11 +35,9 @@ export default function Login() { setLoading(true); await login(user.email, user.password, () => { - if (user.email == "admin@korea.ac.kr" && user.password == "111111") { - navigate("/admin", { replace: true }); - } else { - navigate("/", { replace: true }); - } + + navigate("/", { replace: true }); + }); // console.log("서버연결됬나요", res); // console.log("로그인"); diff --git a/frontend/src/auth/profile.tsx b/frontend/src/auth/profile.tsx index ccf4863063b543da3ee1a006aeca7b91d32a89f9..07ef7af519ce18d0b40bbbdf29d49348a6f83792 100644 --- a/frontend/src/auth/profile.tsx +++ b/frontend/src/auth/profile.tsx @@ -59,7 +59,7 @@ export default function Profile() { const user: Profile = await profileApi.profile(); console.log("user in effect", user); setEmail(user.email); - setAvatarUrl(user.avatar?.newfilename); + setAvatarUrl(user.fileInfo?.newfilename); setProfile({ ...profile, name: user.name }); }; getProfile(); diff --git a/frontend/src/auth/signup.tsx b/frontend/src/auth/signup.tsx index c08d1907c92d431cb3e1c3af8737b7db26acad6b..570734852b02e2f218a8e4ed64b9fec597c13c39 100644 --- a/frontend/src/auth/signup.tsx +++ b/frontend/src/auth/signup.tsx @@ -77,12 +77,12 @@ export default function Signup() {
-
+
이름
-
+
-
+
이메일
-
+
-
+
비밀번호
-
+
-
+
비밀번호 확인
-
+
(); + const location = useLocation() as Newpost; + const newPost = location.state; + const navigate = useNavigate(); + const { user } = useAuth(); + + console.log("get newPost Info", newPost); + + const setNewPosts = (newpost: PostType) => { + const postArr = posts?.splice(-1, 0, newPost); + if (!(postArr === undefined)) { + setPosts(postArr); + } + }; useEffect(() => { getDataList(); + setNewPosts(newPost); }, []); // posts const getDataList = async () => { const res = await postApi.getData(); - setPosts(res); + setPosts(res); //posts = res }; const titleHandleClick = async (event: MouseEvent) => { @@ -36,29 +55,37 @@ export default function BoardPage() { } }; + const GoLogin = async (event: React.MouseEvent) => { + if (!user.isLoggedIn) { + alert("로그인이 필요합니다."); + navigate("/login", { replace: true }); + } + }; + return (
-
자유 게시판
-
여행지 후기를 남겨주세요!
+
자유 게시판
+
+ 여행지 후기를 남겨주세요! +
-
- - - -
{" "} - {/* Link */} +
+ +
-
+
제목
게시 날짜
조회수
-
+
{posts?.map((post, i) => ( ))} diff --git a/frontend/src/home/body.tsx b/frontend/src/home/body.tsx index a3be100083d390a158592ba35bf0ad4a5a2ef1f9..55ad8aa2246ca85f6dcc491a11d47802e072b8d5 100644 --- a/frontend/src/home/body.tsx +++ b/frontend/src/home/body.tsx @@ -21,10 +21,10 @@ export default function Body() { imgsData(); }, []); - useEffect(() => { - console.log(searchParams.get("theme"), searchParams.get("city")); - setSearchParams(searchParams); - }, []); + // useEffect(() => { + // console.log(searchParams.get("theme"), searchParams.get("city")); + // setSearchParams(searchParams); + // }, []); const themeHandleClick = (event: MouseEvent) => { console.log(`theme id= ${event.currentTarget.id}`); @@ -65,16 +65,16 @@ export default function Body() { Idpics.slice(i * limit, i * limit + limit).map( (picture, index: number) => (
-
+
{picture.title}
diff --git a/frontend/src/home/header.tsx b/frontend/src/home/header.tsx index ff3c9c08dcec4f89921e3476ab8c0c33b771608f..f0be7f926c27b2b5a2763c2af55607c40c5f003a 100644 --- a/frontend/src/home/header.tsx +++ b/frontend/src/home/header.tsx @@ -14,20 +14,20 @@ export default function Header() { }; return ( -
+
-
-
diff --git a/frontend/src/home/theme.tsx b/frontend/src/home/theme.tsx index 1b70b00b1422d5577092b8ca3bbfab542c8638d3..058ed3915f5095f5ca7bcee28fca5d3d348add08 100644 --- a/frontend/src/home/theme.tsx +++ b/frontend/src/home/theme.tsx @@ -1,89 +1,120 @@ -import React, { MouseEventHandler } from "react"; +import React, { MouseEventHandler, useState } from "react"; type ThemeProps = { handleClick: MouseEventHandler; }; export default function Theme({ handleClick }: ThemeProps) { + const [active, setActive] = useState(0); + + const onactive = "whitespace-nowrap px-5 text-sky-300 "; + const offactive = "whitespace-nowrap px-5 "; + + const clickActive = (a: number) => { + setActive(a); + }; + return ( -
- - - - - - - - - - - +
+
clickActive(1)}> + +
+
clickActive(2)}> + +
+
clickActive(3)}> + +
+
clickActive(4)}> + +
+
clickActive(5)}> + +
+
clickActive(6)}> + +
+
clickActive(7)}> + +
+
clickActive(8)}> + +
+
clickActive(9)}> + +
+
clickActive(10)}> + +
+
clickActive(11)}> + +
); } diff --git a/frontend/src/pages/citylist.tsx b/frontend/src/pages/citylist.tsx index a6fa3de76f845f0c3d986759106542e28f1e94d0..7f498db54a301099f1b5df42b8b8e123bd9110c6 100644 --- a/frontend/src/pages/citylist.tsx +++ b/frontend/src/pages/citylist.tsx @@ -1,86 +1,114 @@ -import React, { MouseEventHandler } from "react"; +import React, { MouseEventHandler, useState } from "react"; type CityProps = { handleClick: MouseEventHandler; }; export default function Citylist({ handleClick }: CityProps) { + const [active, setActive] = useState(0); + + const onactive = "text-start px-5 py-2 underline whitespace-nowrap"; + const offactive = "text-start px-5 py-2 whitespace-nowrap"; + + const clickActive = (a: number) => { + setActive(a); + }; + return (
도시
- - - - - - - - - - - {/* citylist */} +
clickActive(1)}> + +
+
clickActive(2)}> + +
+
clickActive(3)}> + +
+
clickActive(4)}> + +
+
clickActive(5)}> + +
+
clickActive(6)}> + +
+
clickActive(7)}> + +
+
clickActive(8)}> + +
+
clickActive(9)}> + +
+
clickActive(10)}> + +
// Citylist Page ); diff --git a/frontend/src/post/editpost.tsx b/frontend/src/post/editpost.tsx index f800f2875e8b3f3574320635431d7261b9ef954b..411f68ae29211d2c736e2fd3543cbbb7e727e946 100644 --- a/frontend/src/post/editpost.tsx +++ b/frontend/src/post/editpost.tsx @@ -1,25 +1,24 @@ -import React, { FormEvent, useState, useEffect } from "react"; -import { useNavigate, useLocation } from "react-router-dom"; +import React, { FormEvent, MouseEventHandler, useState } from "react"; +import { useNavigate, useLocation, Link } from "react-router-dom"; import isLength from "validator/lib/isLength"; import equals from "validator/lib/equals"; import { catchErrors } from "../helpers"; import { PostType } from "../types"; import { postApi } from "../apis"; import { PostState } from "./intopost"; -import { FileType } from "./intopost"; export function EditPost() { - const [city, setCity] = useState("city"); - const [theme, setTheme] = useState("theme"); + const location = useLocation() as PostState; + const post = location.state; + + const [city, setCity] = useState(post.city); + const [theme, setTheme] = useState(post.theme); const [title, setTitle] = useState(""); const [text, setText] = useState(""); const [file, setFile] = useState(); const [imgSrc, setImgSrc] = useState(); - const [filesList, setFilesList] = useState(); + const [change, setChange] = useState(false); const navigate = useNavigate(); - const location = useLocation() as PostState; - - const post = location.state; const [user, setUser] = useState({ title: post.title, @@ -30,6 +29,7 @@ export function EditPost() { user: post.user, counts: post.counts, _id: post._id, + file: post.file, }); const [loading, setLoading] = useState(false); @@ -37,24 +37,17 @@ export function EditPost() { const [disabled, setDisabled] = useState(false); const [success, setSuccess] = useState(false); - useEffect(() => { - getFilesList(post._id); - }, []); - - const getFilesList = async (postId: string) => { - const res = await postApi.getFileByPostId(postId); - setFilesList(res); - }; - const imgArr = new Array(); - const updateImg2Db = async (filelist: FileList) => { + // console.log("post.file", post.file); + + const updateImg2Db = async (filelist: FileList | undefined) => { const formdata = new FormData(); formdata.append("title", user.title); formdata.append("text", user.text); formdata.append("theme", user.theme); formdata.append("city", user.city); - if (filelist === undefined || filelist === null) { + if (filelist === undefined) { const res = await postApi.updateImgAndPost(user._id, formdata); } else { for (var i = 0; i < filelist.length; i++) { @@ -69,14 +62,12 @@ export function EditPost() { try { if (confirm("게시물을 수정하시겠습니까?") == true) { setError(""); - // console.log("user data", user); if (postingFormMatch(user) === true) { setLoading(true); - if (file) { - const res = updateImg2Db(file); - // console.log(res); - } - navigate("/board", { replace: true }); + + const updateRes = await updateImg2Db(file); + navigate("/board", { replace: true, state: updateRes }); + setSuccess(true); setError(""); } @@ -92,9 +83,12 @@ export function EditPost() { } const handleInputPic = async (event: React.ChangeEvent) => { + setChange(true); const maxImg = 10; const { files } = event.target; + // console.log("update file", files); + if (!(files === null)) { setFile(files); } @@ -118,18 +112,18 @@ export function EditPost() { function postingFormMatch(user: PostType) { if (!isLength(user.title ?? "", { min: 1 })) { - setError("제목을 입력해 주세요."); alert("제목을 입력해 주세요."); + setError("제목을 입력해 주세요."); return false; } else if (!isLength(user.text ?? "", { min: 1 })) { alert("내용을 입력해 주세요."); setError("내용을 입력해 주세요."); return false; - } else if (equals(user.city, "city")) { + } else if (equals(city, "city")) { alert("도시를 선택해 주세요."); setError("도시를 선택해 주세요."); return false; - } else if (equals(user.theme, "theme")) { + } else if (equals(theme, "theme")) { alert("테마를 선택해 주세요."); setError("테마를 선택해 주세요."); return false; @@ -170,96 +164,127 @@ export function EditPost() { setUser(newUser); }; + const GoBack = () => { + if (confirm("취소하시겠습니까?") == true) { + navigate(-1); + } + }; + + const oldFileShow = (post: PostType) => { + const res = post.file?.map((file, i) => ( + + )); + // console.log("oldfiles", res); + return res; + }; + + const newFileShow = (imgSrc: string[] | undefined) => { + const res = imgSrc?.map((img, i) => ( + + )); + return res; + }; + return ( -
-
-
- - -
+
+ +
+
+ + +
- + - + - -
+ +
-
-