From 12513e52b8ad173059e9bc21631960673c61c81a Mon Sep 17 00:00:00 2001 From: ghdtnals Date: Thu, 11 Dec 2025 12:27:20 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=97=A4=EB=8D=94=EC=97=90=20=ED=8C=90?= =?UTF-8?q?=EB=A7=A4=ED=95=98=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/icons/sell.svg | 7 +++++ .../createPost/lib/useOpenCreatePost.ts | 23 ++++++++++++++ src/widgets/header/ui/HeaderDesktop.tsx | 28 +++++++++++++++-- src/widgets/header/ui/MobileSideMenu.tsx | 30 +++++++++++++------ 4 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 public/icons/sell.svg create mode 100644 src/features/createPost/lib/useOpenCreatePost.ts diff --git a/public/icons/sell.svg b/public/icons/sell.svg new file mode 100644 index 00000000..d9c6a9f5 --- /dev/null +++ b/public/icons/sell.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/features/createPost/lib/useOpenCreatePost.ts b/src/features/createPost/lib/useOpenCreatePost.ts new file mode 100644 index 00000000..13bc5f35 --- /dev/null +++ b/src/features/createPost/lib/useOpenCreatePost.ts @@ -0,0 +1,23 @@ +"use client"; + +import { useRouter } from "next/navigation"; +import { useAuthStore } from "@/features/auth/model/auth.store"; +import { usePostCreateModal } from "./usePostCreateModal"; + +export const useOpenCreatePostWithAuth = () => { + const router = useRouter(); + const isLogined = useAuthStore((state) => state.isLogined); + + const { openPostCreateModal } = usePostCreateModal(); + + const handleOpen = () => { + if (!isLogined) { + router.push("/login"); + return; + } + + openPostCreateModal(); + }; + + return { handleOpen }; +}; diff --git a/src/widgets/header/ui/HeaderDesktop.tsx b/src/widgets/header/ui/HeaderDesktop.tsx index ca51edf0..77fb9964 100644 --- a/src/widgets/header/ui/HeaderDesktop.tsx +++ b/src/widgets/header/ui/HeaderDesktop.tsx @@ -1,7 +1,9 @@ "use client"; import Link from "next/link"; +import { usePathname } from "next/navigation"; import SearchForm from "./SearchForm"; +import { useOpenCreatePostWithAuth } from "@/features/createPost/lib/useOpenCreatePost"; interface HeaderDesktopProps { isLogined: boolean; @@ -23,6 +25,11 @@ const HeaderDesktop = ({ navItems, onOpenChat, }: HeaderDesktopProps) => { + const pathname = usePathname(); + const { handleOpen } = useOpenCreatePostWithAuth(); + + const hideSellButton = pathname.startsWith("/my"); + return (
@@ -34,6 +41,23 @@ const HeaderDesktop = ({ {isLogined ? (
    + {!hideSellButton && ( +
  • + +
  • + )} + {navItems.map(({ href, label, icon, hasDivider }) => (
  • - {href === "/chat" && onOpenChat ? ( + {href === "/chat" ? (
  • -
  • - {/* - 분석하기 - */} -
  • + {!hideSellButton && ( +
  • + +
  • + )}
  • +