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
2 changes: 0 additions & 2 deletions src/app/router/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import { Home } from '@/pages/home';
import { GeoTrip } from '@/pages/tour/geotrip';
import { Bookmark } from '@/pages/tour/bookmark';
import { GeoSetup } from '@/pages/geoSetup';
import { Tour } from '@/pages/tour';
import { Profile } from '@/pages/profile';

Expand All @@ -23,7 +22,6 @@ export default function Router() {
<Suspense fallback={<LoadingSpinner centered />}>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/geo-setup" element={<GeoSetup />} />
<Route path="/map" element={<Map />}>
<Route path="destination" element={<Destination />} />
<Route path="around-search" element={<AroundSearch />} />
Expand Down
41 changes: 41 additions & 0 deletions src/features/navigate/lib/useDestination.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useStore } from 'zustand';
import {
useFollowAlongStore,
useMapLevelStore,
useTransportationStore,
} from '.';
import { useSearchParams } from 'react-router-dom';
import { useEffect } from 'react';
import { getSuspenseLocation } from '@/shared';
import type { TransportationType } from '@/entities/navigate';

const useDestination = () => {
const [searchParams] = useSearchParams();

const { reset: resetFollowAlong } = useStore(useFollowAlongStore);
const { reset: resetTransportation, setVehicle } = useStore(
useTransportationStore,
);
const { reset: resetMapLevel } = useStore(useMapLevelStore);

//이동수단
const vehicle = searchParams.get('vehicle');

useEffect(() => {
setVehicle(vehicle as TransportationType);
}, [vehicle]);

const geoLocation = getSuspenseLocation();

useEffect(() => {
return () => {
resetTransportation();
resetMapLevel();
resetFollowAlong();
};
}, [resetFollowAlong, resetTransportation, resetMapLevel]);

return { geoLocation };
};

export default useDestination;
18 changes: 18 additions & 0 deletions src/features/navigate/lib/useGettingLocation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useSearchParams } from 'react-router-dom';

const useGettingLocation = () => {
const [searchParams] = useSearchParams();

//좌표
const lng = searchParams.get('lnt');
const lat = searchParams.get('lat');

const destination = {
lng: lng ? parseFloat(lng) : 0,
lat: lat ? parseFloat(lat) : 0,
};

return { destination };
};

export default useGettingLocation;
65 changes: 16 additions & 49 deletions src/features/navigate/lib/withDestination.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import { Suspense, useEffect } from 'react';
import { Suspense } from 'react';
import { useStore } from 'zustand';
import { useSearchParams } from 'react-router-dom';

import {
useFollowAlongStore,
useMapLevelStore,
useTransportationStore,
SelectTransportationFromGeoMap,
isValidationLocation,
DepartureAndArrivalAddress,
DestinationSkeleton,
} from '@/features/navigate';
import {
getSuspenseLocation,
LoadingSpinner,
QueryErrorBoundary,
} from '@/shared';
import { LoadingSpinner, QueryErrorBoundary } from '@/shared';

import type { GeoTripLocation } from '@/shared';
import type { TransportationType } from '@/entities/navigate';
import useGettingLocation from './useGettingLocation';
import useDestination from './useDestination';

interface WithDestinationProps {
start: GeoTripLocation;
Expand All @@ -31,43 +26,13 @@ export default function withDestination<P extends WithDestinationProps>(
return function GeoDestinationMapWrapper(
props: Omit<P, keyof WithDestinationProps>,
) {
const { isFollowAlong, reset: resetFollowAlong } =
useStore(useFollowAlongStore);
const { reset: resetTransportation, setVehicle } = useStore(
useTransportationStore,
);
const { reset: resetMapLevel } = useStore(useMapLevelStore);
const { isFollowAlong } = useStore(useFollowAlongStore);
const { geoLocation } = useDestination();
const { destination } = useGettingLocation();
const [searchParams] = useSearchParams();

//좌표
const lng = searchParams.get('lnt');
const lat = searchParams.get('lat');

const destination = {
lng: lng ? parseFloat(lng) : 0,
lat: lat ? parseFloat(lat) : 0,
};

//컨텐츠 ID, Type
const id = searchParams.get('id') && atob(searchParams.get('id') as string);

//이동수단
const vehicle = searchParams.get('vehicle');

useEffect(() => {
setVehicle(vehicle as TransportationType);
}, [vehicle]);

const geoLocation = getSuspenseLocation();

useEffect(() => {
return () => {
resetTransportation();
resetMapLevel();
resetFollowAlong();
};
}, [resetFollowAlong, resetTransportation, resetMapLevel]);

if (
!isValidationLocation(geoLocation) ||
!isValidationLocation(destination) ||
Expand All @@ -88,13 +53,15 @@ export default function withDestination<P extends WithDestinationProps>(
<SelectTransportationFromGeoMap />
</div>
)}
<Suspense fallback={<LoadingSpinner centered={true} />}>
<WrappedComponent
{...(props as P)}
start={geoLocation}
end={destination}
/>
</Suspense>
<QueryErrorBoundary>
<Suspense fallback={<LoadingSpinner centered={true} />}>
<WrappedComponent
{...(props as P)}
start={geoLocation}
end={destination}
/>
</Suspense>
</QueryErrorBoundary>
</>
);
};
Expand Down
10 changes: 7 additions & 3 deletions src/features/navigate/ui/GeoDestinationMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ import {
useTransportationStore,
withDestination,
} from '@/features/navigate';
import { Car } from '@/features/car';
import { Pedestrian } from '@/features/pedestrian';
import { PublicTransit } from '@/features/publicTransit';
import { LoadingSpinner } from '@/shared';

import type { GeoTripLocation } from '@/shared';
import { lazy } from 'react';

interface GeoDestinationMapProps {
start: GeoTripLocation;
end: GeoTripLocation;
}

const Pedestrian = lazy(() => import('@/features/pedestrian/ui/Pedestrian'));
const Car = lazy(() => import('@/features/car/ui/Car'));
const PublicTransit = lazy(
() => import('@/features/publicTransit/ui/PublicTransit'),
);

function GeoDestinationMap({ start, end }: GeoDestinationMapProps) {
const { vehicle } = useStore(useTransportationStore);

Expand Down
6 changes: 3 additions & 3 deletions src/features/navigate/ui/ResizingMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useTransportationStore,
} from '@/features/navigate';

import { getSuspenseLocation, type GeoTripLocation } from '@/shared';
import { Button, getSuspenseLocation, type GeoTripLocation } from '@/shared';

interface ResizingMapProps {
points: GeoTripLocation[];
Expand Down Expand Up @@ -68,12 +68,12 @@ export default function ResizingMap({
>
모든 경로 보기
</button>
<button
<Button
onClick={goToMyLocation}
className="fill-black border-black border-1 w-10 h-10 bg-white rounded-full flex items-center justify-center cursor-pointer z-(--z-layer2)"
>
<destinationSVG.MyLocationIcon />
</button>
</Button>
</div>
</>
);
Expand Down
11 changes: 0 additions & 11 deletions src/pages/geoSetup/GeoSetup.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions src/pages/geoSetup/components/FooterButton.tsx

This file was deleted.

36 changes: 0 additions & 36 deletions src/pages/geoSetup/components/SetupButton.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions src/pages/geoSetup/components/SetupButtonList.tsx

This file was deleted.

74 changes: 0 additions & 74 deletions src/pages/geoSetup/components/SetupContainer.tsx

This file was deleted.

Loading