Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
37 changes: 14 additions & 23 deletions src/components/estimate/detail/EstimateDetailDriverSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { Text } from "@/components/common/Text";
import { MoveTypeChip } from "@/components/common/Chip/MoveTypeChip";
import DesignatedChip from "@/components/estimate/DesignatedChip";
import { FavoriteButton } from "@/components/mover/FavoriteButton";
import { useFavoriteMover } from "@/hooks/useFavoriteMover";
import { ConfirmedCheckIcon, LikeIcon, StarIcon } from "@/icons";
import { cn } from "@/lib/utils/cn";
import { ConfirmedCheckIcon, StarIcon } from "@/icons";
import { formatRating } from "@/lib/utils/estimateFormat";
import type { EstimateDetail } from "@/types/estimate";

Expand Down Expand Up @@ -89,27 +89,18 @@ export default function EstimateDetailDriverSummary({
<Text as="p" variant="2lg-semibold" className="text-text-primary min-w-0 wrap-break-word">
{displayName} 기사님
</Text>
<button
type="button"
className="focus-visible:ring-border-brand rounded-8 flex min-h-44 min-w-44 shrink-0 items-center justify-center gap-4 px-4 py-2 focus-visible:ring-2 focus-visible:outline-none disabled:opacity-60"
aria-label={`${displayName} 기사님 찜, 현재 찜 ${mover.favoriteCount}개`}
aria-pressed={mover.isFavorite}
disabled={favoriteMutation.isPending}
onClick={() =>
favoriteMutation.mutate({
moverId: mover.id,
nextIsFavorite: !mover.isFavorite,
})
}
>
<Text as="span" variant="2lg-medium" className="text-text-muted" aria-hidden="true">
{mover.favoriteCount}
</Text>
<LikeIcon
isFavorite={mover.isFavorite}
className={cn("size-24", mover.isFavorite ? "text-text-brand" : "text-icon-default")}
/>
</button>
<FavoriteButton
moverName={displayName}
isFavorite={mover.isFavorite}
favoriteCount={mover.favoriteCount}
showCount
countPosition="before"
countVariant="2lg-medium"
className="min-h-44 min-w-44 justify-center gap-4 px-4 py-2"
onToggle={(nextIsFavorite) => {
favoriteMutation.mutate({ moverId: mover.id, nextIsFavorite });
}}
/>
</div>

<div className="flex flex-wrap items-center gap-x-8 gap-y-4">
Expand Down
40 changes: 11 additions & 29 deletions src/components/estimate/pending/PendingEstimateCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import Button, { buttonVariants } from "@/components/common/Button/Button";
import { Text } from "@/components/common/Text";
import { MoveTypeChip } from "@/components/common/Chip/MoveTypeChip";
import DesignatedChip from "@/components/estimate/DesignatedChip";
import { FavoriteButton } from "@/components/mover/FavoriteButton";
import { useConfirmEstimate } from "@/hooks/useConfirmEstimate";
import { useFavoriteMover } from "@/hooks/useFavoriteMover";
import { ConfirmedCheckIcon, LikeIcon, ProfileDefaultIcon, StarIcon } from "@/icons";
import { ConfirmedCheckIcon, ProfileDefaultIcon, StarIcon } from "@/icons";
import { APP_ROUTES } from "@/lib/constants/appRoutes";
import { markInternalDetailNavigationOnClick } from "@/lib/utils/detailNavigation";
import { cn } from "@/lib/utils/cn";
Expand Down Expand Up @@ -141,35 +142,16 @@ export default function PendingEstimateCard({
{displayName} 기사님
</Text>
</div>
<button
type="button"
className="focus-visible:ring-border-brand rounded-8 flex shrink-0 items-center gap-2 focus-visible:ring-2 focus-visible:outline-none disabled:opacity-60"
aria-label={`${displayName} 기사님 찜, 현재 찜 ${mover.favoriteCount}개`}
aria-pressed={mover.isFavorite}
disabled={favoriteMutation.isPending}
onClick={() => {
favoriteMutation.mutate({
moverId: mover.id,
nextIsFavorite: !mover.isFavorite,
});
<FavoriteButton
moverName={displayName}
isFavorite={mover.isFavorite}
favoriteCount={mover.favoriteCount}
showCount
className="gap-2"
onToggle={(nextIsFavorite) => {
favoriteMutation.mutate({ moverId: mover.id, nextIsFavorite });
}}
>
<LikeIcon
isFavorite={mover.isFavorite}
className={cn(
"size-24",
mover.isFavorite ? "text-text-brand" : "text-icon-default",
)}
/>
<Text
as="span"
variant="md-regular"
className="text-text-muted"
aria-hidden="true"
>
{mover.favoriteCount}
</Text>
</button>
/>
</div>

<div className="flex w-full flex-wrap items-center gap-x-8 gap-y-4">
Expand Down
39 changes: 12 additions & 27 deletions src/components/estimate/received/EstimateOfferCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import Link from "next/link";
import { Text } from "@/components/common/Text";
import { MoveTypeChip } from "@/components/common/Chip/MoveTypeChip";
import DesignatedChip from "@/components/estimate/DesignatedChip";
import { FavoriteButton } from "@/components/mover/FavoriteButton";
import { useFavoriteMover } from "@/hooks/useFavoriteMover";
import { ConfirmedCheckIcon, LikeIcon, ProfileDefaultIcon, StarIcon } from "@/icons";
import { ConfirmedCheckIcon, ProfileDefaultIcon, StarIcon } from "@/icons";
import { APP_ROUTES } from "@/lib/constants/appRoutes";
import { markInternalDetailNavigationOnClick } from "@/lib/utils/detailNavigation";
import { cn } from "@/lib/utils/cn";
Expand Down Expand Up @@ -173,32 +174,16 @@ export default function EstimateOfferCard({
</div>
</Link>

{/* 2026.07.24 정슬기 - [추가] 찜 버튼을 Link 바깥 독립 버튼으로 연결 */}
<button
type="button"
className="focus-visible:ring-border-brand rounded-8 flex min-h-44 min-w-44 shrink-0 items-center justify-center gap-2 px-4 py-2 focus-visible:ring-2 focus-visible:outline-none disabled:opacity-60"
aria-label={`${displayName} 기사님 찜, 현재 찜 ${mover.favoriteCount}개`}
aria-pressed={mover.isFavorite}
disabled={favoriteMutation.isPending}
onClick={() =>
favoriteMutation.mutate({
moverId: mover.id,
nextIsFavorite: !mover.isFavorite,
})
}
>
{/* 2026.07.24 정슬기 - [수정] 찜 상태를 LikeIcon isFavorite로 전달해 채움 표시 */}
<LikeIcon
isFavorite={mover.isFavorite}
className={cn(
"size-24",
mover.isFavorite ? "text-text-brand" : "text-icon-default",
)}
/>
<Text as="span" variant="md-regular" className="text-text-muted" aria-hidden="true">
{mover.favoriteCount}
</Text>
</button>
<FavoriteButton
moverName={displayName}
isFavorite={mover.isFavorite}
favoriteCount={mover.favoriteCount}
showCount
className="min-h-44 min-w-44 justify-center gap-2 px-4 py-2"
onToggle={(nextIsFavorite) => {
favoriteMutation.mutate({ moverId: mover.id, nextIsFavorite });
}}
/>
</div>
</div>

Expand Down
96 changes: 96 additions & 0 deletions src/components/mover/FavoriteButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"use client";

import type { MouseEvent } from "react";

import { Text, type ResponsiveTextVariant, type TextVariant } from "@/components/common/Text";
import { LikeIcon } from "@/icons";
import { cn } from "@/lib/utils/cn";

interface FavoriteButtonProps {
moverName: string;
isFavorite: boolean;
favoriteCount?: number;
showCount?: boolean;
interactive?: boolean;
countPosition?: "before" | "after";
countVariant?: TextVariant | ResponsiveTextVariant;
className?: string;
iconClassName?: string;
countClassName?: string;
onToggle?: (nextIsFavorite: boolean) => void;
}

/** 기사님 찜 하트·개수 표시와 토글 접근성을 통일하는 공통 버튼 */
export function FavoriteButton({
moverName,
isFavorite,
favoriteCount,
showCount = false,
interactive = true,
countPosition = "after",
countVariant = "md-regular",
className,
iconClassName = "size-24",
countClassName,
onToggle,
}: FavoriteButtonProps) {
const icon = (
<LikeIcon
isFavorite={isFavorite}
className={cn(
iconClassName,
isFavorite ? "text-like-active-fill" : "text-like-default-stroke",
)}
/>
);
const count =
showCount && favoriteCount !== undefined ? (
<Text
as="span"
variant={countVariant}
className={cn("text-text-muted", countClassName)}
aria-hidden="true"
>
{favoriteCount}
</Text>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
) : null;
const content = (
<>
{countPosition === "before" ? count : icon}
{countPosition === "before" ? icon : count}
</>
);

if (!interactive || !onToggle) {
return (
<div
className={cn("flex shrink-0 items-center", className)}
role="group"
aria-label={`${moverName} 기사님 현재 찜 ${favoriteCount ?? 0}개`}
>
{content}
</div>
);
}

const handleClick = (event: MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
event.stopPropagation();
onToggle(!isFavorite);
};

return (
<button
type="button"
className={cn(
"focus-visible:ring-border-brand rounded-8 flex shrink-0 cursor-pointer items-center focus-visible:ring-2 focus-visible:outline-none",
className,
)}
aria-label={`${moverName} 기사님 찜`}
aria-pressed={isFavorite}
onClick={handleClick}
>
{content}
</button>
);
}
Loading