fix(numbering): correct error state handling in MetricsDashboard
- Change state type to allow undefined distinction from empty object - Set undefined on error instead of empty object - Fixes test failure where 'No metrics available' was not displayed
This commit is contained in:
@@ -7,7 +7,7 @@ import { documentNumberingService } from '@/lib/services/document-numbering.serv
|
|||||||
import { NumberingMetrics } from '@/types/dto/numbering.dto';
|
import { NumberingMetrics } from '@/types/dto/numbering.dto';
|
||||||
|
|
||||||
export function MetricsDashboard() {
|
export function MetricsDashboard() {
|
||||||
const [metrics, setMetrics] = useState<Partial<NumberingMetrics>>({});
|
const [metrics, setMetrics] = useState<Partial<NumberingMetrics> | undefined>(undefined);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -16,7 +16,7 @@ export function MetricsDashboard() {
|
|||||||
const data = await documentNumberingService.getMetrics();
|
const data = await documentNumberingService.getMetrics();
|
||||||
setMetrics(data);
|
setMetrics(data);
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
setMetrics({});
|
setMetrics(undefined);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user