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
1 change: 1 addition & 0 deletions __mocks__/lucide-react-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ export const UserIcon = mockIcon;
export const Users = mockIcon;
export const UsersIcon = mockIcon;
export const X = mockIcon;
export const Menu = mockIcon;
4 changes: 4 additions & 0 deletions src/api/calls/calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface CreateCallRequest {
nature: string;
note?: string;
address?: string;
destinationPoiId?: number | null;
latitude?: number;
longitude?: number;
priority: number;
Expand All @@ -57,6 +58,7 @@ export interface UpdateCallRequest {
nature: string;
note?: string;
address?: string;
destinationPoiId?: number | null;
latitude?: number;
longitude?: number;
priority: number;
Expand Down Expand Up @@ -111,6 +113,7 @@ export const createCall = async (callData: CreateCallRequest) => {
Nature: callData.nature,
Note: callData.note || '',
Address: callData.address || '',
DestinationPoiId: callData.destinationPoiId ?? null,
Geolocation: `${callData.latitude?.toString() || ''},${callData.longitude?.toString() || ''}`,
Priority: callData.priority,
Type: callData.type || '',
Expand Down Expand Up @@ -155,6 +158,7 @@ export const updateCall = async (callData: UpdateCallRequest) => {
Nature: callData.nature,
Note: callData.note || '',
Address: callData.address || '',
DestinationPoiId: callData.destinationPoiId ?? null,
Geolocation: `${callData.latitude?.toString() || ''},${callData.longitude?.toString() || ''}`,
Priority: callData.priority,
Type: callData.type || '',
Expand Down
22 changes: 22 additions & 0 deletions src/api/dispatch/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { type GetSetUnitStateResult } from '@/models/v4/dispatch/getSetUnitStateResult';
import { type NewCallFormResult } from '@/models/v4/dispatch/newCallFormResult';

import { createApiEndpoint } from '../common/client';

const getNewCallDataApi = createApiEndpoint('/Dispatch/GetNewCallData');
const getSetUnitStatusDataApi = createApiEndpoint('/Dispatch/GetSetUnitStatusData');

export const getNewCallData = async (signal?: AbortSignal) => {
const response = await getNewCallDataApi.get<NewCallFormResult>(undefined, signal);
return response.data;
};

export const getSetUnitStatusData = async (unitId: string, signal?: AbortSignal) => {
const response = await getSetUnitStatusDataApi.get<GetSetUnitStateResult>(
{
unitId: unitId,
},
signal
);
return response.data;
};
36 changes: 36 additions & 0 deletions src/api/mapping/mapping.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { type GetMapDataAndMarkersResult } from '@/models/v4/mapping/getMapDataAndMarkersResult';
import { type GetMapLayersResult } from '@/models/v4/mapping/getMapLayersResult';
import { type PoiResult } from '@/models/v4/mapping/poiResult';
import { type PoisResult } from '@/models/v4/mapping/poisResult';
import { type PoiTypesResult } from '@/models/v4/mapping/poiTypesResult';

import { createApiEndpoint } from '../common/client';

const getMayLayersApi = createApiEndpoint('/Mapping/GetMapLayers');

const getMapDataAndMarkersApi = createApiEndpoint('/Mapping/GetMapDataAndMarkers');
const getPoiTypesApi = createApiEndpoint('/Mapping/GetPoiTypes');
const getPoisApi = createApiEndpoint('/Mapping/GetPois');

export const getMapDataAndMarkers = async (signal?: AbortSignal) => {
const response = await getMapDataAndMarkersApi.get<GetMapDataAndMarkersResult>(undefined, signal);
Expand All @@ -18,3 +23,34 @@ export const getMayLayers = async (type: number) => {
});
return response.data;
};

export interface GetPoisOptions {
poiTypeId?: number;
destinationOnly?: boolean;
}

export const getPoiTypes = async (signal?: AbortSignal) => {
const response = await getPoiTypesApi.get<PoiTypesResult>(undefined, signal);
return response.data;
};

export const getPois = async (options: GetPoisOptions = {}, signal?: AbortSignal) => {
const params: Record<string, unknown> = {};

if (options.poiTypeId !== undefined) {
params.poiTypeId = options.poiTypeId;
}

if (options.destinationOnly !== undefined) {
params.destinationOnly = options.destinationOnly;
}

const response = await getPoisApi.get<PoisResult>(Object.keys(params).length > 0 ? params : undefined, signal);
return response.data;
};

export const getPoi = async (poiId: number, signal?: AbortSignal) => {
const getPoiApi = createApiEndpoint(`/Mapping/GetPoi/${encodeURIComponent(poiId)}`);
const response = await getPoiApi.get<PoiResult>(undefined, signal);
return response.data;
};
12 changes: 12 additions & 0 deletions src/app/(app)/__tests__/map.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import HomeMap from '../map';
// Mock NativeWind and CSS Interop
jest.mock('nativewind', () => ({
cssInterop: jest.fn(),
useColorScheme: () => ({
colorScheme: 'light',
setColorScheme: jest.fn(),
toggleColorScheme: jest.fn(),
}),
}));

jest.mock('react-native-css-interop', () => ({
Expand Down Expand Up @@ -302,11 +307,17 @@ jest.mock('@/stores/toast/store', () => ({
}));

// Mock expo-router
const mockRouterPush = jest.fn();

jest.mock('expo-router', () => ({
useFocusEffect: (callback: () => void) => {
const mockReact = require('react');
mockReact.useEffect(callback, []);
},
useLocalSearchParams: () => ({}),
useRouter: () => ({
push: mockRouterPush,
}),
}));

describe('HomeMap', () => {
Expand All @@ -315,6 +326,7 @@ describe('HomeMap', () => {

beforeEach(() => {
jest.clearAllMocks();
mockRouterPush.mockReset();
mockTrackEvent.mockReset();
mockTrackEvent.mockReset();
mockTrackEvent.mockReset();
Expand Down
Loading
Loading