-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚚 [open-formulieren/open-forms#4929] Move SubmissionProvider into its…
… own component The component was moved from Form.jsx into its own file and imports are updated.
- Loading branch information
1 parent
cff4b05
commit f4df338
Showing
9 changed files
with
59 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import PropTypes from 'prop-types'; | ||
import React, {useContext} from 'react'; | ||
|
||
import Types from 'types'; | ||
|
||
const SubmissionContext = React.createContext({ | ||
submission: null, | ||
onSubmissionObtained: () => {}, | ||
onDestroySession: () => {}, | ||
removeSubmissionId: () => {}, | ||
}); | ||
|
||
const SubmissionProvider = ({ | ||
submission = null, | ||
onSubmissionObtained, | ||
onDestroySession, | ||
removeSubmissionId, | ||
children, | ||
}) => ( | ||
<SubmissionContext.Provider | ||
value={{submission, onSubmissionObtained, onDestroySession, removeSubmissionId}} | ||
> | ||
{children} | ||
</SubmissionContext.Provider> | ||
); | ||
|
||
SubmissionProvider.propTypes = { | ||
/** | ||
* The submission currently being filled out / submitted / viewed. It must exist in | ||
* the backend session. | ||
*/ | ||
submission: Types.Submission, | ||
/** | ||
* Callback for when a submission was (re-)loaded to store it in the state. | ||
*/ | ||
onSubmissionObtained: PropTypes.func.isRequired, | ||
/** | ||
* Callback for when an abort/logout/stop button is clicked which terminates the | ||
* form submission / session. | ||
*/ | ||
onDestroySession: PropTypes.func.isRequired, | ||
/** | ||
* Callback to remove the submission reference (it's ID) from the local storage. | ||
*/ | ||
removeSubmissionId: PropTypes.func.isRequired, | ||
}; | ||
|
||
export const useSubmissionContext = () => useContext(SubmissionContext); | ||
|
||
export default SubmissionProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters