Skip to content
Merged
42 changes: 42 additions & 0 deletions src/components/common/DetailBackButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"use client";

import { Text } from "@/components/common/Text";
import { useDetailBackNavigation } from "@/hooks/useDetailBackNavigation";
import { ArrowLeftIcon } from "@/icons";
import { cn } from "@/lib/utils/cn";

interface DetailBackButtonProps {
/** 이력이 없을 때 이동할 목록 경로 (`APP_ROUTES`) */
fallbackHref: string;
className?: string;
}

/**
* 상세 페이지 ghost 목록 이동 버튼 (← 목록으로)
* 시각 크기는 작게, 터치 영역만 min 44px 보장
* // 2026.08.03 정슬기- [추가]
*/
export default function DetailBackButton({ fallbackHref, className }: DetailBackButtonProps) {
const goBack = useDetailBackNavigation(fallbackHref);

return (
<button
type="button"
onClick={goBack}
aria-label="목록으로 이동"
className={cn(
"text-text-muted rounded-8 inline-flex min-h-44 min-w-44 items-center gap-4 self-start",
"-ml-8 px-8 py-8",
"hover:bg-background-hover",
"active:bg-background-hover",
"focus-visible:ring-border-brand focus-visible:ring-2 focus-visible:outline-none",
className,
)}
>
<ArrowLeftIcon className="size-16 shrink-0" aria-hidden="true" />
<Text as="span" variant="sm-medium" className="text-text-muted whitespace-nowrap">
목록으로
</Text>
</button>
);
}
5 changes: 4 additions & 1 deletion src/components/common/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import Image from "next/image";
import Link from "next/link";
import type { ReactNode } from "react";
import type { MouseEventHandler, ReactNode } from "react";

