apiDeleteZoneOfficial handles DELETE /admin/api/v1/elections/zones/{zone}/official Removes the elected official for the named zone.
(r *http.Request)
| 90 | // apiDeleteZoneOfficial handles DELETE /admin/api/v1/elections/zones/{zone}/official |
| 91 | // Removes the elected official for the named zone. |
| 92 | func (m *ElectionsModule) apiDeleteZoneOfficial(r *http.Request) (int, bool, any) { |
| 93 | zoneName := r.PathValue("zone") |
| 94 | if zoneName == "" { |
| 95 | return http.StatusBadRequest, false, map[string]string{"error": "zone is required"} |
| 96 | } |
| 97 | zoneKey := strings.ToLower(zoneName) |
| 98 | |
| 99 | if _, ok := m.state.Winners[zoneKey]; !ok { |
| 100 | return http.StatusNotFound, false, map[string]string{"error": "no elected official for zone"} |
| 101 | } |
| 102 | |
| 103 | delete(m.state.Winners, zoneKey) |
| 104 | return http.StatusOK, true, map[string]any{"zone": zoneKey, "official_removed": true} |
| 105 | } |