EAP: Update schema for Save and submit functionality#2240
EAP: Update schema for Save and submit functionality#2240shreeyash07 wants to merge 4 commits intoproject/early-action-protocolsfrom
Conversation
|
f663360 to
21c940f
Compare
c9aef37 to
97a5803
Compare
- Add getIsSubmission context in form schema for save and submit functionality - Add lastModifiedAtRef to send modified_at while updating
| const strings = useTranslation(i18n); | ||
|
|
||
| const { pending: fullEapPending, response: fullEapResponse } = useRequest({ | ||
| skip: isNotDefined(fullEapId) || isDefined(simplifiedEapId), |
There was a problem hiding this comment.
Why skip fullEap if simplifiedEap is not defined?
There was a problem hiding this comment.
Because we don't need full response in simplified form.
| }); | ||
|
|
||
| const { pending: simplifiedEapPending, response: simplifiedEapResponse } = useRequest({ | ||
| skip: isNotDefined(simplifiedEapId) || isDefined(fullEapId), |
There was a problem hiding this comment.
Why skip simplifiedEap if fullEap is not defined?
There was a problem hiding this comment.
Because we don't need simplified response in full form.
| }); | ||
|
|
||
| const response = fullEapResponse ?? simplifiedEapResponse; | ||
| const pending = fullEapPending ?? simplifiedEapPending; |
There was a problem hiding this comment.
| const pending = fullEapPending ?? simplifiedEapPending; | |
| const pending = fullEapPending || simplifiedEapPending; |
| )} | ||
| > | ||
| {pending && <BlockLoading />} | ||
| {!pending && ( |
| "confirmStatusButtonLabel": "Confirm", | ||
| "updateStatusDescription": "Are you sure you want to update the status?", | ||
| "reviewChecklistDescription": "Upload the Review Checklist for the National Society to download and review. Make sure to keep a proper labeling of the file to avoid duplications.", | ||
| "editSimplifiedEapFormLinkLabel": "Edit sEAP", |
There was a problem hiding this comment.
| "editSimplifiedEapFormLinkLabel": "Edit sEAP", | |
| "editSimplifiedEapFormLinkLabel": "Edit simplified EAP", |
There was a problem hiding this comment.
No changes required in this. this is correct.
| </Label> | ||
| </ListView> | ||
| )} | ||
| {isDefined(hasFormErrors) && ( |
There was a problem hiding this comment.
I think we've already alerted the users. Is this necessary again?
There was a problem hiding this comment.
This alert is different it persist its state in the modal to show warning and error.
| const [fileIdToUrlMap, setFileIdToUrlMap] = useState<Record<number, string>>({}); | ||
|
|
||
| const updateFileUrlMapping = useCallback((response: GetSimplifiedResponse) => { | ||
| lastModifiedAtRef.current = response?.modified_at; |
There was a problem hiding this comment.
Move this setting right after we get data from the request as opposed to doing it during updateFileUrlMapping
| // NOTE it is here to clear the state and | ||
| // replace is necessary for not pushing a new entry |
There was a problem hiding this comment.
Mention in the note in a bit more detail about why the state was used and what happens if we don't replace it.
Also, try this:
window.history.replaceState({}, '')
There was a problem hiding this comment.
Navigating my trigger the request again that will lead to the onSuccess being triggered again.
app/src/views/EapFullForm/index.tsx
Outdated
| ); | ||
|
|
||
| const updateFileUrlMapping = useCallback((response: GetFullEapResponse) => { | ||
| lastModifiedAtRef.current = response?.modified_at; |
There was a problem hiding this comment.
Same as in the simplified form
app/src/views/EapFullForm/index.tsx
Outdated
|
|
||
| // NOTE it is here to clear the state and | ||
| // replace is necessary for not pushing a new entry | ||
| navigate( |
There was a problem hiding this comment.
Same as in the simplified form
Changes
This PR Ensures:
console.logstatements meant for debuggingAdditional Notes
Optional: Add any other relevant context, screenshots, or details here.