ship-gis/src/api/favoriteApi.ts

40 lines
1.2 KiB
TypeScript
Raw Normal View 히스토리

import { fetchWithAuth } from './fetchWithAuth';
/** 관심선박 API 응답 아이템 */
export interface FavoriteShipItem {
signalSourceCode?: string;
targetId?: string;
[key: string]: unknown;
}
/** 관심구역 API 응답 아이템 */
export interface RealmItem {
[key: string]: unknown;
}
/**
*
* @returns {Promise<FavoriteShipItem[]>}
*/
export async function fetchFavoriteShips(): Promise<FavoriteShipItem[]> {
const response = await fetchWithAuth('/api/gis/my/dashboard/ship/attention/static/search');
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
return result?.data || [];
}
/**
*
* @returns {Promise<RealmItem[]>}
*/
export async function fetchRealms(): Promise<RealmItem[]> {
const response = await fetchWithAuth('/api/gis/sea-relm/manage/show', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
return result?.seaRelmManageShowDtoList || [];
}