Skip to content
Merged
4 changes: 3 additions & 1 deletion src/app/estimates/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { redirect } from "next/navigation";

import { APP_ROUTES } from "@/lib/constants/appRoutes";

// 2026.07.24 정슬기 - [추가] /estimates 진입 시 받았던 견적 목록으로 이동
export default function EstimatesIndexPage() {
redirect("/estimates/received");
redirect(APP_ROUTES.ESTIMATES.RECEIVED);
}
50 changes: 50 additions & 0 deletions src/components/auth/CustomerAuthGate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use client";

import { usePathname, useRouter } from "next/navigation";
import { useEffect, type ReactNode } from "react";

import EstimatesQueryStatus from "@/components/estimate/EstimatesQueryStatus";
import { useCustomerAuthReady } from "@/hooks/useCustomerAuthReady";
import { buildLoginPath } from "@/lib/auth/redirect";

interface CustomerAuthGateProps {
children: ReactNode;
/** 세션 확인 중 표시. 기본은 공통 로딩 메시지 */
loadingMessage?: string;
}

/**
* 고객 전용 영역 가드
* - 세션 복구 중: 로딩
* - 비로그인: 로그인 페이지로 이동 (?redirect=)
* - 기사님: 받은 견적 요청 목록으로 이동
* // 2026.07.30 정슬기 - [추가]
*/
export default function CustomerAuthGate({
children,
loadingMessage = "로그인 상태를 확인하는 중입니다.",
}: CustomerAuthGateProps) {
const router = useRouter();
const pathname = usePathname();
const { isPending, isAuthenticated, isMover, canAccess } = useCustomerAuthReady();

useEffect(() => {
if (isPending) return;

if (!isAuthenticated) {
const search = typeof window !== "undefined" ? window.location.search : "";
window.location.assign(buildLoginPath(`${pathname}${search}`));
return;
}

if (isMover) {
router.replace("/estimate/received-requests");
}
Comment thread
yooseohyeon marked this conversation as resolved.
Resolved
}, [isPending, isAuthenticated, isMover, pathname, router]);

if (isPending || !canAccess) {
return <EstimatesQueryStatus message={loadingMessage} />;
}

return children;
}
2 changes: 1 addition & 1 deletion src/components/common/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const LOGGED_OUT_LINKS = [{ label: "기사님 찾기", href: APP_ROUTES.MOVERS.R
const LOGGED_IN_LINKS = [
{ label: "견적 요청", href: APP_ROUTES.ESTIMATE_REQUEST },
{ label: "기사님 찾기", href: APP_ROUTES.MOVERS.ROOT },
{ label: "내 견적 관리", href: "/estimates" },
{ label: "내 견적 관리", href: APP_ROUTES.ESTIMATES.ROOT },
];

export interface HeaderProps {
Expand Down
39 changes: 5 additions & 34 deletions src/components/estimate/EstimateRequestSummaryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,26 @@ import type { MoveType } from "@/types/move";
export const ESTIMATE_REQUEST_DETAIL_CARD_CLASSNAME =
"border-border-subtle bg-background-surface rounded-20 flex w-full flex-col gap-24 border px-20 py-24 shadow-[0_0_10px_rgba(220,220,220,0.2)] min-[744px]:gap-32 min-[744px]:px-40 min-[744px]:py-32 lg:px-40 lg:py-32";

/** 기사님 받은 요청 목록 main과 동일한 콘텐츠 폭·여백 */
export const ESTIMATE_REQUEST_DETAIL_PAGE_CLASSNAME =
"mx-auto flex w-full max-w-[1200px] flex-col gap-24 px-24 pb-80 min-[744px]:px-[72px] lg:gap-40 lg:px-0";

export interface EstimateRequestSummaryRow {
label: string;
value: string;
}

interface EstimateRequestSummaryContentProps {
moveType: MoveType;
isDesignated: boolean;
/** 제목 (기사: 고객명 / 고객: 상태·이사유형 등) */
/** 제목 (기사: 고객명) */
title: ReactNode;
/** 우측 메타 (기사: N분 전 / 고객: 요청일 등) */
/** 우측 메타 (기사: N분 전) */
headerMeta?: ReactNode;
fromLabel: string;
toLabel: string;
moveDate: string;
/** 출발·도착·이사일 외 추가 행 (고객 상세용) */
extraRows?: EstimateRequestSummaryRow[];
className?: string;
/** 모달 요약은 타이포·간격이 약간 다름 */
density?: "card" | "modal";
}

/**
* EstimateRequest 요약 블록 — 기사님 받은 요청 카드/모달과 고객 보낸 요청 상세 공통
* EstimateRequest 요약 블록 — 기사님 받은 요청 카드·모달 전용
* (고객 보낸 요청 상세는 EstimateDetail 셸 + EstimateRequestDetailSummary 사용)
* // 2026.07.29 정슬기 - [추가]
* // 2026.07.30 정슬기 - [수정] 미사용 PAGE_CLASSNAME·extraRows 제거
*/
export default function EstimateRequestSummaryContent({
moveType,
Expand All @@ -48,7 +39,6 @@ export default function EstimateRequestSummaryContent({
fromLabel,
toLabel,
moveDate,
extraRows,
className,
density = "card",
}: EstimateRequestSummaryContentProps) {
Expand Down Expand Up @@ -135,25 +125,6 @@ export default function EstimateRequestSummaryContent({
</dl>

{isModal ? <div className="bg-border-subtle h-px" /> : null}

{extraRows && extraRows.length > 0 ? (
<dl className="flex flex-col gap-12">
{extraRows.map((row) => (
<div key={row.label} className="flex w-full items-start justify-between gap-12">
<Text as="dt" variant="md-regular" className="text-text-muted shrink-0">
{row.label}
</Text>
<Text
as="dd"
variant="lg-semibold"
className="text-text-primary m-0 min-w-0 text-right wrap-break-word"
>
{row.value}
</Text>
</div>
))}
</dl>
) : null}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { Text } from "@/components/common/Text";

interface ReceivedEstimatesStatusProps {
interface EstimatesQueryStatusProps {
message: string;
actionLabel?: string;
onAction?: () => void;
}

// 2026.07.24 정슬기 - [추가] 받은 견적 도메인 전용 로딩·빈·에러 상태 UI
export default function ReceivedEstimatesStatus({
/**
* 견적·리뷰 목록/상세 공통 로딩·에러 상태 UI
* // 2026.07.30 정슬기 - [수정] ReceivedEstimatesStatus → EstimatesQueryStatus (도메인 중립화)
*/
export default function EstimatesQueryStatus({
message,
actionLabel,
onAction,
}: ReceivedEstimatesStatusProps) {
}: EstimatesQueryStatusProps) {
return (
<div className="px-margin-mobile flex w-full flex-col items-center justify-center gap-16 py-64 md:px-0 md:py-80">
<div
className="px-margin-mobile flex w-full flex-col items-center justify-center gap-16 py-64 md:px-0 md:py-80"
role={actionLabel ? "alert" : "status"}
{...(actionLabel ? {} : { "aria-live": "polite" as const })}
>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
<Text as="p" variant="lg-regular" className="text-text-muted text-center">
{message}
</Text>
Expand Down
6 changes: 4 additions & 2 deletions src/components/estimate/EstimatesShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { usePathname } from "next/navigation";
import type { ReactNode } from "react";

import CustomerAuthGate from "@/components/auth/CustomerAuthGate";
import MyEstimateTabs from "@/components/estimate/MyEstimateTabs";

interface EstimatesShellProps {
Expand All @@ -12,6 +13,7 @@ interface EstimatesShellProps {
// 2026.07.24 정슬기 - [수정] /estimates/[estimateId] 상세에서는 목록 탭을 숨김
// 2026.07.25 정슬기 - [수정] /estimates/pending/[estimateId] 상세에서도 탭 숨김
// 2026.07.29 정슬기 - [수정] 보낸 견적 요청 목록에서도 탭 표시
// 2026.07.30 정슬기 - [수정] CustomerAuthGate로 로그인·고객 권한 연동
function shouldShowTabs(pathname: string): boolean {
return (
pathname === "/estimates/pending" ||
Expand All @@ -24,9 +26,9 @@ export default function EstimatesShell({ children }: EstimatesShellProps) {
const pathname = usePathname();

return (
<>
<CustomerAuthGate loadingMessage="견적 관리를 불러오는 중입니다.">
{shouldShowTabs(pathname) ? <MyEstimateTabs /> : null}
{children}
</>
</CustomerAuthGate>
);
}
4 changes: 2 additions & 2 deletions src/components/estimate/RejectedRequestsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Text } from "@/components/common/Text";
import MoverEstimateTabs from "@/components/estimate/MoverEstimateTabs";
import RejectedRequestCard from "@/components/estimate/RejectedRequestCard";
import ReceivedEstimatesStatus from "@/components/estimate/received/ReceivedEstimatesStatus";
import EstimatesQueryStatus from "@/components/estimate/EstimatesQueryStatus";
import { useRejectedEstimateRequests } from "@/hooks/useMoverEstimateRequests";

export default function RejectedRequestsPage() {
Expand All @@ -22,7 +22,7 @@ export default function RejectedRequestsPage() {
) : null}

{query.isError ? (
<ReceivedEstimatesStatus
<EstimatesQueryStatus
message="반려 요청을 불러오지 못했어요."
actionLabel={query.isFetching ? "다시 시도 중..." : "다시 시도"}
onAction={() => {
Expand Down
68 changes: 48 additions & 20 deletions src/components/estimate/detail/EstimateDetailActions.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
import Button from "@/components/common/Button/Button";
import { Text } from "@/components/common/Text";
import { ConfirmedCheckIcon } from "@/icons";
import { formatPrice } from "@/lib/utils/estimateFormat";

interface EstimateDetailActionsProps {
isConfirmed: boolean;
canConfirm: boolean;
confirmDisabledReason: string | null;
isConfirming: boolean;
onConfirm: () => void;
/** 대기 상세 Figma: CTA 위 견적가 재표시 */
price?: number;
/** received: sm / pending: detail */
buttonSize?: "sm" | "detail";
}

/**
* 견적 상세 확정 CTA (받았던·대기 상세 공통)
* // 2026.07.24 정슬기 - [추가]
* // 2026.07.30 정슬기 - [수정] PendingEstimateDetailActions 통합 (optional price·buttonSize)
*/
export default function EstimateDetailActions({
isConfirmed,
canConfirm,
confirmDisabledReason,
isConfirming,
onConfirm,
price,
buttonSize = "sm",
}: EstimateDetailActionsProps) {
// 2026.07.24 정슬기 - [수정] 확정 완료 시 확정 버튼을 숨기고 완료 상태만 표시
const showPrice = typeof price === "number";

const priceBlock = showPrice ? (
<div className="flex w-full flex-col gap-0">
<Text as="p" variant="2lg-semibold" className="text-text-weak">
견적가
</Text>
<Text as="p" variant="2xl-bold" className="text-text-primary">
{formatPrice(price)}
</Text>
</div>
) : null;

if (isConfirmed) {
return (
<div className="flex w-full flex-col gap-16">
{priceBlock}
<div className="flex items-center justify-center gap-6">
<ConfirmedCheckIcon className="text-icon-brand size-24 shrink-0" aria-hidden="true" />
<Text as="p" variant="2lg-semibold" className="text-text-brand">
Expand All @@ -31,31 +56,34 @@ export default function EstimateDetailActions({
);
}

// 2026.07.24 정슬기 - [추가] 확정 견적 존재 시 대기 견적 확정 버튼 비활성화
const disabled = !canConfirm || isConfirming;
const reason =
confirmDisabledReason ??
(!canConfirm ? "이미 확정된 견적이 있어 추가로 확정할 수 없습니다." : null);

return (
<div className="flex w-full flex-col gap-12">
<Button
type="button"
variant="solid"
size="sm"
fullWidth
disabled={disabled}
onClick={onConfirm}
// 2026.07.24 정슬기 - [수정] 좁은 Mobile 폭에서 min-width 오버플로우 방지
className="max-w-full min-w-0"
>
{isConfirming ? "확정 중..." : "견적 확정하기"}
</Button>
{disabled && reason ? (
<Text as="p" variant="md-regular" className="text-text-muted text-center">
{reason}
</Text>
) : null}
<div className={showPrice ? "flex w-full flex-col gap-30" : "flex w-full flex-col gap-12"}>
{priceBlock}

<div className="flex w-full flex-col gap-12">
<Button
type="button"
variant="solid"
size={buttonSize}
fullWidth
disabled={disabled}
onClick={onConfirm}
className="max-w-full min-w-0"
aria-busy={isConfirming}
>
{isConfirming ? "확정 중..." : "견적 확정하기"}
</Button>
{disabled && reason ? (
<Text as="p" variant="md-regular" className="text-text-muted text-center">
{reason}
</Text>
) : null}
</div>
</div>
);
}
Loading