40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { type GeoCoordinates } from 'react-native-geolocation-service';
|
|
import axiosInstance, { ApiKeys, getApiUrl } from '../components/utlis/apiHelper';
|
|
|
|
export const sendLocationAndActivenessToServer = async (
|
|
location: GeoCoordinates,
|
|
isActive: boolean
|
|
) => {
|
|
try {
|
|
const response = await axiosInstance.post(
|
|
getApiUrl(ApiKeys.SEND_LOCATION),
|
|
[
|
|
{
|
|
latitude: location?.latitude,
|
|
longitude: location?.longitude,
|
|
accuracy: location?.accuracy,
|
|
timestamp: new Date().getTime(),
|
|
isActiveOnApp: isActive,
|
|
},
|
|
],
|
|
{
|
|
headers: {
|
|
donotHandleError: 'true',
|
|
},
|
|
}
|
|
);
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
};
|
|
|
|
export const getSyncTime = async () => {
|
|
try {
|
|
const url = getApiUrl(ApiKeys.SYNC_TIME);
|
|
const response = await axiosInstance.get(url, { headers: { donotHandleError: true } });
|
|
return response?.data?.currentTimestamp;
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
};
|