fix for nested x-display-format

This commit is contained in:
2026-07-11 03:38:25 +05:30
parent f5bc7adc37
commit 46e666c6a5

View File

@@ -64,7 +64,19 @@ export function ResourceDetail({ resource, basePath }: ResourceDetailProps) {
Back Back
</Button> </Button>
<Typography variant="h5" fontWeight={700} sx={{ flex: 1 }}> <Typography variant="h5" fontWeight={700} sx={{ flex: 1 }}>
{applyDisplayFormat(data, resource.displayFormat)} {applyDisplayFormat(
Object.fromEntries(
resource.orderedFields.map((field) => {
const value = data[field.name];
if (field.fk && typeof value === "object" && value != null) {
const target = allResources.find((r) => r.name === field.fk!.resource);
if (target) return [field.name, applyDisplayFormat(value, target.displayFormat)];
}
return [field.name, value];
})
),
resource.displayFormat
)}
</Typography> </Typography>
{resource.operations.update && ( {resource.operations.update && (
<Button variant="contained" startIcon={<EditIcon />} onClick={() => navigate(`${basePath}/${resource.name}/${id}/edit`)}> <Button variant="contained" startIcon={<EditIcon />} onClick={() => navigate(`${basePath}/${resource.name}/${id}/edit`)}>