fix: rename getCustomStatusConfig to getCustomStatusBadgeConfig in EnterpriseDetailPageProvider
This commit is contained in:
+1
-49
@@ -1,60 +1,12 @@
|
||||
import { z } from 'zod';
|
||||
import { FieldTextarea, STATUS_DATA } from '@repo/ui/components';
|
||||
import { Sparkles } from 'lucide-react';
|
||||
import { EnterpriseDetailPageProvider, useEnterpriseModuleTranslationContext } from '@repo/ui/foundations';
|
||||
import { FullPageModuleConfig } from '../../domain/constants';
|
||||
import { useState } from 'react';
|
||||
import { FullPageEntity } from '../../domain/entities';
|
||||
|
||||
const cancelSchema = z.object({
|
||||
reason: z.string().min(1, 'Reason is required'),
|
||||
});
|
||||
|
||||
export default function FullPagePageDetail() {
|
||||
const { t } = useEnterpriseModuleTranslationContext();
|
||||
const [detailData, setDetailData] = useState<FullPageEntity>();
|
||||
|
||||
console.log({ detailData });
|
||||
|
||||
return (
|
||||
<EnterpriseDetailPageProvider
|
||||
onDetailLoaded={setDetailData}
|
||||
cancelModalConfig={{
|
||||
title: t('common:confirmDialog.cancel.title'),
|
||||
schema: cancelSchema,
|
||||
defaultValues: { reason: '' },
|
||||
renderBody: (form) => (
|
||||
<FieldTextarea
|
||||
name="reason"
|
||||
control={form!.control}
|
||||
label="Reason for Cancellation"
|
||||
placeholder="Please provide a reason..."
|
||||
withAsterisk
|
||||
/>
|
||||
),
|
||||
confirmLabel: 'Submit Cancellation',
|
||||
successMessage: 'The record was successfully cancelled.',
|
||||
errorMessage: (error: any) => {
|
||||
// Example of parsing a standard axios/backend network error
|
||||
const backendMessage = error?.response?.data?.message;
|
||||
return backendMessage
|
||||
? `Custom Cancellation failed: ${backendMessage}`
|
||||
: 'Custom Failed to cancel the record due to a system error.';
|
||||
},
|
||||
}}
|
||||
// By default it looks for 'status' in detailData, but you can change it here:
|
||||
statusKey="status"
|
||||
// Example of custom badge injection
|
||||
getCustomStatusConfig={(status) => {
|
||||
if (status === STATUS_DATA.DRAFT) {
|
||||
return {
|
||||
color: 'violet',
|
||||
variant: 'outline',
|
||||
leftSection: <Sparkles size={12} strokeWidth={2.5} />,
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}}
|
||||
highlightDataKey="issuer_name"
|
||||
pageHeaderProps={{
|
||||
title: t('detail_page_title'),
|
||||
description: t('detail_page_description'),
|
||||
|
||||
Reference in New Issue
Block a user