diff --git a/src/app/admin/components/block-list-section.tsx b/src/app/admin/components/block-list-section.tsx index 13156fe9..9fbc7487 100644 --- a/src/app/admin/components/block-list-section.tsx +++ b/src/app/admin/components/block-list-section.tsx @@ -77,26 +77,13 @@ const BlockListSection = ({ blocks, isAdmin, setBlocks }: Props) => { > ))} diff --git a/src/app/admin/components/home-menu.tsx b/src/app/admin/components/home-menu.tsx index cc747857..5ec34726 100644 --- a/src/app/admin/components/home-menu.tsx +++ b/src/app/admin/components/home-menu.tsx @@ -1,32 +1,10 @@ import React, { useState } from "react"; import Image from "next/image"; -import Link from "next/link"; -import { useRouter } from "next/navigation"; -import { ClientRoute } from "@config/route"; -import Contour from "@app/admin/(block)/components/contour"; +import UserMenu from "@app/admin/components/user-menu"; const HomeMenu = () => { const [isMenuOn, setIsMenuOn] = useState(false); - const router = useRouter(); - - async function handleLogout() { - try { - // 인증 관련 데이터 제거 - const response = await fetch("/api/logout", { - credentials: "include", - method: "POST", - }); - if (response.ok) { - alert("로그아웃 되었습니다."); - router.push(`/intro`); - } - } catch (error) { - console.error("로그아웃 중 오류 발생:", error); - alert("로그아웃 중 오류가 발생했습니다."); - } - } - return ( <> {isMenuOn && ( @@ -56,47 +34,7 @@ const HomeMenu = () => { className="h-4 w-4 sm:h-5 sm:w-5" /> - {isMenuOn && ( - - - - - Admin - - - - - - 회원 정보 조회 - - - - - - Logout - - - - - - Login - - - - - )} + {isMenuOn && } > ); diff --git a/src/app/admin/components/profile-box.tsx b/src/app/admin/components/profile-box.tsx index 7e82ee0e..910d3d32 100644 --- a/src/app/admin/components/profile-box.tsx +++ b/src/app/admin/components/profile-box.tsx @@ -74,7 +74,7 @@ const ProfileBox = ({ userId }: Props) => { {userId} - {!isAdmin && } + > ); diff --git a/src/app/admin/components/user-menu.tsx b/src/app/admin/components/user-menu.tsx new file mode 100644 index 00000000..38ae9e69 --- /dev/null +++ b/src/app/admin/components/user-menu.tsx @@ -0,0 +1,72 @@ +import React from "react"; +import Link from "next/link"; +import { usePathname, useRouter } from "next/navigation"; + +import { ClientRoute } from "@config/route"; +import Contour from "@app/admin/(block)/components/contour"; + +const UserMenu = () => { + const router = useRouter(); + const pathname = usePathname(); + const isAdmin = pathname === "/admin"; + async function handleLogout() { + try { + // 인증 관련 데이터 제거 + const response = await fetch("/api/logout", { + credentials: "include", + method: "POST", + }); + if (response.ok) { + alert("로그아웃 되었습니다."); + router.push(`/`); + } + } catch (error) { + console.error("로그아웃 중 오류 발생:", error); + alert("로그아웃 중 오류가 발생했습니다."); + } + } + return ( + + + + isAdmin && router.back()} + className="block w-full rounded-md px-2 py-1 transition-colors duration-200 hover:bg-gray-100 dark:hover:bg-gray-800" + > + {isAdmin ? "Profile Main" : "Admin"} + + + + + + 회원 정보 조회 + + + + + + Logout + + + + + + Login + + + + + ); +}; + +export default UserMenu; diff --git a/src/app/home/components/header.tsx b/src/app/home/components/header.tsx index 93912988..3b70cdab 100644 --- a/src/app/home/components/header.tsx +++ b/src/app/home/components/header.tsx @@ -3,35 +3,26 @@ import Link from "next/link"; const Header = () => { return ( - + linkle - + 트렌딩 - + 최신 - + 피드 - + 이번 주 이번 달 올해 diff --git a/src/components/basicblock.tsx b/src/components/basicblock.tsx index 46f80fc4..7f10f769 100644 --- a/src/components/basicblock.tsx +++ b/src/components/basicblock.tsx @@ -1,7 +1,7 @@ "use client"; import Image from "next/image"; -import { useState } from "react"; +import React, { useState } from "react"; import DivideBlock from "@app/admin/components/divide-block"; import VideoBlock from "@app/admin/components/video-block"; @@ -11,45 +11,29 @@ import TextBlock from "@app/admin/components/text-block"; import CalendarBlock from "@app/admin/components/calendar-block"; import LinkBlock from "@app/admin/components/link-block"; import ToggleButton from "@components/UI/toggle-button"; +import { Block } from "@/types/apis"; -interface Block { - id: number; - type: number; - sequence: number; - style: number | null; - title: string | null; - subText01: string | null; - subText02: string | null; - url: string; - imgUrl: string | null; - dateStart: string | null; - dateEnd: string | null; - openYn: "Y" | "N"; - keepYn: "Y" | "N"; - dateCreate: string; - dateUpdate: string | null; +interface Props { + block: Block; index: number; - dragStart: (position: number) => void; - dragEnter: (position: number) => void; + dragStart: (index: number) => void; + dragEnter: (index: number) => void; drop: () => void; isAdmin: boolean; + setBlocks: React.Dispatch>; } + export default function BasicBlock({ - id, - type, - sequence, - style, - title, - url, - imgUrl, - dateStart, - dateEnd, + block, index, dragStart, dragEnter, drop, isAdmin, -}: Block) { + setBlocks, +}: Props) { + const { id, type, sequence, style, title, url, imgUrl, dateStart, dateEnd } = + block; const [isOpen, setIsOpen] = useState(false); function toggleMenu() { @@ -122,7 +106,6 @@ export default function BasicBlock({ } async function deleteHandler() { - console.log(id); try { const response = await fetch(`/api/link/delete`, { credentials: "include", @@ -137,6 +120,7 @@ export default function BasicBlock({ if (!response.ok) { alert("삭제 실패"); } else { + setBlocks((prev) => prev.filter((block) => block.id !== id)); alert("삭제 성공"); } } catch (error) { diff --git a/src/config/route.tsx b/src/config/route.tsx index 08bfa803..b0aa29af 100644 --- a/src/config/route.tsx +++ b/src/config/route.tsx @@ -8,6 +8,7 @@ export const ClientRoute: ClientRouteType = { ADMIN: "/admin", // 관리자 페이지 MY: "/admin/my", // 개인 페이지 PROFILE: { + DEFAULT: "/profile", // 프로필 페이지 DETAIL: "/profile/detail", // 프로필 상세 페이지 EDIT: "/profile/edit", // 프로필 수정 페이지 }, diff --git a/src/config/types.tsx b/src/config/types.tsx index 832d8e82..d987800c 100644 --- a/src/config/types.tsx +++ b/src/config/types.tsx @@ -7,6 +7,7 @@ const ClientRouteTypeSchema = z.object({ ADMIN: z.string(), MY: z.string(), PROFILE: z.object({ + DEFAULT: z.string(), DETAIL: z.string(), EDIT: z.string(), }),