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
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@amplitude/unified": "^1.1.28",
"@ncdai/react-wheel-picker": "^1.2.3",
"@next/third-parties": "^16.2.1",
"@stomp/stompjs": "^7.3.0",
"@tanstack/react-query": "^5.95.2",
Expand Down
31 changes: 11 additions & 20 deletions src/app/(main)/bookmark/_components/BookmarkPlacePreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ import { useInViewport } from "@/hooks/useInViewport";
import { usePlacePhotoUrlQuery } from "@/hooks/usePlacePhotoUrl";
import { MAIN_CARD_INNER_PADDING_X_CLASS } from "@/lib/layout-tokens";
import { handlePlacePhotoImageError } from "@/lib/places/place-photo-refresh";
import {
buildGoogleMapsPlaceUrl,
normalizeGooglePlaceResourceId,
} from "@/lib/maps";
import { cn } from "@/lib/utils";

export type BookmarkPlacePreviewCardProps = {
name: string;
address?: string;
primaryTypeDisplayName?: string;
/** 있으면 사진 클릭 시 Google Maps로 이동 */
googlePlaceId?: string;
onClick?: () => void;
onThumbnailClick?: () => void;
className?: string;
contentClassName?: string;
};
Expand All @@ -29,6 +25,7 @@ export function BookmarkPlacePreviewCard({
primaryTypeDisplayName,
googlePlaceId,
onClick,
onThumbnailClick,
className,
contentClassName,
}: BookmarkPlacePreviewCardProps) {
Expand All @@ -38,12 +35,6 @@ export function BookmarkPlacePreviewCard({
});

const rawGid = typeof googlePlaceId === "string" ? googlePlaceId.trim() : "";
const googleMapsPlaceUrl = rawGid.length
? buildGoogleMapsPlaceUrl({
placeId: normalizeGooglePlaceResourceId(rawGid),
query: name,
})
: null;

const thumbnailMedia = imageUrl ? (
// eslint-disable-next-line @next/next/no-img-element -- remote place photo URL
Expand Down Expand Up @@ -100,15 +91,15 @@ export function BookmarkPlacePreviewCard({
) : null}
</div>

{googleMapsPlaceUrl ? (
<a
{rawGid.length && onThumbnailClick ? (
<button
ref={thumbnailRef}
href={googleMapsPlaceUrl}
target="_blank"
rel="noopener noreferrer"
onClick={(e) => e.stopPropagation()}
onMouseDown={(e) => e.stopPropagation()}
aria-label={`${name} — Google Maps에서 열기`}
type="button"
onClick={(e) => {
e.stopPropagation();
onThumbnailClick();
}}
aria-label={`${name} 지도에서 보기`}
className="relative block h-[80px] w-[80px] shrink-0 cursor-pointer overflow-hidden rounded-lg bg-light-gray transition hover:brightness-105"
draggable={false}
>
Expand All @@ -119,7 +110,7 @@ export function BookmarkPlacePreviewCard({
>
<MapPin className="h-3 w-3" strokeWidth={2.4} />
</span>
</a>
</button>
) : (
<div
ref={thumbnailRef}
Expand Down
1 change: 1 addition & 0 deletions src/app/(main)/bookmark/_components/BookmarkPlaceRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export function BookmarkPlaceRow({
className="min-w-0 w-full border-0 hover:bg-gray-50 active:bg-gray-100"
contentClassName="pr-7"
onClick={onOpenDetail}
onThumbnailClick={onOpenDetail}
/>
<div
className="absolute right-[6.25rem] top-3 z-10 flex"
Expand Down
31 changes: 31 additions & 0 deletions src/app/(main)/plan/_components/itinerary/AddFromBookmarkModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import {
useCreateScheduleItem,
useRoomBookmarks,
} from "@/hooks/useRooms";
import { useOpenPlaceOnMap } from "@/hooks/useOpenPlaceOnMap";
import { AnalyticsEvents, trackAnalyticsEvent } from "@/lib/analytics/track";
import { bucketItemCount } from "@/lib/analytics/context";
import { placePreviewQueryOptions } from "@/lib/places/place-queries";
import type { PlacePreview } from "@/lib/api/places";
import type { RoomBookmark } from "@/lib/api/rooms";
import type { PlanPlace } from "@/lib/plan/types";
import { cn } from "@/lib/utils";
Expand Down Expand Up @@ -189,6 +191,32 @@ export function AddFromBookmarkModal({
],
);

const openPlaceOnMap = useOpenPlaceOnMap();
const selectedCategoryColor = categories?.find(
(c) => c.categoryId === selectedCategoryId,
)?.colorCode;

const handleOpenOnMap = useCallback(
(googlePlaceId: string, preview: PlacePreview) => {
if (busy) return;
onClose();
openPlaceOnMap(
{
name: preview.name,
category: "",
rating: null,
address: preview.formattedAddress,
googlePlaceId: googlePlaceId.trim(),
location: preview.location,
fromBookmark: true,
bookmarkCategoryColor: selectedCategoryColor,
},
{ itinerarySource: "bookmark" },
);
},
[busy, onClose, openPlaceOnMap, selectedCategoryColor],
);

return (
<div
role="presentation"
Expand Down Expand Up @@ -328,6 +356,9 @@ export function AddFromBookmarkModal({
busy && !rowAdding && "pointer-events-none opacity-60",
)}
onClick={() => void handleAddPlace(googlePlaceId)}
onThumbnailClick={() =>
handleOpenOnMap(googlePlaceId, preview)
}
/>
);
})
Expand Down
26 changes: 5 additions & 21 deletions src/app/(main)/plan/_components/itinerary/PlanPlaceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import {
import { usePlanPlaceCardPhoto } from "@/hooks/usePlanPlaceCardPhoto";
import { bucketItemCount } from "@/lib/analytics/context";
import { AnalyticsEvents, trackAnalyticsEvent } from "@/lib/analytics/track";
import {
buildGoogleMapsPlaceUrl,
normalizeGooglePlaceResourceId,
} from "@/lib/maps";
import { normalizeGooglePlaceResourceId } from "@/lib/maps";
import { PLAN_PLACE_CARD_TW } from "@/lib/layout-tokens";
import { handlePlacePhotoImageError } from "@/lib/places/place-photo-refresh";
import {
Expand Down Expand Up @@ -218,12 +215,7 @@ export function PlanPlaceCard({

const rawGooglePlaceId =
typeof place.googlePlaceId === "string" ? place.googlePlaceId.trim() : "";
const googleMapsPlaceUrl = rawGooglePlaceId.length
? buildGoogleMapsPlaceUrl({
placeId: normalizeGooglePlaceResourceId(rawGooglePlaceId),
query: place.title,
})
: null;
const hasGooglePlace = rawGooglePlaceId.length > 0;

const memoText = typeof place.memo === "string" ? place.memo.trim() : "";
const hasMemo = memoText.length > 0;
Expand Down Expand Up @@ -334,7 +326,7 @@ export function PlanPlaceCard({
/>
) : null;

if (!googleMapsPlaceUrl) {
if (!hasGooglePlace) {
return (
<div ref={thumbnailRef} className={PLAN_PLACE_CARD_TW.thumbnail}>
{media}
Expand All @@ -343,16 +335,8 @@ export function PlanPlaceCard({
}

return (
<a
<div
ref={thumbnailRef}
href={googleMapsPlaceUrl}
target="_blank"
rel="noopener noreferrer"
data-plan-card-no-drag
draggable={false}
onMouseDown={(e) => e.stopPropagation()}
onClick={(e) => e.stopPropagation()}
aria-label={`${place.title} — Google Maps에서 열기`}
className={cn(
PLAN_PLACE_CARD_TW.thumbnail,
"block cursor-pointer transition hover:brightness-105",
Expand All @@ -365,7 +349,7 @@ export function PlanPlaceCard({
>
<MapPin className="h-3 w-3" strokeWidth={2.4} />
</span>
</a>
</div>
);
})()}

Expand Down
Loading
Loading