Form submission refactoring #203
Conversation
f0804bc
to
30f55cf
Compare
There was a problem hiding this 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": { |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
66a1796
to
146667d
Compare
3904cc5
to
8f305f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fantastic work !
No description provided.