Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sync modified data state in déclaration indicator rénumeration #2136

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const RecapCardIndicator = ({ name, customContent, edit, déclaration }:
</p>
)}

{note !== undefined && (
{note !== undefined && !motifNc && (
<IndicatorNote
note={note}
max={indicatorNoteMax[name]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const stepName: FunnelKey = "remunerations";

export const RemunerationForm = () => {
const router = useRouter();
const { formData, saveFormData } = useDeclarationFormManager();
const { formData, saveFormData, savePageData } = useDeclarationFormManager();

assertOrRedirectCommencerStep(formData);

Expand Down Expand Up @@ -153,14 +153,17 @@ export const RemunerationForm = () => {
});
}

// Prevent stale data mixing with new data
//FIXME: changing estCalculable to non on modified déclaration desyncs remunerations-resultat
if (data.estCalculable === "non") {
draft["remunerations-resultat"] = undefined;
savePageData("remunerations-resultat", undefined);
}
if (data.estCalculable !== formData[stepName]?.estCalculable) {
draft[stepName] = getModifiedFormValues(dirtyFields, data) as DeclarationDTO[typeof stepName];
} else {
draft[stepName] = data as DeclarationDTO[typeof stepName];
}
});

saveFormData(newFormData);

return router.push(funnelConfig(newFormData)[stepName].next().url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ const stepName: FunnelKey = "resultat-global";

export const ResultatGlobalForm = () => {
const router = useRouter();
const { formData, saveFormData } = useDeclarationFormManager();
const { formData, saveFormData, savePageData } = useDeclarationFormManager();

assertOrRedirectCommencerStep(formData);

//FIXME: Sync renumaration with renuerationResultat when editing
if (formData.remunerations?.estCalculable === "non") {
savePageData("remunerations-resultat", undefined);
}

const computed = computeDeclarationIndex(DeclarationComputerInputBuilder.fromDeclarationDTO(formData));

// We don't compute the index if we only read an existing declaration.
Expand Down
Loading