Commit f8c7d710 authored by Kim, MinGyu's avatar Kim, MinGyu
Browse files

css 수정 및 이미지 중첩 수정

parent 32764f1e
...@@ -42,6 +42,8 @@ export default function Profile() { ...@@ -42,6 +42,8 @@ export default function Profile() {
console.log("profile in submit", profile); console.log("profile in submit", profile);
const formdata = new FormData(); const formdata = new FormData();
profile.avatar && formdata.append("avatar", profile.avatar); profile.avatar && formdata.append("avatar", profile.avatar);
console.log(profile.avatar);
formdata.append("name", profile.name); formdata.append("name", profile.name);
console.log("form data", formdata.get("avatar")); console.log("form data", formdata.get("avatar"));
profileApi.profileUpload(formdata); profileApi.profileUpload(formdata);
......
...@@ -14,11 +14,15 @@ export default function Header() { ...@@ -14,11 +14,15 @@ export default function Header() {
}; };
return ( return (
<div className="flex flex-col md:px-56 "> <div className="flex flex-col ">
<div className="flex flex-col-reverse pt-3 pb-12 border-b-2 border-sky-200 bg-gradient-to-t from-sky-200"> <div className="flex flex-col md:px-56 z-10 ">
<div className="flex flex-col-reverse pt-3 pb-12 ">
<div className="flex mt-5 justify-between pr-3"> <div className="flex mt-5 justify-between pr-3">
<button className="ml-3 shrink-0 md:text-2xl"> <button className="ml-3 shrink-0 md:text-2xl">
<Link to="/" className="hover:text-sky-300 active:text-purple-500"> <Link
to="/"
className="hover:text-sky-300 active:text-purple-500 text-white"
>
Travel Report Travel Report
</Link> </Link>
</button> </button>
...@@ -39,7 +43,9 @@ export default function Header() { ...@@ -39,7 +43,9 @@ export default function Header() {
프로필 프로필
</Link> </Link>
<div className="border-0 border-r-2 border-black "></div> <div className="border-0 border-r-2 border-black "></div>
{user.role === "admin" ? <Link to={"/admin"}>어드민</Link> : null} {user.role === "admin" ? (
<Link to={"/admin"}>어드민</Link>
) : null}
<button <button
className="ml-2 text-xs" className="ml-2 text-xs"
onClick={() => { onClick={() => {
...@@ -74,5 +80,7 @@ export default function Header() { ...@@ -74,5 +80,7 @@ export default function Header() {
<Outlet /> <Outlet />
</div> </div>
<div className="bg-center z-0 absolute w-full h-44 overflow-hidden object-cover object-center bg-[url('https://blog.kakaocdn.net/dn/b5qUMZ/btqN9NEYqcW/ZuZmPcI4u7bdK89shT3RL1/img.jpg')]"></div>
</div>
); );
} }
...@@ -15,7 +15,7 @@ export default function Theme({ handleClick }: ThemeProps) { ...@@ -15,7 +15,7 @@ export default function Theme({ handleClick }: ThemeProps) {
}; };
return ( return (
<div className="overflow-x-auto flex rounded py-2 md:p-2 border-b-2 divide-x-2"> <div className="overflow-x-auto flex rounded py-2 md:p-4 shadow-lg divide-x-2 bg-white">
<div onClick={() => clickActive(1)}> <div onClick={() => clickActive(1)}>
<button <button
id={"surfing"} id={"surfing"}
......
...@@ -15,7 +15,7 @@ export default function Citylist({ handleClick }: CityProps) { ...@@ -15,7 +15,7 @@ export default function Citylist({ handleClick }: CityProps) {
}; };
return ( return (
<div className="overflow-auto w-full flex flex-row md:flex-col md:mr-24 bg-sky-100"> <div className="overflow-auto w-full flex flex-row md:flex-col md:mr-24 bg-red-100 shadow-lg">
<div className="text-start px-5 py-2 bg-white whitespace-nowrap"> <div className="text-start px-5 py-2 bg-white whitespace-nowrap">
도시 도시
</div> </div>
......
...@@ -2,9 +2,9 @@ import { userDb } from "../db"; ...@@ -2,9 +2,9 @@ import { userDb } from "../db";
import { asyncWrap } from "../helpers/asyncWrap"; import { asyncWrap } from "../helpers/asyncWrap";
import { Request } from "express"; import { Request } from "express";
import formidable from "formidable"; import formidable from "formidable";
import { ObjectId } from "mongoose"; import fs from "fs/promises";
import fs from "fs";
import { TypedRequest } from "../types"; import { TypedRequest } from "../types";
import { FileInfo, IUser, User } from "../models";
export interface TypedRequestAuth<T> extends Request { export interface TypedRequestAuth<T> extends Request {
auth: T; auth: T;
...@@ -36,8 +36,28 @@ export const updateProfile = asyncWrap(async (reqExp, res) => { ...@@ -36,8 +36,28 @@ export const updateProfile = asyncWrap(async (reqExp, res) => {
const { name } = req.body; const { name } = req.body;
const { avatar }: { avatar: formidable.File } = req.files; const { avatar }: { avatar: formidable.File } = req.files;
const duplicate = await FileInfo.findOne({
originalfilename: avatar.originalFilename,
}); // 같은 사진이 DB에 있는지 확인
console.log(duplicate);
if (!duplicate) {
//만약 같은 사진이 DB안에 존재하지 않을 경우
const user = await userDb.updateProfile(userId, name, avatar); const user = await userDb.updateProfile(userId, name, avatar);
res.json(user);
} else {
// 같은 사진이 DB안에 존재할 경우
await fs.unlink(avatar.filepath);
// await FileInfo.deleteOne({ _id: user?.avatar }); // 덮기 전의 FileInfo 삭제
const user = await User.findById(userId);
if (user !== null) {
user.avatar = duplicate._id;
await user.save();
}
}
// if (!Array.isArray(file.avatar)) { // if (!Array.isArray(file.avatar)) {
// //파일 좁히기 중 // //파일 좁히기 중
// if (!Array.isArray(field.nickname)) { // if (!Array.isArray(field.nickname)) {
...@@ -58,8 +78,6 @@ export const updateProfile = asyncWrap(async (reqExp, res) => { ...@@ -58,8 +78,6 @@ export const updateProfile = asyncWrap(async (reqExp, res) => {
// } // }
// } // }
// } // }
res.json(user);
}); });
export const deleteUser = asyncWrap(async (reqExp, res) => { export const deleteUser = asyncWrap(async (reqExp, res) => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment