- add CurrencyField renderer (inherits NumberField for editing) with cached Intl formatter; route via uiType "currency" in list/detail/form - add resourceConfig.fieldTypes override applied in AppProvider, so amount becomes currency for both Admin and the Expenses page - render Expenses page through react-openapi fields (ListCellRenderer, DetailFieldRenderer, applyDisplayFormat) instead of custom fields - resolve relative /uploads entity logos against the API base URL on load so entity logos render on the expenses feed - drop custom avatar, currency/date formatters from the Expense module
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import React from "react";
|
|
import { Box, Typography, Avatar } from "@mui/material";
|
|
import type { FieldConfig } from "../../types";
|
|
import { ListCellRenderer } from "./ListCellRenderer";
|
|
import { CurrencyField } from "./renderers/CurrencyField";
|
|
|
|
interface DetailFieldProps {
|
|
field: FieldConfig;
|
|
value: any;
|
|
displayFormat?: string;
|
|
basePath?: string;
|
|
}
|
|
|
|
export function DetailFieldRenderer({ field, value, displayFormat, basePath }: DetailFieldProps) {
|
|
if (field.hidden?.detail) return null;
|
|
|
|
return (
|
|
<Box sx={{ mb: 2 }}>
|
|
<Typography variant="caption" color="text.secondary" fontWeight={600} sx={{ mb: 0.25, display: "block" }}>
|
|
{field.label}
|
|
</Typography>
|
|
{field.uiType === "currency" ? (
|
|
<CurrencyField value={Number(value)} large />
|
|
) : field.uiType === "image" ? (
|
|
<Avatar src={value} variant="rounded" sx={{ width: 120, height: 120 }} />
|
|
) : (
|
|
<ListCellRenderer field={field} value={value} displayFormat={displayFormat} basePath={basePath} />
|
|
)}
|
|
</Box>
|
|
);
|
|
}
|