feat(platform): open analysis from vehicle detail
This commit is contained in:
@@ -13,6 +13,7 @@ import { Vehicles } from './pages/Vehicles';
|
||||
export default function App() {
|
||||
const [activePage, setActivePage] = useState<PageKey>('dashboard');
|
||||
const [activeVin, setActiveVin] = useState('LB9A32A24R0LS1426');
|
||||
const [analysisVin, setAnalysisVin] = useState('LB9A32A24R0LS1426');
|
||||
const [linkIssueCount, setLinkIssueCount] = useState<number | null>(null);
|
||||
|
||||
const refreshOpsHealth = useCallback((showError = true) => {
|
||||
@@ -45,13 +46,31 @@ export default function App() {
|
||||
setActivePage('detail');
|
||||
};
|
||||
|
||||
const openHistoryForVehicle = (vin: string) => {
|
||||
const nextVin = vin.trim();
|
||||
if (!nextVin) {
|
||||
return;
|
||||
}
|
||||
setAnalysisVin(nextVin);
|
||||
setActivePage('history');
|
||||
};
|
||||
|
||||
const openMileageForVehicle = (vin: string) => {
|
||||
const nextVin = vin.trim();
|
||||
if (!nextVin) {
|
||||
return;
|
||||
}
|
||||
setAnalysisVin(nextVin);
|
||||
setActivePage('mileage');
|
||||
};
|
||||
|
||||
const pages: Record<PageKey, JSX.Element> = {
|
||||
dashboard: <Dashboard onOpenVehicle={openVehicle} onOpenQuality={() => setActivePage('quality')} />,
|
||||
vehicles: <Vehicles onOpenVehicle={openVehicle} />,
|
||||
realtime: <Realtime onOpenVehicle={openVehicle} />,
|
||||
detail: <VehicleDetail vin={activeVin} />,
|
||||
history: <History onOpenVehicle={openVehicle} />,
|
||||
mileage: <Mileage onOpenVehicle={openVehicle} />,
|
||||
detail: <VehicleDetail vin={activeVin} onOpenHistory={openHistoryForVehicle} onOpenMileage={openMileageForVehicle} />,
|
||||
history: <History initialVin={analysisVin} onOpenVehicle={openVehicle} />,
|
||||
mileage: <Mileage initialVin={analysisVin} onOpenVehicle={openVehicle} />,
|
||||
quality: <Quality onHealthLoaded={(health) => setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length)} />
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user