feat(web): route companies to simplified profile

This commit is contained in:
2026-09-11 10:01:32 -03:00
parent 32fc5bc60d
commit b859278ad0
+39
View File
@@ -0,0 +1,39 @@
import { useEffect, useState } from 'react';
import { useParams, useSearchParams } from 'react-router';
import { Alert, LoadingBlock, errorMessage } from '../components/Feedback';
import { getAsset } from '../lib/api';
import type { AssetDetail } from '../lib/api';
import { AssetEditorPage } from './AssetEditorPage';
import { CompanyInventoryPage } from './CompanyInventoryPage';
export function InventoryDetailPage() {
const { id } = useParams();
const [params] = useSearchParams();
const [asset, setAsset] = useState<AssetDetail | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState('');
useEffect(() => {
if (!id) {
setError('No se encontró el registro solicitado.');
setLoading(false);
return;
}
setLoading(true);
setError('');
getAsset(id)
.then(setAsset)
.catch((requestError) => setError(errorMessage(requestError)))
.finally(() => setLoading(false));
}, [id]);
if (loading) return <LoadingBlock label="Cargando registro…" />;
if (!asset) return <Alert>{error || 'No se pudo cargar el registro.'}</Alert>;
const isCompany = asset.type.code.toLowerCase() === 'empresa';
if (isCompany && params.get('advanced') !== '1') {
return <CompanyInventoryPage initialAsset={asset} />;
}
return <AssetEditorPage />;
}