Implement active Location Sharing Stopped/Ended state with red dot pin

This commit is contained in:
Shanmuga Krishnan S M
2026-07-27 13:51:41 +05:30
parent def3a7c9ce
commit a3e1f1e826
4 changed files with 42 additions and 9 deletions

View File

@@ -37,6 +37,20 @@ public class BusLocationController {
return ResponseEntity.ok(Map.of("status", "success", "message", "Location updated successfully"));
}
@PostMapping("/{routeNumber}/stop")
public ResponseEntity<Map<String, String>> stopLocation(
@PathVariable String routeNumber,
@RequestBody Map<String, String> body) {
String pin = body != null ? body.get("pin") : null;
if (!REQUIRED_PIN.equals(pin)) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(Map.of("error", "Invalid driver PIN"));
}
busLocationService.stopLocation(routeNumber);
return ResponseEntity.ok(Map.of("status", "success", "message", "Location sharing stopped"));
}
@GetMapping
public ResponseEntity<List<BusLocation>> getActiveLocations() {
return ResponseEntity.ok(busLocationService.getActiveLocations());