fix: miler assignment lifecycle, pickup hub resolution, and hyperlocal delivery
Bugs found during live Coimbatore testing against production: - GetMilerAssignments returned every assignment ever made to a miler with no status filter, so weeks-old Rejected assignments still showed up as actionable in the app. Now filters to Assigned/Accepted only. - AcceptMilerAssignment overwrote assignmentstatus unconditionally, letting a stale Rejected assignment be silently reactivated (and pushing its booking back to Pickup_Scheduled). Now 400s unless currently Assigned, reporting the actual status. - RejectMilerAssignment read `reason` from the query string instead of the JSON body, contradicting the API contract and every sibling endpoint. - BookingPickupComplete resolved the origin hub via db.First(&hub) with no Where clause — i.e. the lowest hub ID in the table, unrelated to the booking or miler. Now uses the miler's own MilerProfile.Hubid, falling back to the old behaviour with a warning only when unassigned. - No code path ever set a consignment to Out_for_Delivery, making MilerDeliverConsignment unreachable. BookingPickupComplete now goes straight to Out_for_Delivery when pickup and delivery pincodes share a 3-digit postal-area prefix (same-miler hyperlocal), reusing the hubPincodePrefix convention. Cross-hub still lands at Inwarded_at_Hub. Also allow https://app.doormile.com in CORS, and drop a stray Windows-path log file that was committed by accident. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2
main.go
2
main.go
@@ -50,7 +50,7 @@ func main() {
|
||||
// CORS policy
|
||||
app.Use(cors.New(cors.Config{
|
||||
AllowHeaders: "Origin,Content-Type,Accept,Authorization",
|
||||
AllowOrigins: "http://localhost:5173,http://localhost:5174,http://localhost:3000,http://localhost:3001,http://localhost:3002,http://localhost:8080,http://localhost:8081,https://doormile.com,https://www.doormile.com,https://admin.doormile.com,https://api.doormile.com,https://crm.doormile.com,https://console.doormile.com",
|
||||
AllowOrigins: "http://localhost:5173,http://localhost:5174,http://localhost:3000,http://localhost:3001,http://localhost:3002,http://localhost:8080,http://localhost:8081,https://doormile.com,https://www.doormile.com,https://admin.doormile.com,https://api.doormile.com,https://crm.doormile.com,https://console.doormile.com,https://app.doormile.com",
|
||||
AllowCredentials: true,
|
||||
AllowMethods: "GET,POST,PUT,DELETE,PATCH,OPTIONS",
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user