Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Form submission refactoring #203

Merged
merged 72 commits into from May 20, 2021
Merged

Form submission refactoring #203

merged 72 commits into from May 20, 2021

Conversation

Bernardstanislas
Copy link
Contributor

No description provided.

@Bernardstanislas Bernardstanislas changed the title copy form WIP - Copy form button + form submission refactoring May 17, 2021
@Bernardstanislas Bernardstanislas force-pushed the copy-form branch 2 times, most recently from f0804bc to 30f55cf Compare May 17, 2021 14:23
@Bernardstanislas Bernardstanislas changed the title WIP - Copy form button + form submission refactoring Form submission refactoring May 17, 2021
Copy link
Member

@rdubigny rdubigny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am really fond of the splitting in several little files, particularly of the separated button configuration file with explicit behavior. This implementation is simpler on many aspects. Thanks.

@@ -3188,6 +3188,31 @@
"num2fraction": "^1.2.2",
"postcss": "^7.0.32",
"postcss-value-parser": "^4.1.0"
},
"dependencies": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have doubt that these changes are due to using the wrong version of npm.

Could you confirm this is not the case ?

@@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"engines": {
"node": ">=12.18.3"
"node": ">=12.18.3 <14"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the right not version is : ~12.18.3

const showPrompt = pendingAction !== null;

const confirmPrompt = useRef();
const cancelPrompt = useRef();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use react context ? if the point is to use a shared state it seems the right way to do it. What am I missing ?

setLoading(true);

const userInteractionPromise = new Promise((resolve, reject) => {
confirmPrompt.current = resolve;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, this kind of logic should be handled in the SubmissionPanel component, not in an atom.

return (
<FormActionButton
key={actionConfiguration.id}
actionConfiguration={actionConfiguration}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather set explicitly label, icon and cssClass explicitly than passing an opaque object

actionConfiguration={actionConfiguration}
loading={loading}
setLoading={setLoading}
{...props}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not found of passing an opaque amount of props to an atoms. This comment is linked to the complex logic embarked in the onClick on the atomic button.

confirmPrompt.current = resolve;
cancelPrompt.current = reject;
});
const resultMessages = await handleEnrollmentSubmission(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not agree with handling the most important logic of the whole SubmissionPanel in an atom.

Maybe this should be solved simply by defining the onClick behavior in the SubmissionPanel and passing this function to children.

await deleteEnrollment({ id: enrollmentId });
}

if (actionConfiguration.needsToComputeNextEnrollmentState) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the fact that this is now a parameters, but I can't manage to understand the meaning of this. Can we talk about this ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe my confusion is partially due to NextEnrollment being a name used elsewhere in the codebase.

Copy link
Member

@rdubigny rdubigny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastic work !

@rdubigny rdubigny merged commit c3d8e2f into master May 20, 2021
@rdubigny rdubigny deleted the copy-form branch May 20, 2021 10:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants