IO-3310 Shop Info Data Preservation
Correction to preserve hidden data Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -23,13 +23,24 @@ export default function ShopInfoContainer() {
|
||||
});
|
||||
const notification = useNotification();
|
||||
|
||||
const combinedFeatureConfig = {
|
||||
...FEATURE_CONFIGS.general,
|
||||
...FEATURE_CONFIGS.responsibilitycenters
|
||||
};
|
||||
const combineFeatureConfigs = (...configs) =>
|
||||
(configs || [])
|
||||
.filter(Boolean)
|
||||
.flatMap((cfg) => Object.entries(cfg))
|
||||
.reduce((acc, [featureName, fieldPaths]) => {
|
||||
if (!Array.isArray(fieldPaths)) return acc;
|
||||
acc[featureName] = [...(acc[featureName] ?? []), ...fieldPaths];
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const combinedFeatureConfig = combineFeatureConfigs(FEATURE_CONFIGS.general, FEATURE_CONFIGS.responsibilitycenters);
|
||||
|
||||
// Use form data preservation for all shop-info features
|
||||
const { createSubmissionHandler } = useFormDataPreservation(form, data?.bodyshops[0], combinedFeatureConfig);
|
||||
const { createSubmissionHandler, preserveHiddenFormData } = useFormDataPreservation(
|
||||
form,
|
||||
data?.bodyshops[0],
|
||||
combinedFeatureConfig
|
||||
);
|
||||
|
||||
const handleFinish = createSubmissionHandler((values) => {
|
||||
setSaveLoading(true);
|
||||
@@ -51,8 +62,11 @@ export default function ShopInfoContainer() {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) form.resetFields();
|
||||
}, [form, data]);
|
||||
if (!data) return;
|
||||
form.resetFields();
|
||||
// After reset, re-apply hidden field preservation so values aren't wiped
|
||||
preserveHiddenFormData();
|
||||
}, [data, form, preserveHiddenFormData]);
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
if (loading) return <LoadingSpinner />;
|
||||
|
||||
Reference in New Issue
Block a user