(
const mapx = searchParams.get('lng');
const mapy = searchParams.get('lat');
const contentId = searchParams.get('contentId');
- const tourContentTypeId = searchParams.get(
- 'contentTypeId',
- ) as AroundContentTypeId;
const location: GeoTripLocation = {
lat: mapy ? Number(mapy) : 0,
lng: mapx ? Number(mapx) : 0,
};
- if (!location || !contentId || !tourContentTypeId) {
+ if (!location || !contentId) {
return (
필요한 정보가 부족합니다. 위치, 콘텐츠 ID, 관광지 타입을 확인해주세요.
@@ -41,7 +38,6 @@ export default function withAroundMapParams
(
{...(props as P)}
location={location}
contentId={contentId}
- tourContentTypeId={tourContentTypeId}
/>
);
};
diff --git a/src/features/shared/index.ts b/src/features/shared/index.ts
new file mode 100644
index 00000000..03a8d531
--- /dev/null
+++ b/src/features/shared/index.ts
@@ -0,0 +1,2 @@
+export * from './lib';
+export * from './ui';
diff --git a/src/features/shared/lib/index.ts b/src/features/shared/lib/index.ts
new file mode 100644
index 00000000..2de0abe5
--- /dev/null
+++ b/src/features/shared/lib/index.ts
@@ -0,0 +1 @@
+export { default as useKakaoShare } from './useKakaoShare';
diff --git a/src/features/tour/ui/single/Single.tsx b/src/features/shared/ui/ShareTrip.tsx
similarity index 96%
rename from src/features/tour/ui/single/Single.tsx
rename to src/features/shared/ui/ShareTrip.tsx
index 373a0e74..b901ce25 100644
--- a/src/features/tour/ui/single/Single.tsx
+++ b/src/features/shared/ui/ShareTrip.tsx
@@ -5,7 +5,7 @@ import { tourQueries, type TourItem } from '@/entities/tour';
import { LoadingSpinner } from '@/shared/ui';
import { TourSlide } from '@/features/tourShort';
-export default function Single() {
+export default function ShareTrip() {
const { contentId } = useParams();
const navigate = useNavigate();
diff --git a/src/features/shared/ui/SharedButtonContainer.tsx b/src/features/shared/ui/SharedButtonContainer.tsx
index 23d3998a..4d32e447 100644
--- a/src/features/shared/ui/SharedButtonContainer.tsx
+++ b/src/features/shared/ui/SharedButtonContainer.tsx
@@ -9,7 +9,7 @@ interface SharedButtonContainerProps {
export default function SharedButtonContainer({
contentId,
}: SharedButtonContainerProps) {
- const link = `${window.location.origin}/tour/single/${contentId}`;
+ const link = `${window.location.origin}/tour/share/${contentId}`;
const { shareKakao } = useKakaoShare({ contentId, link });
return (
diff --git a/src/features/shared/ui/index.ts b/src/features/shared/ui/index.ts
new file mode 100644
index 00000000..a36efd3f
--- /dev/null
+++ b/src/features/shared/ui/index.ts
@@ -0,0 +1,2 @@
+export { default as ShareTrip } from './ShareTrip';
+export { default as SharedButtonContainer } from './SharedButtonContainer';
diff --git a/src/features/tour/lib/withGeoTripParams.tsx b/src/features/tour/lib/withGeoTripParams.tsx
index 05758447..be41772a 100644
--- a/src/features/tour/lib/withGeoTripParams.tsx
+++ b/src/features/tour/lib/withGeoTripParams.tsx
@@ -1,36 +1,32 @@
-import { useSearchParams } from 'react-router-dom';
-
import { isValidTourType } from '@/features/map';
-import type { AroundContentTypeId } from '@/entities/tour';
-interface InjectedProps {
- distance: string;
- tourContentTypeId: AroundContentTypeId;
-}
+import { useLocalStorage } from '@/shared';
+import type { TourInjected } from '../types';
-export function withGeoTripParams
(
+export function withGeoTripParams
(
WrappedComponent: React.ComponentType
,
) {
- return function GeoTripWrapper(props: Omit
) {
- const [searchParams] = useSearchParams();
- const distance = searchParams.get('distance');
- const tourContentTypeId = searchParams.get('tour-type');
+ return function GeoTripWrapper(props: Omit
) {
+ const [tourInfo] = useLocalStorage('tourInfo', {
+ distance: '20000',
+ contentTypeId: '12',
+ });
- if (!distance || !tourContentTypeId) {
+ if (!tourInfo.distance || !tourInfo.contentTypeId) {
throw new Error(
'필요한 정보가 부족합니다. 거리와 관광지 타입을 확인해주세요.',
);
}
- if (!isValidTourType(tourContentTypeId)) {
+ if (!isValidTourType(tourInfo.contentTypeId)) {
throw new Error('잘못된 관광 타입입니다.');
}
return (
);
};
diff --git a/src/features/tour/types.ts b/src/features/tour/types.ts
index f17c25ed..d0b130f6 100644
--- a/src/features/tour/types.ts
+++ b/src/features/tour/types.ts
@@ -33,3 +33,8 @@ export type TourDetailImage = {
originimgurl?: string;
serialnum: string;
};
+
+export type TourInjected = {
+ distance: string;
+ contentTypeId: AroundContentTypeId;
+};
diff --git a/src/features/tourDetail/ui/TourOverview.tsx b/src/features/tourDetail/ui/TourOverview.tsx
index 41cbd17f..997483c1 100644
--- a/src/features/tourDetail/ui/TourOverview.tsx
+++ b/src/features/tourDetail/ui/TourOverview.tsx
@@ -1,10 +1,9 @@
import { useSuspenseQuery } from '@tanstack/react-query';
-import { commonSVG } from '@/assets';
-
import { BookmarkButtonContainer } from '@/features/bookmark';
import { tourQueries } from '@/entities/tour';
-import { TourTypeBadge, DistanceTimeInfo, getCopyClipBoard } from '@/shared';
+import { TourTypeBadge, DistanceTimeInfo } from '@/shared';
+import { SharedButtonContainer } from '@/features/shared';
interface TourCardProps {
distance: string;
@@ -37,10 +36,8 @@ export default function TourOverview({