fix operating status: translate FMCSA status codes to human-readable labels (A=Active, I=Inactive, etc)
This commit is contained in:
parent
4345a7546d
commit
18fb45dba0
1 changed files with 19 additions and 3 deletions
|
|
@ -87,14 +87,30 @@ router.get("/api/v1/dot/lookup", async (req, res) => {
|
|||
// ── Check 1: Operating Status ──
|
||||
if (carrier) {
|
||||
const allowed = carrier.allowedToOperate === "Y";
|
||||
const status = carrier.statusCode;
|
||||
const statusCode = carrier.statusCode || "";
|
||||
const statusLabels: Record<string, string> = {
|
||||
A: "Active",
|
||||
I: "Inactive",
|
||||
N: "Not Authorized",
|
||||
O: "Out of Service",
|
||||
R: "Revoked",
|
||||
S: "Suspended",
|
||||
C: "Cancelled",
|
||||
};
|
||||
const statusLabel = statusLabels[statusCode] || statusCode;
|
||||
checks.push({
|
||||
id: "operating_status",
|
||||
label: "Operating Status",
|
||||
status: allowed ? "green" : "red",
|
||||
detail: allowed
|
||||
? `Authorized to operate. Status: ${status === "A" ? "Active" : status}.`
|
||||
: `NOT authorized to operate. Status: ${status}. This carrier cannot legally operate.`,
|
||||
? `Authorized to operate (${statusLabel}).`
|
||||
: `NOT authorized to operate — ${statusLabel}. ${
|
||||
statusCode === "I" ? "This USDOT number is inactive. You may need to reactivate it before operating."
|
||||
: statusCode === "N" ? "This carrier is not authorized. Operating authority may be required."
|
||||
: statusCode === "R" ? "This carrier's authority has been revoked."
|
||||
: statusCode === "O" ? "This carrier has been placed out of service by FMCSA."
|
||||
: "This carrier cannot legally operate."
|
||||
}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue