Skip to content

Commit

Permalink
fix: create certificate button
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmagnus committed Dec 7, 2023
1 parent 68540f6 commit add606d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
7 changes: 6 additions & 1 deletion frontend/src/app/core/pages/contracts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ import { ContractsTemplate } from 'components/templates/contracts'

export const Contracts: React.FC = () => {
const { loading, getContracts, contracts } = useContracts()
const { userPermissions, getUserPermissions } = useAuth()
const { userPermissions, profile, getProfile, getUserPermissions } = useAuth()

useEffect(() => {
getContracts()
}, [getContracts])

useEffect(() => {
getProfile()
}, [getProfile])

useEffect(() => {
getUserPermissions()
}, [getUserPermissions])
Expand All @@ -27,6 +31,7 @@ export const Contracts: React.FC = () => {
loading={loading}
contracts={contracts}
userPermissions={userPermissions}
profile={profile}
/>
</Sidebar>
</Flex>
Expand Down
25 changes: 14 additions & 11 deletions frontend/src/components/templates/contracts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ interface IContractsTemplate {
loading: boolean
contracts: Hooks.UseContractsTypes.IContract[] | undefined
userPermissions: Hooks.UseAuthTypes.IUserPermission[] | undefined
profile: Hooks.UseAuthTypes.IUserDto | undefined
}

export const ContractsTemplate: React.FC<IContractsTemplate> = ({
loading,
contracts,
userPermissions,
profile,
}) => {
const navigate = useNavigate()

Expand All @@ -47,17 +49,18 @@ export const ContractsTemplate: React.FC<IContractsTemplate> = ({
<Text fontSize="2xl" fontWeight="400">
Certificate of Deposits
</Text>
{havePermission(Permissions.CREATE_CERTIFICATES, userPermissions) && (
<Button
variant="primary"
leftIcon={<NewIcon />}
onClick={(): void =>
navigate({ pathname: PathRoute.CONTRACT_CREATE })
}
>
New Certificate of Deposit
</Button>
)}
{havePermission(Permissions.CREATE_CERTIFICATES, userPermissions) &&
profile?.vault_id && (
<Button
variant="primary"
leftIcon={<NewIcon />}
onClick={(): void =>
navigate({ pathname: PathRoute.CONTRACT_CREATE })
}
>
New Certificate of Deposit
</Button>
)}
</Flex>
<Container variant="primary" p={0} maxW="full">
{loading ? (
Expand Down

0 comments on commit add606d

Please sign in to comment.