Skip to content

Commit 6baa5dc

Browse files
committed
Merge branch 'findme-geolocation' of https://github.com/map-of-pi/map-of-pi-frontend-react into findme-geolocation
2 parents da1e89e + 4b877bd commit 6baa5dc

File tree

6 files changed

+13
-27
lines changed

6 files changed

+13
-27
lines changed

.env.development

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ NEXT_PUBLIC_API_URL=http://localhost:8001/api/v1
88
NEXT_PUBLIC_PI_SDK_URL=https://sdk.minepi.com/pi-sdk.js
99

1010
NEXT_PUBLIC_SENTRY_DSN="ADD YOUR SENTRY DSN"
11-
NEXT_PUBLIC_IMAGE_PLACEHOLDER_URL='/path/to/default/image.png'
11+
NEXT_PUBLIC_IMAGE_PLACEHOLDER_URL="ADD YOUR IMAGE PLACEHOLDER URL"

src/app/[locale]/page.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import { useContext, useEffect, useState, useRef } from 'react';
1010
import { Button } from '@/components/shared/Forms/Buttons/Buttons';
1111
import SearchBar from '@/components/shared/SearchBar/SearchBar';
1212
import { fetchSellers } from '@/services/sellerApi';
13-
import { fetchUserLocation, fetchUserSettings } from '@/services/userSettingsApi';
13+
import { fetchUserSettings } from '@/services/userSettingsApi';
1414
import { DeviceLocationType, IUserSettings } from '@/constants/types';
15+
import { userLocation } from '@/utils/geolocation';
1516

1617
import { AppContext } from '../../../context/AppContextProvider';
1718
import logger from '../../../logger.config.mjs';
18-
import { userLocation } from '@/utils/resolveUserLocation';
1919

2020
export default function Index() {
2121
const t = useTranslations();
@@ -37,9 +37,6 @@ export default function Index() {
3737

3838
const { isSigningInUser, currentUser, autoLoginUser, reload, setReload } = useContext(AppContext);
3939

40-
// Default map center (example: New York City)
41-
const defaultMapCenter = { lat: 20, lng: -74.006 };
42-
4340
useEffect(() => {
4441
setReload(false)
4542
if (!currentUser) {

src/components/shared/map/Map.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ const Map = ({
245245
setLocationError(false);
246246
if (center) {
247247
map.setView(center, zoom, { animate: false });
248-
// setInitialLocationSet(true);
249-
// setIsLocationAvailable(true);
250248
}
251249
},
252250
locationerror() {
@@ -340,10 +338,6 @@ const Map = ({
340338
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
341339
noWrap={true}
342340
/>
343-
{/* <Marker
344-
position={center as LatLngExpression}
345-
icon={crosshairIcon}
346-
></Marker> */}
347341
<LocationMarker />
348342
{sellers.map((seller) => (
349343
<Marker

src/components/shared/sidebar/sidebar.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ function Sidebar(props: any) {
251251
logger.info('User Settings saved successfully:', { data });
252252
toast.success(t('SIDE_NAVIGATION.VALIDATION.SUCCESSFUL_PREFERENCES_SUBMISSION'));
253253
if (pathname === '/' || pathname === `/${local}`) {
254-
setReload(true)
254+
setReload(true);
255255
}
256256
}
257257
} catch (error) {
@@ -295,11 +295,11 @@ function Sidebar(props: any) {
295295

296296
const translateFindMeOptions = [
297297
{
298-
value: 'Auto',
298+
value: 'auto',
299299
name: t('SIDE_NAVIGATION.FIND_ME_OPTIONS.PREFERRED_AUTO'),
300300
},
301301
{
302-
value: 'GPS',
302+
value: 'deviceGPS',
303303
name: t('SIDE_NAVIGATION.FIND_ME_OPTIONS.PREFERRED_DEVICE_GPS'),
304304
},
305305
{

src/constants/types.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ export interface ReviewInt {
6161
image: string;
6262
}
6363

64+
export enum DeviceLocationType {
65+
Automatic = 'auto',
66+
GPS = 'deviceGPS',
67+
SearchCenter = 'searchCenter'
68+
}
69+
6470
// Select specific fields from IUserSettings
6571
export type PartialUserSettings = Pick<IUserSettings, 'user_name' | 'email' | 'phone_number' | 'findme' | 'trust_meter_rating'>;
6672

@@ -74,8 +80,3 @@ export type PartialReview = {
7480

7581
export interface IReviewOutput extends IReviewFeedback, PartialReview {}
7682

77-
export enum DeviceLocationType {
78-
Automatic = 'Auto',
79-
GPS = 'GPS',
80-
SearchCenter = 'searchCenter'
81-
}

src/utils/resolveUserLocation.ts renamed to src/utils/geolocation.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import { IUserSettings } from '@/constants/types';
1+
import { DeviceLocationType, IUserSettings } from '@/constants/types';
22
import logger from '../../logger.config.mjs';
33

4-
export enum DeviceLocationType {
5-
Automatic = 'Auto',
6-
GPS = 'GPS',
7-
SearchCenter = 'searchCenter',
8-
}
9-
104
// Get device location, first trying GPS, and then falling back to IP-based geolocation
115
const getDeviceLocation = async (): Promise<[number, number] | null> => {
126
if (navigator.geolocation) {

0 commit comments

Comments
 (0)