feat(core): sgw-device-ui
This commit is contained in:
25
src/models/getSos.ts
Normal file
25
src/models/getSos.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { getGPS } from '@/services/controller/DeviceController';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
export default function useGetGpsModel() {
|
||||
const [gpsData, setGpsData] = useState<API.GPSResonse | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const getGPSData = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await getGPS(); // đổi URL cho phù hợp
|
||||
console.log('GPS Data fetched:', res);
|
||||
|
||||
setGpsData(res || []);
|
||||
} catch (err) {
|
||||
console.error('Fetch gps data failed', err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
return {
|
||||
gpsData,
|
||||
loading,
|
||||
getGPSData,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user