fix: update BreadcrumbBar component to correctly assign keys and enhance error handling in EnterpriseDetailPageProvider
This commit is contained in:
@@ -80,7 +80,6 @@ function BreadcrumbBar({ breadcrumbs }: BreadcrumbBarProps) {
|
|||||||
const isText = item.type === 'text';
|
const isText = item.type === 'text';
|
||||||
const isLast = index === breadcrumbs.length - 1;
|
const isLast = index === breadcrumbs.length - 1;
|
||||||
const sharedProps = {
|
const sharedProps = {
|
||||||
key: index,
|
|
||||||
c: !isLast ? ('dimmed' as const) : undefined,
|
c: !isLast ? ('dimmed' as const) : undefined,
|
||||||
size: 'xs' as const,
|
size: 'xs' as const,
|
||||||
fw: 500,
|
fw: 500,
|
||||||
@@ -92,11 +91,13 @@ function BreadcrumbBar({ breadcrumbs }: BreadcrumbBarProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return !isText ? (
|
return !isText ? (
|
||||||
<Anchor {...sharedProps} href={item.href}>
|
<Anchor key={index} {...sharedProps} href={item.href}>
|
||||||
{item.label}
|
{item.label}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
) : (
|
) : (
|
||||||
<Text {...sharedProps}>{item.label}</Text>
|
<Text key={index} {...sharedProps}>
|
||||||
|
{item.label}
|
||||||
|
</Text>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Breadcrumbs>
|
</Breadcrumbs>
|
||||||
|
|||||||
@@ -79,13 +79,12 @@ export function EnterpriseDetailPageProvider<E extends BaseEntity = BaseEntity>(
|
|||||||
setDetailData(data as E);
|
setDetailData(data as E);
|
||||||
if (onDetailLoaded) onDetailLoaded(data as E);
|
if (onDetailLoaded) onDetailLoaded(data as E);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
// FIXME => remove this example later;
|
notifications.show({
|
||||||
|
title: t('common:notifications.errorTitle'),
|
||||||
const data = { id: 1, code: 'ABCD-0001', status: 'open' } as any;
|
message: error?.message,
|
||||||
setDetailData(data as E);
|
color: 'red',
|
||||||
if (onDetailLoaded) onDetailLoaded(data as E);
|
});
|
||||||
console.error('Failed to load detail data', error);
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
@@ -202,7 +201,7 @@ export function EnterpriseDetailPageProvider<E extends BaseEntity = BaseEntity>(
|
|||||||
: currentConfig?.successMessage;
|
: currentConfig?.successMessage;
|
||||||
|
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: t('common:notifications.successTitle', { defaultValue: 'Success' }),
|
title: t('common:notifications.successTitle'),
|
||||||
message: customSuccessMessage || defaultSuccessMessage,
|
message: customSuccessMessage || defaultSuccessMessage,
|
||||||
color: 'teal',
|
color: 'teal',
|
||||||
});
|
});
|
||||||
@@ -227,7 +226,7 @@ export function EnterpriseDetailPageProvider<E extends BaseEntity = BaseEntity>(
|
|||||||
: currentConfig?.errorMessage;
|
: currentConfig?.errorMessage;
|
||||||
|
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: t('common:notifications.errorTitle', { defaultValue: 'Error' }),
|
title: t('common:notifications.errorTitle'),
|
||||||
message: customErrorMessage || defaultErrorMessage,
|
message: customErrorMessage || defaultErrorMessage,
|
||||||
color: 'red',
|
color: 'red',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user