diff --git a/src/components/Actions/Items/modify.jsx b/src/components/Actions/Items/modify.jsx index 13c0b40b..7a4b18da 100644 --- a/src/components/Actions/Items/modify.jsx +++ b/src/components/Actions/Items/modify.jsx @@ -22,9 +22,14 @@ export const modify = ({ t, navigate }) => { getCreatedByApp(docs[0]) === 'mespapiers', action: docs => { const country = docs[0].metadata.country?.toLowerCase() + const searchParams = new URLSearchParams({ + model: 'scan', + ...(country && { country }) + }).toString() + navigate({ pathname: `edit/${docs[0]._id}`, - ...(country && { search: `?country=${country}` }) + search: searchParams }) }, // eslint-disable-next-line react/display-name diff --git a/src/components/Contexts/StepperDialogProvider.jsx b/src/components/Contexts/StepperDialogProvider.jsx index fc316bd6..6c341c47 100644 --- a/src/components/Contexts/StepperDialogProvider.jsx +++ b/src/components/Contexts/StepperDialogProvider.jsx @@ -18,7 +18,13 @@ import { useWebviewIntent } from 'cozy-intent' const StepperDialogContext = createContext() -export const StepperDialogProvider = ({ children, isEdit }) => { +/** + * @param {object} props + * @param {React.ReactNode} props.children + * @param {boolean} props.isEdit - True if the dialog is in edit mode + * @param {function} props.stepFilterFn - The filter function to apply on the steps + */ +export const StepperDialogProvider = ({ children, isEdit, stepFilterFn }) => { const [stepperDialogTitle, setStepperDialogTitle] = useState('') const [allCurrentSteps, setAllCurrentSteps] = useState([]) const [currentStepIndex, setCurrentStepIndex] = useState(-1) @@ -68,6 +74,7 @@ export const StepperDialogProvider = ({ children, isEdit }) => { steps: allCurrentStepsDefinitions, webviewIntent, isEdit, + stepFilterFn, fromFlagshipUpload }) setAllCurrentSteps(filteredSteps) @@ -75,7 +82,13 @@ export const StepperDialogProvider = ({ children, isEdit }) => { } buildAllCurrentSteps() } - }, [webviewIntent, currentDefinition, fromFlagshipUpload, isEdit]) + }, [ + webviewIntent, + currentDefinition, + fromFlagshipUpload, + isEdit, + stepFilterFn + ]) useEffect(() => { const loadCreatePaperDataBackup = async () => { diff --git a/src/components/ModelSteps/Scan/ScanWrapper.jsx b/src/components/ModelSteps/Scan/ScanWrapper.jsx index 45e11ac2..c8219811 100644 --- a/src/components/ModelSteps/Scan/ScanWrapper.jsx +++ b/src/components/ModelSteps/Scan/ScanWrapper.jsx @@ -1,4 +1,5 @@ import { PDFDocument } from 'pdf-lib' +import propTypes from 'prop-types' import React, { useEffect, useState } from 'react' import { useParams, useSearchParams } from 'react-router-dom' import { PaperDefinitionsStepPropTypes } from 'src/PaperDefinitionsPropTypes' @@ -37,7 +38,7 @@ const isFileEncryptedPDF = async file => { return pdf.isEncrypted } -const ScanWrapper = ({ currentStep, onClose, onBack }) => { +const ScanWrapper = ({ currentStep, onClose, onBack, onSubmit }) => { const client = useClient() const [searchParams] = useSearchParams() const { qualificationLabel } = useParams() @@ -153,6 +154,7 @@ const ScanWrapper = ({ currentStep, onClose, onBack }) => { onChangeFile={onChangeFile} onClose={onClose} onBack={onBack} + onSubmit={onSubmit} /> ) } @@ -180,7 +182,10 @@ const ScanWrapper = ({ currentStep, onClose, onBack }) => { } ScanWrapper.propTypes = { - currentStep: PaperDefinitionsStepPropTypes + currentStep: PaperDefinitionsStepPropTypes, + onClose: propTypes.func.isRequired, + onBack: propTypes.func.isRequired, + onSubmit: propTypes.func.isRequired } export default ScanWrapper diff --git a/src/components/ModelSteps/ScanResult/ScanResultActions.jsx b/src/components/ModelSteps/ScanResult/ScanResultActions.jsx deleted file mode 100644 index 83397d53..00000000 --- a/src/components/ModelSteps/ScanResult/ScanResultActions.jsx +++ /dev/null @@ -1,52 +0,0 @@ -import cx from 'classnames' -import PropTypes from 'prop-types' -import React from 'react' -import { PaperDefinitionsStepPropTypes } from 'src/PaperDefinitionsPropTypes' - -import DialogActions from 'cozy-ui/transpiled/react/DialogActions' -import Button, { ButtonLink } from 'cozy-ui/transpiled/react/deprecated/Button' -import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints' -import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' - -const ScanResultActions = ({ currentStep, onNextStep, onRepeatStep }) => { - const { t } = useI18n() - const { isMobile } = useBreakpoints() - const { multipage } = currentStep - - return ( - -