-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(harvest): Extract routes v4 from Routes
- Loading branch information
Showing
2 changed files
with
100 additions
and
89 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
88 changes: 88 additions & 0 deletions
88
packages/cozy-harvest-lib/src/components/Routes/RoutesV4.jsx
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,88 @@ | ||
import React from 'react' | ||
import { Switch, Route, Redirect } from 'react-router-dom' | ||
|
||
import { ViewerModal } from '../../datacards/ViewerModal' | ||
import AccountModal from '../AccountModal' | ||
import NewAccountModal from '../NewAccountModal' | ||
import EditAccountModal from '../EditAccountModal' | ||
import KonnectorSuccess from '../KonnectorSuccess' | ||
import HarvestModalRoot from '../HarvestModalRoot' | ||
|
||
const RoutesV4 = ({ | ||
konnectorRoot, | ||
konnectorWithTriggers, | ||
accountsAndTriggers, | ||
onDismiss | ||
}) => { | ||
return ( | ||
<Switch> | ||
<Route | ||
path={`${konnectorRoot}/`} | ||
exact | ||
render={() => ( | ||
<HarvestModalRoot | ||
accounts={accountsAndTriggers} | ||
konnector={konnectorWithTriggers} | ||
/> | ||
)} | ||
/> | ||
<Route | ||
path={`${konnectorRoot}/accounts/:accountId`} | ||
exact | ||
render={({ match }) => ( | ||
<AccountModal | ||
konnector={konnectorWithTriggers} | ||
accountId={match.params.accountId} | ||
accountsAndTriggers={accountsAndTriggers} | ||
onDismiss={onDismiss} | ||
showNewAccountButton={!konnectorWithTriggers.clientSide} | ||
showAccountSelection={!konnectorWithTriggers.clientSide} | ||
/> | ||
)} | ||
/> | ||
<Route | ||
path={`${konnectorRoot}/accounts/:accountId/edit`} | ||
exact | ||
render={({ match }) => ( | ||
<EditAccountModal | ||
konnector={konnectorWithTriggers} | ||
accountId={match.params.accountId} | ||
accounts={accountsAndTriggers} | ||
/> | ||
)} | ||
/> | ||
<Route | ||
path={`${konnectorRoot}/viewer/:accountId/:folderToSaveId/:fileIndex`} | ||
exact | ||
render={routeComponentProps => <ViewerModal {...routeComponentProps} />} | ||
/> | ||
<Route | ||
path={`${konnectorRoot}/new`} | ||
exact | ||
render={() => ( | ||
<NewAccountModal | ||
konnector={konnectorWithTriggers} | ||
onDismiss={onDismiss} | ||
/> | ||
)} | ||
/> | ||
<Route | ||
path={`${konnectorRoot}/accounts/:accountId/success`} | ||
exact | ||
render={({ match }) => { | ||
return ( | ||
<KonnectorSuccess | ||
konnector={konnectorWithTriggers} | ||
accountId={match.params.accountId} | ||
accounts={accountsAndTriggers} | ||
onDismiss={onDismiss} | ||
/> | ||
) | ||
}} | ||
/> | ||
<Redirect from={`${konnectorRoot}/*`} to={`${konnectorRoot}/`} /> | ||
</Switch> | ||
) | ||
} | ||
|
||
export default RoutesV4 |