Skip to content

Commit

Permalink
fix: Don't display the Add Account in the config dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Crash-- committed May 24, 2023
1 parent 9e531a4 commit dfbdfc5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
Expand Up @@ -30,6 +30,7 @@ export const AccountModalHeader = ({
accountsAndTriggers={accountsAndTriggers}
pushHistory={pushHistory}
replaceHistory={replaceHistory}
showAccountSelection={showAccountSelection}
/>
)

Expand Down
@@ -1,8 +1,10 @@
import cx from 'classnames'
import React from 'react'

import { models } from 'cozy-client'
import DialogBackButton from 'cozy-ui/transpiled/react/CozyDialogs/DialogBackButton'
import DialogTitle from 'cozy-ui/transpiled/react/Dialog/DialogTitle'
import Typography from 'cozy-ui/transpiled/react/Typography'

import AccountSelectBox from './AccountSelectBox'
import { useDialogContext } from '../DialogContext'
Expand All @@ -13,13 +15,15 @@ interface AccountSelectorHeaderProps {
accountsAndTriggers: (object | null | undefined)[]
pushHistory: (path: string) => void
replaceHistory: (path: string) => void
showAccountSelection: boolean
}

export const AccountSelectorHeader = ({
account,
accountsAndTriggers,
pushHistory,
replaceHistory
replaceHistory,
showAccountSelection
}: AccountSelectorHeaderProps): JSX.Element => {
// @ts-expect-error IDK
const { dialogTitleProps } = useDialogContext()
Expand All @@ -41,18 +45,22 @@ export const AccountSelectorHeader = ({
)}
disableTypography
>
<AccountSelectBox
loading={!account}
selectedAccount={account}
accountsAndTriggers={accountsAndTriggers}
onChange={(option: { account: { _id: string } }): void => {
pushHistory(`/accounts/${option.account._id}`)
}}
onCreate={(): void => {
pushHistory('/new')
}}
variant="big"
/>
{showAccountSelection ? (
<AccountSelectBox
loading={!account}
selectedAccount={account}
accountsAndTriggers={accountsAndTriggers}
onChange={(option: { account: { _id: string } }): void => {
pushHistory(`/accounts/${option.account._id}`)
}}
onCreate={(): void => {
pushHistory('/new')
}}
variant="big"
/>
) : (
<Typography>{models.account.getAccountName(account)}</Typography>
)}
</DialogTitle>
</>
)
Expand Down

0 comments on commit dfbdfc5

Please sign in to comment.