import { Text } from "@/components/common/Text";
import { cn } from "@/lib/utils/cn";
Expand All @@ -16,6 +16,7 @@ export interface EmptyStateProps {
buttonLabel?: string;
/** CTA 클릭 시 이동 경로 */
href?: string;
onButtonClick?: MouseEventHandler<HTMLAnchorElement>;
imageAlt?: string;
className?: string;
/**
Expand All @@ -32,6 +33,7 @@ export default function EmptyState({
description,
buttonLabel,
href,
onButtonClick,
imageAlt = "",
className,
size,
Expand Down Expand Up @@ -108,6 +110,7 @@ export default function EmptyState({
{showButton && (
<Link
href={href!}
onClick={onButtonClick}
className={cn(
"bg-background-brand hover:bg-background-brand-hover flex items-center justify-center px-16 transition-colors",
isSm
Expand Down
113 changes: 113 additions & 0 deletions src/components/common/ScrollToTopButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
"use client";

import Image from "next/image";
import { usePathname } from "next/navigation";
import { useEffect, useState } from "react";

import { Text } from "@/components/common/Text";
import { APP_ROUTES } from "@/lib/constants/appRoutes";
import { cn } from "@/lib/utils/cn";

/** Auth/프로필 등에서 쓰는 공식 컬러 캐릭터 */
const CHARACTER_SRC = "/images/profile-character.png";

/** 이 스크롤 위치(px) 이상이면 버튼 노출 (300~500 구간) */
const SCROLL_SHOW_THRESHOLD_PX = 400;

/** 로그인·회원가입·프로필·인증 화면 — Scroll To Top 미노출 */
const SCROLL_TO_TOP_HIDDEN_PATHS = new Set<string>([
APP_ROUTES.LOGIN,
APP_ROUTES.SIGN_UP,
APP_ROUTES.MOVER_LOGIN,
APP_ROUTES.MOVER_SIGN_UP,
APP_ROUTES.PROFILE,
APP_ROUTES.PROFILE_EDIT,
APP_ROUTES.MOVER_PROFILE,
]);

function shouldHideScrollToTop(pathname: string): boolean {
if (pathname.startsWith("/oauth/")) {
return true;
}
return SCROLL_TO_TOP_HIDDEN_PATHS.has(pathname);
}

/** 기사 상세(`/movers/:id`) — Mobile sticky CTA와 겹침 방지 */
function isMoverDetailPath(pathname: string): boolean {
if (pathname === APP_ROUTES.MOVERS.ROOT || pathname === APP_ROUTES.MOVERS.FAVORITES) {
return false;
}
return pathname.startsWith(`${APP_ROUTES.MOVERS.ROOT}/`);
}

/**
* 공통 Scroll To Top (캐릭터 + TOP)
* AppShell에서 1회 마운트 — 짧은 페이지·제외 경로에서는 자연스럽게 숨김
* // 2026.08.03 정슬기 - [추가]
*/
export default function ScrollToTopButton() {
const pathname = usePathname();
const [scrolledPastThreshold, setScrolledPastThreshold] = useState(false);
const hiddenByRoute = shouldHideScrollToTop(pathname);
const raiseForStickyCta = isMoverDetailPath(pathname);
const show = !hiddenByRoute && scrolledPastThreshold;

useEffect(() => {
if (hiddenByRoute) {
return;
}

const updateVisibility = () => {
setScrolledPastThreshold(window.scrollY >= SCROLL_SHOW_THRESHOLD_PX);
};

updateVisibility();
window.addEventListener("scroll", updateVisibility, { passive: true });
return () => {
window.removeEventListener("scroll", updateVisibility);
};
}, [pathname, hiddenByRoute]);

if (hiddenByRoute) {
return null;
}

return (
<button
type="button"
aria-label="맨 위로"
aria-hidden={!show}
tabIndex={show ? 0 : -1}
onClick={() => {
window.scrollTo({ top: 0, behavior: "smooth" });
}}
className={cn(
"bg-background-surface shadow-toast rounded-20 fixed z-30 flex size-64 flex-col items-center justify-center gap-2",
// Mobile 16~20 / Desktop 24~32 + Safe Area
"right-[max(1rem,env(safe-area-inset-right))] md:right-[max(1.5rem,env(safe-area-inset-right))] lg:right-[max(2rem,env(safe-area-inset-right))]",
raiseForStickyCta
? "bottom-[calc(7rem+env(safe-area-inset-bottom))] lg:bottom-[max(1.5rem,env(safe-area-inset-bottom))]"
: "bottom-[max(1rem,env(safe-area-inset-bottom))] md:bottom-[max(1.5rem,env(safe-area-inset-bottom))] lg:bottom-[max(2rem,env(safe-area-inset-bottom))]",
"transition-[opacity,transform,box-shadow] duration-200 ease-out",
"hover:shadow-notification hover:-translate-y-4",
"active:translate-y-0 active:scale-95",
"focus-visible:ring-border-brand focus-visible:ring-2 focus-visible:outline-none",
show
? "pointer-events-auto translate-y-0 opacity-100"
: "pointer-events-none translate-y-8 opacity-0",
)}
>
<Image
src={CHARACTER_SRC}
alt=""
width={40}
height={40}
className="size-40 object-contain"
aria-hidden="true"
/>
<Text as="span" variant="xs-medium" className="text-text-muted leading-none tracking-wide">
TOP
</Text>
</button>
);
}
44 changes: 30 additions & 14 deletions src/components/estimate/detail/EstimateDetailHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
"use client";

import type { ReactNode } from "react";

import DetailBackButton from "@/components/common/DetailBackButton";
import { Text } from "@/components/common/Text";

interface EstimateDetailHeaderProps {
title?: string;
/** Header 우측 액션 슬롯 (보낸 요청 취소 등). 다른 상세에는 영향 없음 */
/** 있으면 제목 위 ghost 뒤로가기 표시 */
// 2026.08.03 정슬기 - [추가]
backFallbackHref?: string;
/** Header 우측 액션 슬롯 (optional — 다른 상세 화면 무영향) */
// 2026.08.03 정슬기 - [추가] optional actions
actions?: ReactNode;
}

/**
* 견적·기사 상세 공통 페이지 헤더
* // 2026.08.03 정슬기 - [수정] optional 뒤로가기 — 제목 위 별도 행
* // 2026.08.04 정슬기 - [수정] Desktop padding/타이포를 xl로 — Tablet 가로 스크롤 방지
*/
export default function EstimateDetailHeader({
title = "견적 상세",
backFallbackHref,
actions,
}: EstimateDetailHeaderProps) {
return (
// 2026.07.24 정슬기 - [수정] Figma Mobile/Tablet 페이지 헤더 높이·여백
// 2026.08.04 정슬기 - [수정] Desktop padding/타이포를 xl로 — Tablet(lg) 과다 padding·가로 스크롤 방지
<header className="bg-background-default px-margin-mobile md:px-margin-tablet h-page-header-height-mobile md:h-page-header-height-tablet xl:h-page-header-height-desktop xl:px-page-header-padding-x-desktop flex w-full max-w-full items-center justify-center overflow-x-hidden shadow-[0_2px_10px_0_rgba(248,248,248,0.1)]">
<div className="max-w-container-desktop flex w-full min-w-0 flex-1 items-center justify-between gap-12">
<h1 className="text-text-primary min-w-0">
<Text as="span" variant="2lg-semibold" className="xl:hidden">
{title}
</Text>
<Text as="span" variant="2xl-semibold" className="hidden xl:inline">
{title}
</Text>
</h1>
{actions ? <div className="flex shrink-0 items-center">{actions}</div> : null}
// 고정 높이 대신 padding으로 두 행(뒤로+제목)을 수용 — 과도한 확장 방지
// 2026.08.04 정슬기 - [수정] Desktop padding/타이포를 xl로
<header className="bg-background-default shadow-page-header px-margin-mobile md:px-margin-tablet xl:px-page-header-padding-x-desktop flex w-full max-w-full items-center justify-center overflow-x-hidden">
<div className="max-w-container-desktop flex w-full min-w-0 flex-1 flex-col items-start gap-8 py-12 md:py-14 xl:py-16">
{backFallbackHref ? <DetailBackButton fallbackHref={backFallbackHref} /> : null}

<div className="flex w-full min-w-0 items-center justify-between gap-12">
<h1 className="text-text-primary min-w-0">
<Text as="span" variant="2lg-semibold" className="xl:hidden">
{title}
</Text>
<Text as="span" variant="2xl-semibold" className="hidden xl:inline">
{title}
</Text>
</h1>
{actions ? <div className="flex shrink-0 items-center">{actions}</div> : null}
</div>
</div>
</header>
);
Expand Down
20 changes: 17 additions & 3 deletions src/components/estimate/detail/EstimateDetailLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export const ESTIMATE_DETAIL_LAYOUT_CLASSES = {
// 본문+aside 블록을 컨테이너 안에서 가운데로 모아 좌측 치우침을 줄인다
rowClassName: "gap-32 md:gap-40 xl:justify-center xl:gap-40",
// Desktop 본문 840 + aside 320 + gap 40 = 1200 (container)
// overflow-clip 제거 — focus ring이 aside 경계에서 잘리지 않도록 폭만으로 제한
// 2026.08.04 정슬기 - [수정]
mainClassName: "gap-24 md:gap-30 xl:w-210 xl:shrink-0",
asideClassName: "gap-28 md:gap-40 xl:w-80 xl:shrink-0 xl:overflow-clip",
asideClassName: "gap-28 md:gap-40 xl:w-80 xl:shrink-0",
} as const;

interface EstimateDetailLayoutProps {
Expand All @@ -29,6 +31,9 @@ interface EstimateDetailLayoutProps {
/** Header 우측 액션 (optional — 다른 상세 화면 무영향) */
// 2026.08.03 정슬기 - [추가]
headerActions?: ReactNode;
/** 상세 Header 뒤로가기 fallback 목록 경로 */
// 2026.08.03 정슬기 - [추가]
backFallbackHref?: string;
main: ReactNode;
aside?: ReactNode;
/** main+aside 바깥 여백·폭. Figma 화면별로 다를 수 있음 */
Expand All @@ -53,6 +58,7 @@ export default function EstimateDetailLayout({
heroName = "",
showProfile = true,
headerActions,
backFallbackHref,
main,
aside,
contentClassName,
Expand All @@ -63,7 +69,11 @@ export default function EstimateDetailLayout({
}: EstimateDetailLayoutProps) {
return (
<div className="bg-background-default flex w-full max-w-full flex-col items-start overflow-x-hidden">
<EstimateDetailHeader title={title} actions={headerActions} />
<EstimateDetailHeader
title={title}
backFallbackHref={backFallbackHref}
actions={headerActions}
/>
<DetailHeroBanner imageUrl={heroImageUrl} name={heroName} showProfile={showProfile} />

<div
Expand Down Expand Up @@ -100,6 +110,9 @@ interface EstimateDetailQueryStateProps {
onAction?: () => void;
/** 에러 시 목록 링크 등 추가 액션 */
secondaryAction?: ReactNode;
/** 로딩·에러 Header 뒤로가기 fallback */
// 2026.08.03 정슬기 - [추가]
backFallbackHref?: string;
}

/** 상세 로딩·에러 — Header만 두고 상태 메시지 표시 */
Expand All @@ -109,10 +122,11 @@ export function EstimateDetailQueryState({
actionLabel,
onAction,
secondaryAction,
backFallbackHref,
}: EstimateDetailQueryStateProps) {
return (
<div className="bg-background-default flex w-full max-w-full flex-col overflow-x-hidden">
<EstimateDetailHeader title={title} />
<EstimateDetailHeader title={title} backFallbackHref={backFallbackHref} />
<div className="px-margin-mobile md:px-margin-tablet flex w-full flex-col items-center xl:px-0">
<div className="max-w-container-desktop w-full">
<EstimatesQueryStatus message={message} actionLabel={actionLabel} onAction={onAction} />
Expand Down
12 changes: 10 additions & 2 deletions src/components/estimate/detail/EstimateDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useConfirmEstimate } from "@/hooks/useConfirmEstimate";
import { useEstimateDetail } from "@/hooks/useEstimateDetail";
import { useEstimateRequestCancelFlow } from "@/hooks/useEstimateRequestCancelFlow";
import { getApiErrorMessage } from "@/lib/api/getApiErrorMessage";
import { APP_ROUTES } from "@/lib/constants/appRoutes";
import { cn } from "@/lib/utils/cn";
import { isCancelableEstimateRequestStatus } from "@/lib/utils/estimateFormat";
import type { EstimateDetail } from "@/types/estimate";
Expand Down Expand Up @@ -61,6 +62,7 @@ function EstimateDetailContent({ estimateId, data }: EstimateDetailContentProps)
rowClassName={ESTIMATE_DETAIL_LAYOUT_CLASSES.rowClassName}
mainClassName={ESTIMATE_DETAIL_LAYOUT_CLASSES.mainClassName}
asideClassName={cn(ESTIMATE_DETAIL_LAYOUT_CLASSES.asideClassName, "xl:pt-40")}
backFallbackHref={APP_ROUTES.ESTIMATES.RECEIVED}
main={
<>
<div className="flex w-full flex-col gap-20 md:gap-26">
Expand Down Expand Up @@ -120,13 +122,18 @@ function EstimateDetailContent({ estimateId, data }: EstimateDetailContentProps)
* 받았던 견적 상세
* // 2026.07.24 정슬기 - [추가]
* // 2026.07.30 정슬기 - [수정] EstimateDetailLayout·공통 Actions 사용
* // 2026.08.03 정슬기 - [수정] 레이아웃·코멘트·요청 취소 액션
* // 2026.08.03 정슬기 - [수정] 레이아웃·코멘트·요청 취소 액션 · Header 뒤로가기
*/
export default function EstimateDetailView({ estimateId }: EstimateDetailViewProps) {
const { data, isLoading, isError, error, refetch } = useEstimateDetail(estimateId);

if (isLoading) {
return <EstimateDetailQueryState message="견적 상세를 불러오는 중입니다." />;
return (
<EstimateDetailQueryState
message="견적 상세를 불러오는 중입니다."
backFallbackHref={APP_ROUTES.ESTIMATES.RECEIVED}
/>
);
}

if (isError || !data) {
Expand All @@ -137,6 +144,7 @@ export default function EstimateDetailView({ estimateId }: EstimateDetailViewPro
onAction={() => {
void refetch();
}}
backFallbackHref={APP_ROUTES.ESTIMATES.RECEIVED}
/>
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/estimate/pending/PendingEstimateCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { MoveTypeChip, DesignatedChip } from "@/components/estimate/received/Mov
import { useConfirmEstimate } from "@/hooks/useConfirmEstimate";
import { useFavoriteMover } from "@/hooks/useFavoriteMover";
import { ConfirmedCheckIcon, LikeIcon, ProfileDefaultIcon, StarIcon } from "@/icons";
import { APP_ROUTES } from "@/lib/constants/appRoutes";
import { markInternalDetailNavigationOnClick } from "@/lib/utils/detailNavigation";
import { cn } from "@/lib/utils/cn";
import {
formatPrice,
Expand Down Expand Up @@ -43,6 +45,7 @@ export default function PendingEstimateCard({
const displayName = mover.nickname || mover.name;
const intro = mover.shortIntro ?? "고객님의 물품을 안전하게 운송해 드립니다.";
const moverTitleId = `offer-${offer.id}-mover`;
const detailHref = APP_ROUTES.ESTIMATES.PENDING_DETAIL(offer.id);
// 찜: PENDING_LIST / RECEIVED / DETAIL 캐시는 useFavoriteMover가 갱신
const favoriteMutation = useFavoriteMover({ onError: onFavoriteError });
// BE mapListEstimate에는 canConfirm 없음 — SENT만 확정 후보 (pending 목록은 SENT-only)
Expand Down Expand Up @@ -226,7 +229,8 @@ export default function PendingEstimateCard({
{/* 상세: /estimates/pending/[estimateId] */}
<div className="flex w-full flex-col-reverse gap-11 md:flex-row">
<Link
href={`/estimates/pending/${offer.id}`}
href={detailHref}
onClick={(event) => markInternalDetailNavigationOnClick(event, detailHref)}
className={cn(
buttonVariants({ variant: "outline", size: "cta", fullWidth: true }),
"focus-visible:ring-border-brand focus-visible:ring-2 focus-visible:outline-none md:flex-1",
Expand Down
Loading