Skip to content

Commit

Permalink
feat: Add two more intent route.
Browse files Browse the repository at this point in the history
You now need to use `path` option in Intent to select route
  • Loading branch information
JF-Cozy committed Dec 18, 2024
1 parent db5078c commit 9dffdd6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/targets/intents/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ import setupApp from 'src/targets/browser/setupApp'
import { EditLoader } from 'src/components/Views/Edit'
import { AppProviders } from 'src/components/AppProviders'
import ErrorBoundary from 'src/components/Views/ErrorBoundary'
import ContactEdit from 'src/components/Views/ContactEdit'
import InformationEdit from 'src/components/Views/InformationEdit'

export const IntentWrapper = () => {
export const IntentWrapper = ({ Component }) => {
const { service } = useIntent()

return <EditLoader onClose={service.cancel} onSubmit={service.terminate} />
return <Component onClose={service.cancel} onSubmit={service.terminate} />
}

const IntentLoader = () => {
const { data } = useIntent()

return <Navigate to={`${data.qualificationLabel}/${data.fileId}`} replace />
return <Navigate to={data.path} replace />
}

const makeRoutes = ({ client, intentId, ...rest }) => [
Expand All @@ -57,7 +59,17 @@ const makeRoutes = ({ client, intentId, ...rest }) => [
},
{
path: ':qualificationLabel/:fileId',
element: <IntentWrapper />,
element: <IntentWrapper Component={EditLoader} />,
errorElement: <ErrorBoundary />
},
{
path: ':qualificationLabel/:fileId/edit/information',
element: <IntentWrapper Component={InformationEdit} />,
errorElement: <ErrorBoundary />
},
{
path: ':qualificationLabel/:fileId/edit/contact',
element: <IntentWrapper Component={ContactEdit} />,
errorElement: <ErrorBoundary />
}
]
Expand Down

0 comments on commit 9dffdd6

Please sign in to comment.