| import api from './axiosInstance.api'; |
|
|
| |
| |
| |
|
|
| export interface EarthquakeAlert { |
| warning_message: string; |
| effective_start_time: string; |
| depth: string; |
| latitude: number; |
| longitude: number; |
| magnitude: string; |
| disaster_type: string; |
| direction: string; |
| source: string; |
| polygons?: Array<{ |
| intensity: number; |
| color: string; |
| latitude: number; |
| longitude: number; |
| radius: number; |
| name: string; |
| coordinates: { |
| type: string; |
| coordinates: any; |
| }; |
| }>; |
| } |
|
|
| export interface NowcastAlert { |
| severity: string; |
| effective_start_time: string; |
| effective_end_time: string; |
| area_description: string; |
| events: string; |
| event_category: string; |
| severity_color: string; |
| location: { |
| coordinates: [number, number]; |
| type: string; |
| }; |
| source: string; |
| identifier: string; |
| state_id: string; |
| entry_time: string; |
| } |
|
|
| export interface GeneralAlert { |
| severity: string; |
| identifier: number; |
| effective_start_time: string; |
| effective_end_time: string; |
| disaster_type: string; |
| area_description: string; |
| warning_message: string; |
| severity_color: string; |
| severity_level: string; |
| centroid: string; |
| alert_source: string; |
| area_covered: string; |
| sender_org_id: string; |
| type: number; |
| actual_lang: string; |
| disseminated: string; |
| alert_id_sdma_autoinc: number; |
| } |
|
|
| export interface EarthquakeAlertsResponse { |
| alerts: EarthquakeAlert[]; |
| } |
|
|
| export interface NowcastAlertsResponse { |
| nowcastDetails: NowcastAlert[]; |
| } |
|
|
| export interface AllAlertsResponse { |
| earthquakes: EarthquakeAlertsResponse; |
| nowcast: NowcastAlertsResponse; |
| general: GeneralAlert[]; |
| } |
|
|
| export interface StatewiseFilter { |
| event: string; |
| Warn_type: string; |
| action: string; |
| view: string; |
| noalert: string; |
| sachethead: string; |
| localert: string; |
| issued_by: string; |
| state_wise: string; |
| loc_wise: string; |
| search_state: string; |
| search_loc: string; |
| state: string; |
| noalert_msg: string; |
| } |
|
|
| |
| |
| |
|
|
| |
| |
| |
| export const getAllAlerts = async (): Promise<AllAlertsResponse> => { |
| const response = await api.get<{ success: boolean; data: AllAlertsResponse }>('/sachet/all-alerts'); |
| return response.data.data; |
| }; |
|
|
| |
| |
| |
| export const getEarthquakeAlerts = async (): Promise<EarthquakeAlertsResponse> => { |
| const response = await api.get<{ success: boolean; data: EarthquakeAlertsResponse }>('/sachet/earthquake-alerts'); |
| return response.data.data; |
| }; |
|
|
| |
| |
| |
| export const getNowcastAlerts = async (): Promise<NowcastAlertsResponse> => { |
| const response = await api.get<{ success: boolean; data: NowcastAlertsResponse }>('/sachet/nowcast-alerts'); |
| return response.data.data; |
| }; |
|
|
| |
| |
| |
| export const getGeneralAlerts = async (): Promise<GeneralAlert[]> => { |
| const response = await api.get<{ success: boolean; data: GeneralAlert[] }>('/sachet/all-alert-details'); |
| return response.data.data; |
| }; |
|
|
| |
| |
| |
| export const getStatewiseFilter = async (): Promise<StatewiseFilter> => { |
| const response = await api.get<{ success: boolean; data: StatewiseFilter }>('/sachet/statewise-filter'); |
| return response.data.data; |
| }; |
|
|
| |
| |
| |
|
|
| |
| |
| |
| export const geoJsonToLeaflet = (coordinates: [number, number]): [number, number] => { |
| return [coordinates[1], coordinates[0]]; |
| }; |
|
|
| |
| |
| |
| export const parseCentroid = (centroid: string): [number, number] | null => { |
| const coords = centroid.split(',').map(Number); |
| if (coords.length !== 2 || coords.some(isNaN)) { |
| return null; |
| } |
| return [coords[1], coords[0]]; |
| }; |
|
|
| |
| |
| |
| export const getSeverityColor = (severity: string): string => { |
| const colors: { [key: string]: string } = { |
| 'red': '#ef4444', |
| 'orange': '#f97316', |
| 'yellow': '#eab308', |
| 'green': '#22c55e', |
| 'EXTREME': '#dc2626', |
| 'SEVERE': '#f97316', |
| 'ALERT': '#f97316', |
| 'WATCH': '#eab308', |
| }; |
| return colors[severity] || colors[severity?.toUpperCase()] || '#6b7280'; |
| }; |
|
|
| |
| |
| |
|
|
| export default { |
| getAllAlerts, |
| getEarthquakeAlerts, |
| getNowcastAlerts, |
| getGeneralAlerts, |
| getStatewiseFilter, |
| geoJsonToLeaflet, |
| parseCentroid, |
| getSeverityColor, |
| }; |
|
|