Files
Environment-Monitoring-System/ems-frontend/ems-monitoring-system/src/api/pathfinding.ts
ChuXun 02a830145e 1
2025-10-25 19:18:43 +08:00

30 lines
758 B
TypeScript

import apiClient from './index';
/**
* Represents a point with x and y coordinates.
* Matches the backend Point DTO.
*/
export interface Point {
x: number;
y: number;
}
/**
* Represents the request payload for finding a path.
* Matches the backend PathfindingRequest DTO.
*/
export interface PathfindingRequest {
startX: number;
startY: number;
endX: number;
endY: number;
}
/**
* Calls the backend API to find a path between two points.
* @param request The pathfinding request containing start and end coordinates.
* @returns A promise that resolves to a list of points representing the path.
*/
export const findPath = (request: PathfindingRequest): Promise<Point[]> => {
return apiClient.post('/pathfinding/find', request);
};