Skip to content

Commit ed5a02e

Browse files
committed
error message fixes
1 parent e28ef11 commit ed5a02e

File tree

5 files changed

+8
-12
lines changed

5 files changed

+8
-12
lines changed

apps/app/src/hooks/useGeoValidation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ export function useGeoValidation(options?: {
3535

3636
// Reject low-accuracy fixes first
3737
if (!accuracy || accuracy > accuracyLimit) {
38-
const msg = `Preciznost lokacije je preniska.`;
3938
setIsOk(false);
40-
setError(msg);
39+
setError('Preciznost lokacije je preniska.');
4140
return;
4241
}
4342

4443
const result = validateWithinRadius(pos.coords);
4544
// for debugging:
4645
// console.log('Geolocation validation result:', result);
4746
setIsOk(result.isOk);
47+
if (!result.isOk) {
48+
setError('Izvan ste dozvoljene lokacije.');
49+
}
4850
},
4951
() => {
5052
setIsOk(false);

apps/app/src/pages/Home/popups/CodePopup/CodePopup.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ const CodePopup: React.FC<CodePopupProps> = ({
2424

2525
function handleCodeSubmit(code: string) {
2626
if (!geolocation.isOk) {
27-
setErrorMessage(
28-
`${geolocation?.error ?? 'Ne možete unijeti kod izvan dozvoljene lokacije.'}`,
29-
);
27+
setErrorMessage(`${geolocation.error ?? "Greška, pokušajte ponovno."}`);
3028
return;
3129
}
3230

apps/app/src/pages/RateCompanyPage/RateCompanyPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const RateCompanyPage = () => {
5454
}
5555

5656
if (!geolocation.isOk) {
57-
toast.error(geolocation?.error ?? 'Ne možete ocijeniti štand izvan dozvoljene lokacije.');
57+
toast.error(`${geolocation.error ?? "Greška, pokušajte ponovno."}`);
5858
navigate(RouteNames.HOME);
5959
return;
6060
}

apps/app/src/pages/ScannerPage/ScannerPage.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ const ScannerPage = () => {
4242
}
4343

4444
if (!geolocation.isOk) {
45-
toast.error(
46-
geolocation?.error ??
47-
'Ne možete skenirati QR kod izvan dozvoljene lokacije.',
48-
);
45+
toast.error(`${geolocation.error ?? 'Greška, pokušajte ponovno.'}`);
4946
return;
5047
}
5148

apps/app/src/validation/validateGeolocation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import {
55
VALIDATION_RADIUS_M,
66
} from '@/constants/geolocation';
77

8-
98
type Coordinates = {
109
lat: number;
1110
lon: number;
1211
};
1312

1413
/* const TARGET_COORDS = { lat: 43.393407, lon: 16.281887 }; */ // for testing, set to your location
15-
const TARGET_COORDS: Coordinates = { lat: TARGET_LAT, lon: TARGET_LON };
14+
const TARGET_COORDS: Coordinates = { lat: TARGET_LAT, lon: TARGET_LON };
1615

1716
// Haversine distance in meters
1817
export function distanceMeters(a: Coordinates, b: Coordinates): number {

0 commit comments

Comments
 (0)