Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app/(public)/search/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SearchScreen } from "@/screens/search";

export default function Page() {
return <SearchScreen />;
}
1 change: 1 addition & 0 deletions src/screens/search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SearchScreen } from "./ui/search-screen";
65 changes: 65 additions & 0 deletions src/screens/search/ui/search-screen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"use client";

import { useEffect, useState } from "react";

import { useRouter } from "next/navigation";

import { ROUTES } from "@/shared/config/routes";
import SearchInput from "@/shared/ui/input/search-input";
import { SubHeader } from "@/widgets/sub-header/sub-header";

export function SearchScreen() {
const router = useRouter();
const [query, setQuery] = useState("");

useEffect(() => {
const mediaQuery = window.matchMedia("(min-width: 1024px)");

const handleChange = () => {
if (mediaQuery.matches) {
router.replace(ROUTES.auctions);
}
};

handleChange();
mediaQuery.addEventListener("change", handleChange);

return () => {
mediaQuery.removeEventListener("change", handleChange);
};
}, [router]);

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
const trimmed = query.trim();
if (!trimmed) return;

const params = new URLSearchParams();
params.set("query", trimmed);
router.push(`${ROUTES.auctions}?${params.toString()}`);
};

return (
<div className="bg-background flex min-h-screen w-full flex-col lg:hidden">
<SubHeader
content={
<form className="w-full" onSubmit={handleSubmit}>
<SearchInput
value={query}
onChange={(event) => setQuery(event.target.value)}
onDelete={() => setQuery("")}
placeholder="검색어를 입력해주세요"
/>
</form>
}
/>

<main className="flex-1 px-4 pb-6">
<section className="pt-4">
<h2 className="text-sm font-semibold">최근 검색어</h2>
<div className="mt-3 min-h-24" />
</section>
</main>
</div>
);
}
10 changes: 6 additions & 4 deletions src/widgets/bottom-nav/model/item.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { House, Search, Plus, Bell, User } from "lucide-react";
import { House, Search, Plus, MessageCircle, User } from "lucide-react";

import { ROUTES } from "@/shared/config/routes";

import type { LucideIcon } from "lucide-react";

export const BOTTOM_NAV_ITEMS = [
{ id: "home", label: "홈", href: "/", icon: House },
{ id: "search", label: "검색", href: "/search", icon: Search },
{ id: "create", label: "등록", href: "/auctions/create", icon: Plus },
{ id: "notification", label: "알림", href: "/notifications", icon: Bell },
{ id: "profile", label: "내정보", href: "/users/me", icon: User },
{ id: "create", label: "등록", href: ROUTES.auctionCreate, icon: Plus },
{ id: "chat", label: "채팅", href: "/dm", icon: MessageCircle },
{ id: "mypage", label: "내정보", href: ROUTES.myPage, icon: User },
] as const;

export type BottomNavIdType = (typeof BOTTOM_NAV_ITEMS)[number]["id"];
Expand Down
16 changes: 9 additions & 7 deletions src/widgets/bottom-nav/ui/bottom-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import { usePathname } from "next/navigation";

import { BOTTOM_NAV_ITEMS, BottomNavIdType } from "@/widgets/bottom-nav/model/item";
import { BOTTOM_NAV_ITEMS } from "@/widgets/bottom-nav/model/item";
import { BottomNavItem } from "@/widgets/bottom-nav/ui/bottom-nav-item";

export function BottomNav() {
const pathname = usePathname();

// TODO: 알림 연결 후 하드 코딩 삭제
const hasNotificationsById: Partial<Record<BottomNavIdType, boolean>> = {
notification: true,
};
// // TODO: 알림 연결 후 하드 코딩 삭제
// const hasNotificationsById: Partial<Record<BottomNavIdType, boolean>> = {
// notification: true,
// };

return (
<nav
Expand All @@ -23,8 +23,10 @@ export function BottomNav() {
<BottomNavItem
key={item.id}
{...item}
isActive={pathname === item.href}
hasNotification={!!hasNotificationsById[item.id]}
isActive={
item.id === "mypage" ? pathname.startsWith("/users/me") : pathname === item.href
}
// hasNotification={!!hasNotificationsById[item.id]}
/>
))}
</ul>
Expand Down
7 changes: 4 additions & 3 deletions src/widgets/header/ui/header-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Link from "next/link";

import { Bell, Plus } from "lucide-react";
import { Plus } from "lucide-react";

import { ROUTES } from "@/shared/config/routes";
import { Button } from "@/shared/ui";
Expand Down Expand Up @@ -30,10 +30,11 @@ export default function HeaderActions({
</Link>
</Button>

<Button aria-label="알림" size="icon-lg" variant="ghost" className="relative">
{/* TODO: 알림 기능 복구 시 다시 노출 */}
{/* <Button aria-label="알림" size="icon-lg" variant="ghost" className="relative">
<Bell className="size-5" />
<span className="absolute top-1 right-1 h-2 w-2 rounded-full bg-red-500" />
</Button>
</Button> */}

<HeaderUserMenu avatarUrl={avatarUrl} avatarAlt={avatarAlt} />
</div>
Expand Down
1 change: 0 additions & 1 deletion src/widgets/header/ui/header-user-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default function HeaderUserMenu({ avatarUrl, avatarAlt }: HeaderUserMenuP
showToast.error("로그아웃에 실패했습니다. 잠시 후 다시 시도해주세요.");
} finally {
queryClient.setQueryData(userKeys.basic(), null);
queryClient.removeQueries({ queryKey: userKeys.all, exact: false });
router.refresh();
router.push(ROUTES.login);
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/sub-header/sub-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function SubHeader({ content = "", className, ...props }: SubHeaderProps)
const router = useRouter();

return (
<header className={cn("w-full md:hidden", className)} {...props}>
<header className={cn("w-full lg:hidden", className)} {...props}>
<div className="h-header flex items-center gap-3 px-2.5">
<Button variant="ghost" size="icon-lg" aria-label="뒤로가기" onClick={() => router.back()}>
<ChevronLeft />
Expand Down