diff --git a/mechanic-pwa/frontend/src/api/vehicles.ts b/mechanic-pwa/frontend/src/api/vehicles.ts index 86555c5..fb3a838 100644 --- a/mechanic-pwa/frontend/src/api/vehicles.ts +++ b/mechanic-pwa/frontend/src/api/vehicles.ts @@ -8,6 +8,10 @@ export interface VehicleSummary { model?: string | null; year?: number | null; last_inspection_at?: string | null; + /** Текущий статус машины из 1C Element (cars_v2.element_status): + 'На линии' / 'Простой' / 'Ремонтируется' / 'Ждет ремонта' / 'ДТП' / + 'Бронь' / 'Выкуп' / 'На продаже' / etc. NULL если не задан. */ + status?: string | null; } export interface VehicleDetail extends VehicleSummary { diff --git a/mechanic-pwa/frontend/src/pages/Home.tsx b/mechanic-pwa/frontend/src/pages/Home.tsx index f6be092..b063b58 100644 --- a/mechanic-pwa/frontend/src/pages/Home.tsx +++ b/mechanic-pwa/frontend/src/pages/Home.tsx @@ -10,6 +10,38 @@ const ACTION_TITLES: Record = { repair: "Ремонт", }; +// Группа цветов по семантике статуса. Палитра подсчитана из Tailwind с +// прозрачностью, чтобы чип не перебивал гос.номер. Tone: +// ok — на линии (зелёный) +// idle — простой (серый) +// repair — в ремонте / ждёт ремонта (янтарный) +// alert — ДТП (красный) +// admin — выкуп / на продаже / бронь / подготовка к продаже / ждёт доставки +// sold — продана (не отображается — отфильтрована из выдачи) +const STATUS_TONE: Record = { + "На линии": "bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300", + "Простой": "bg-muted text-muted-foreground", + "Ремонтируется": "bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-300", + "Ждет ремонта": "bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-300", + "ДТП": "bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300", + "Бронь": "bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300", + "Выкуп": "bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300", + "На продаже": "bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300", + "Подготовка на продажу": "bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300", + "Ждет доставки до офиса": "bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300", +}; + +function StatusChip({ status }: { status: string }) { + const tone = + STATUS_TONE[status] ?? + "bg-muted text-muted-foreground"; + return ( + + {status} + + ); +} + export default function Home() { const [q, setQ] = useState(""); const [searchParams] = useSearchParams(); @@ -63,7 +95,10 @@ export default function Home() { navigate(`/vehicles/${v.id}${action ? `?action=${action}` : ""}`) } > -
{v.license_plate}
+
+
{v.license_plate}
+ {v.status && } +
{[v.make, v.model, v.year].filter(Boolean).join(" ") || "—"}
diff --git a/mechanic-pwa/frontend/src/pages/VehicleCard.tsx b/mechanic-pwa/frontend/src/pages/VehicleCard.tsx index 1fa87b5..f7d195a 100644 --- a/mechanic-pwa/frontend/src/pages/VehicleCard.tsx +++ b/mechanic-pwa/frontend/src/pages/VehicleCard.tsx @@ -110,7 +110,29 @@ export default function VehicleCard() { -
{v.license_plate}
+
+
{v.license_plate}
+ {v.status && ( + + {v.status} + + )} +
{[v.make, v.model, v.year].filter(Boolean).join(" ") || "—"}