Client: Improved show page titles
This commit is contained in:
@@ -21,13 +21,21 @@ export const FilamentShow: React.FC<IResourceComponentsProps> = () => {
|
||||
|
||||
const record = data?.data;
|
||||
|
||||
const formatTitle = (item: IFilament) => {
|
||||
let vendorPrefix = "";
|
||||
if (item.vendor) {
|
||||
vendorPrefix = `${item.vendor.name} - `;
|
||||
}
|
||||
return `[Filament #${item.id}] ${vendorPrefix}${item.name}`;
|
||||
};
|
||||
|
||||
const formatVendor = (item: IVendor) => {
|
||||
const URL = `/vendor/show/${item.id}`;
|
||||
return <a href={URL}>{item.name}</a>;
|
||||
};
|
||||
|
||||
return (
|
||||
<Show isLoading={isLoading}>
|
||||
<Show isLoading={isLoading} title={record ? formatTitle(record) : ""}>
|
||||
<Title level={5}>{t("filament.fields.id")}</Title>
|
||||
<NumberField value={record?.id ?? ""} />
|
||||
<Title level={5}>{t("filament.fields.vendor")}</Title>
|
||||
|
||||
@@ -34,17 +34,24 @@ export const SpoolShow: React.FC<IResourceComponentsProps> = () => {
|
||||
if (item.material) {
|
||||
material = ` - ${item.material}`;
|
||||
}
|
||||
const label = `${vendorPrefix}${name}${material}`;
|
||||
return `${vendorPrefix}${name}${material}`;
|
||||
};
|
||||
|
||||
const filamentURL = (item: IFilament) => {
|
||||
const URL = `/filament/show/${item.id}`;
|
||||
return <a href={URL}>{label}</a>;
|
||||
return <a href={URL}>{formatFilament(item)}</a>;
|
||||
};
|
||||
|
||||
const formatTitle = (item: ISpool) => {
|
||||
return `[Spool #${item.id}] ${formatFilament(item.filament)}`;
|
||||
};
|
||||
|
||||
return (
|
||||
<Show isLoading={isLoading}>
|
||||
<Show isLoading={isLoading} title={record ? formatTitle(record) : ""}>
|
||||
<Title level={5}>{t("spool.fields.id")}</Title>
|
||||
<NumberField value={record?.id ?? ""} />
|
||||
<Title level={5}>{t("spool.fields.filament")}</Title>
|
||||
<TextField value={record ? formatFilament(record?.filament) : ""} />
|
||||
<TextField value={record ? filamentURL(record?.filament) : ""} />
|
||||
<Title level={5}>{t("spool.fields.registered")}</Title>
|
||||
<DateField
|
||||
value={dayjs.utc(record?.registered).local()}
|
||||
|
||||
6
client/src/pages/vendors/show.tsx
vendored
6
client/src/pages/vendors/show.tsx
vendored
@@ -19,8 +19,12 @@ export const VendorShow: React.FC<IResourceComponentsProps> = () => {
|
||||
|
||||
const record = data?.data;
|
||||
|
||||
const formatTitle = (item: IVendor) => {
|
||||
return `[Vendor #${item.id}] ${item.name}`;
|
||||
};
|
||||
|
||||
return (
|
||||
<Show isLoading={isLoading}>
|
||||
<Show isLoading={isLoading} title={record ? formatTitle(record) : ""}>
|
||||
<Title level={5}>{t("vendor.fields.id")}</Title>
|
||||
<NumberField value={record?.id ?? ""} />
|
||||
<Title level={5}>{t("vendor.fields.registered")}</Title>
|
||||
|
||||
Reference in New Issue
Block a user