Skip to content

Commit

Permalink
feat(company certificates): company certificate details view (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
manojava-gk authored Jan 26, 2024
1 parent 1786e89 commit 0f1ee81
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Company Certificate
- Provide new link from user menu for the company certificate page
- UI components created to display filter, sort and company certificates
- Company Certificate Details overlay
- Company Roles
- Fetch the standard library data from standards.json and implement Table component to display it in the company roles section.

Expand Down
10 changes: 10 additions & 0 deletions src/assets/locales/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -1714,9 +1714,19 @@
"name": "Name",
"date": "Date"
},
"details": {
"type": "Type",
"validtill": "Valid Till",
"status": "Status",
"deletebutton": "Delete Certificate",
"fileUpload": "File Upload",
"verification": "Verification"
},
"uploadCertificate": "Upload Certificate",
"noData": "Currently there are no certificates for the company. You can start uploading a certificate by clicking the 'Upload Certificate' button above.",
"validtill": "Valid Till",
"view": "View",
"delete": "Delete",
"morelink": ">> More"
},
"companyWallet": {
Expand Down
12 changes: 11 additions & 1 deletion src/assets/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -1655,10 +1655,20 @@
"name": "Name",
"date": "Date"
},
"details": {
"type": "Type",
"validtill": "Valid Till",
"status": "Status",
"deletebutton": "Delete Certificate",
"fileUpload": "File Upload",
"verification": "Verification"
},
"uploadCertificate": "Upload Certificate",
"noData": "Currently there are no certificates for the company. You can start uploading a certificate by clicking the 'Upload Certificate' button above.",
"validtill": "Valid Till",
"morelink": ">> More"
"morelink": ">> More",
"view": "View",
"delete": "Delete"
},
"adminCertificate": {
"headline": "Credential Request Overview",
Expand Down
201 changes: 201 additions & 0 deletions src/components/overlays/CompanyCertificateDetails/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/********************************************************************************
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { useTranslation } from 'react-i18next'
import { useDispatch } from 'react-redux'
import {
Button,
Dialog,
DialogActions,
DialogContent,
Typography,
} from '@catena-x/portal-shared-components'
import { closeOverlay } from 'features/control/overlay'
import './style.scss'
import { setOverlayCancel } from 'features/companyRoles/slice'
import {
type ComapnyCertificateData,
useFetchCertificatesQuery,
useFetchDocumentQuery,
} from 'features/companyCertification/companyCertificateApiSlice'
import { Box } from '@mui/material'
import DeleteIcon from '@mui/icons-material/DeleteOutlineOutlined'
import { ProgressVerificationButton } from 'components/shared/basic/ProgressVerificationButton'
import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline'
import PendingActionsIcon from '@mui/icons-material/PendingActions'
import {
type ProgressButtonsType,
ProgressStatus,
} from 'features/admin/applicationRequestApiSlice'
import { useEffect, useState } from 'react'

export enum StatusTag {
PENDING = 'Pending',
ACTIVE = 'Active',
COMPLETED = 'completed',
}

export default function CompanyCertificateDetails({
id,
}: {
readonly id: string
}) {
const { t } = useTranslation()
const dispatch = useDispatch()
const close = () => {
dispatch(setOverlayCancel(true))
dispatch(closeOverlay())
}

const { data } = useFetchCertificatesQuery()
const { data: document } = useFetchDocumentQuery(id ?? '')

const companyData = data?.content.filter((cert) => cert.documentId === id)
const [selected, setSelected] = useState<ComapnyCertificateData>()
const [pdf, setPdf] = useState<string>()

if (companyData && companyData?.length > 0) {
setSelected(companyData[0])
}

useEffect(() => {
//set file here
setPdf('')
}, [document])

const flag = selected?.companyCertificateStatus === StatusTag.PENDING

const getButtonStatusTag = (statusId: string) => {
if (statusId === ProgressStatus.IN_PROGRESS) {
return 'label'
} else {
return 'confirmed'
}
}

const getButtonStatusId = () => {
if (selected?.companyCertificateStatus === StatusTag.PENDING) {
return ProgressStatus.IN_PROGRESS
} else {
return ProgressStatus.DONE
}
}

const statusId = getButtonStatusId()

const button: ProgressButtonsType = {
statusId,
typeId: '',
backgroundColor: flag ? '#F5F9EE' : '#EAF1FE',
icon: flag ? (
<CheckCircleOutlineIcon
style={{
color: '#00AA55',
height: '30px',
width: '20px',
}}
/>
) : (
<PendingActionsIcon
style={{
color: '#0F71CB',
height: '20px',
width: '20px',
}}
/>
),
label: flag
? t('content.companyCertificate.details.fileUpload')
: t('content.companyCertificate.details.verification'),
statusTag: getButtonStatusTag(
flag ? ProgressStatus.DONE : ProgressStatus.IN_PROGRESS
),
statusLabel: flag ? StatusTag.COMPLETED : StatusTag.PENDING,
}

return (
<Dialog
open={true}
additionalModalRootStyles={{
'.MuiPaper-root': {
maxWidth: '60% !important',
},
}}
>
<DialogContent>
{selected ? (
<>
<Box className="box-container">
<Box className="header-container">
<Box className="flex-container">
<Typography variant="label3">
{t('content.companyCertificate.details.type')} :{' '}
{selected.companyCertificateType}
</Typography>
<Typography variant="h5">{selected.documentId}</Typography>
<Typography variant="label4">
{t('content.companyCertificate.details.validtill')} :{' '}
{selected.validTill}
</Typography>
<Typography variant="label4">
{t('content.companyCertificate.details.status')} :{' '}
{selected.companyCertificateStatus}
</Typography>
</Box>
<Box>
<Button
startIcon={<DeleteIcon />}
variant="outlined"
size="small"
onClick={close}
>
{t('content.companyCertificate.details.deletebutton')}
</Button>
</Box>
</Box>
</Box>
<Box className="iframe-container">
<Box className="verification-container">
<ProgressVerificationButton {...button} />
</Box>
{pdf && (
<iframe
title="certificate document"
src={pdf}
width="100%"
height="500px"
/>
)}
</Box>
</>
) : (
<Typography variant="body1">
{t('content.companyCertificate.noData')}
</Typography>
)}
</DialogContent>

<DialogActions>
<Button variant="outlined" onClick={close}>
{t('global.actions.close')}
</Button>
</DialogActions>
</Dialog>
)
}
48 changes: 48 additions & 0 deletions src/components/overlays/CompanyCertificateDetails/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/********************************************************************************
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

.box-container {
padding: 20px 40px;
background-color: #f7f7f7;
position: absolute;
height: 160px;
width: 100%;
left: 0px;
display: block;
display: flex;
text-align: left;
align-items: center;

.header-container {
margin-left: 40px;
margin-right: 40px;
display: flex;
justify-content: space-between;
width: 100%;
align-items: center;
}

.flex-container {
display: grid;
}
}

.iframe-container {
margin-top: 200px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
********************************************************************************/

import Box from '@mui/material/Box'
import { Typography, StatusTag } from '@catena-x/portal-shared-components'
import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline'
import ReportProblemIcon from '@mui/icons-material/ReportProblem'
import LoopIcon from '@mui/icons-material/Loop'
Expand All @@ -30,6 +29,7 @@ import {
} from 'features/admin/applicationRequestApiSlice'
import { useState, useEffect, useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { ProgressVerificationButton } from 'components/shared/basic/ProgressVerificationButton'

interface CheckListFullButtonsProps {
progressButtons?: Array<ProgressButtonsType>
Expand Down Expand Up @@ -143,58 +143,7 @@ export default function CheckListFullButtons({
{checkListButtons && (
<Box>
{checkListButtons.map((button: ProgressButtonsType) => (
<Box
key={button.typeId}
sx={{
display: 'flex',
placeItems: 'center',
flexDirection: 'row',
margin: '0px 0px 20px 0px',
width: '100%',
height: '60px',
padding: '12px 8px',
borderRadius: '6px',
backgroundColor: button?.backgroundColor ?? '#fff',
color: '#111',
fontSize: '14px',
outlined: 'none',
}}
>
<Box
sx={{
display: 'flex',
justifyContent: 'space-between',
flexDirection: 'row',
width: '100%',
}}
>
<Box
sx={{
paddingLeft: '5px',
display: 'flex',
placeItems: 'center',
flexDirection: 'row',
}}
>
{button.icon}
<Typography
sx={{
paddingLeft: '15px',
}}
variant="h4"
>
{' '}
{button.label}
</Typography>
</Box>
<Box>
<StatusTag
color={button.statusTag}
label={button.statusLabel}
/>
</Box>
</Box>
</Box>
<ProgressVerificationButton key={button.typeId} {...button} />
))}
</Box>
)}
Expand Down
Loading

0 comments on commit 0f1ee81

Please sign in to comment.