diff --git a/src/components/overlays/CSVUploadOverlay/index.tsx b/src/components/overlays/CSVUploadOverlay/index.tsx index 5ea856d78..7ebfe0278 100644 --- a/src/components/overlays/CSVUploadOverlay/index.tsx +++ b/src/components/overlays/CSVUploadOverlay/index.tsx @@ -51,6 +51,7 @@ export default function CSVUploadOverlay(): JSX.Element { const [success, setSuccess] = useState(false) const [error, setError] = useState(false) const [errorResponse, setErrorResponse] = useState([]) + const [errorStatus, setErrorStatus] = useState(0) const renderDropArea = (props: DropAreaProps): JSX.Element => { return @@ -76,6 +77,7 @@ export default function CSVUploadOverlay(): JSX.Element { // eslint-disable-next-line } catch (err: any) { setLoading(false) + setErrorStatus(err?.status) setErrorResponse(err?.data?.error ?? []) setError(true) } @@ -161,22 +163,30 @@ export default function CSVUploadOverlay(): JSX.Element { textAlign: 'center', }} > - {errorResponse?.length > 0 ? ( + {errorStatus !== 500 ? ( <> - {errorResponse.map((text, i) => ( - - {text} + {errorResponse?.length > 0 ? ( + <> + {errorResponse.map((text, i) => ( + + {text} + + ))} + + ) : ( + + {t('content.companyData.upload.emptyError')} - ))} + )} ) : ( - {t('content.companyData.upload.emptyError')} + {errorResponse} )} @@ -193,7 +203,7 @@ export default function CSVUploadOverlay(): JSX.Element { variant="outlined" startIcon={} sx={{ marginRight: '8px' }} - disabled={errorResponse.length === 0} + disabled={errorResponse.length === 0 || errorStatus === 500} > {t('content.companyData.upload.copy')} diff --git a/src/components/pages/CompanyData/components/CompanyAddressList.tsx b/src/components/pages/CompanyData/components/CompanyAddressList.tsx index 1505ee887..1b156814d 100644 --- a/src/components/pages/CompanyData/components/CompanyAddressList.tsx +++ b/src/components/pages/CompanyData/components/CompanyAddressList.tsx @@ -182,80 +182,84 @@ export const CompanyAddressList = ({ return ( <> - {sharingStates.length > 0 && ( - page + 1} - nextPage={() => { - setPage((i) => i + 1) - }} - hideFooterPagination={true} - buttons={[ - { - title: t('content.companyData.table.buttonSite'), - click: () => { - handleSecondButtonClick() - }, - icon: , - }, - { - title: t('content.companyData.csvUploadBtn'), - click: () => dispatch(show(OVERLAYS.CSV_UPLOAD_OVERLAY)), - icon: , - }, - ]} - autoFocus={false} - onButtonClick={handleButtonClick} - rowsCount={inputs.length + outputs.length} - buttonLabel={t('content.companyData.table.buttonAddress')} - toolbarVariant="premium" - searchPlaceholder={t('content.companyData.table.search')} - columnHeadersBackgroundColor={'#FFFFFF'} - searchDebounce={1000} - noRowsMsg={t('content.companyData.table.noRowsMsg')} - title={t('content.companyData.table.title')} - getRowId={(row: { [key: string]: string }) => row.createdAt} - rows={inputs.concat(outputs)} - onCellClick={onRowClick} - error={errorObj.status === 0 ? null : errorObj} - columns={[ - { - field: 'site', - headerAlign: 'left', - align: 'left', - headerName: t('content.companyData.table.site'), - flex: 1.5, - valueGetter: ({ row }: { row: CompanyDataType }) => - row.site?.name ?? '', +
page + 1} + nextPage={() => { + setPage((i) => i + 1) + }} + hideFooterPagination={true} + buttons={[ + { + title: t('content.companyData.table.buttonSite'), + click: () => { + handleSecondButtonClick() }, - { - field: 'address', - headerAlign: 'left', - align: 'left', - headerName: t('content.companyData.table.location'), - flex: 2, - valueGetter: ({ row }: { row: CompanyDataType }) => - row.address - ? `${row.address.name ?? ''} ${row.address.physicalPostalAddress.street?.name ?? ''} ${row.address.physicalPostalAddress.street?.houseNumber ?? ''} ${row.address.physicalPostalAddress.city ?? ''} ${row.address.physicalPostalAddress.postalCode ?? ''} ${row.address.physicalPostalAddress.country ?? ''}` - : '', - }, - { - field: 'type', - headerAlign: 'left', - align: 'left', - headerName: t('content.companyData.table.type'), - flex: 1, - valueGetter: ({ row }: { row: CompanyDataType }) => - row.address.addressType === AddressType.SiteMainAddress - ? 'S' - : 'A', - }, - { - field: 'status', - headerName: t('content.companyData.table.status'), - align: 'left', - flex: 1, - renderCell: ({ row }: { row: CompanyDataType }) => { + icon: , + }, + { + title: t('content.companyData.csvUploadBtn'), + click: () => dispatch(show(OVERLAYS.CSV_UPLOAD_OVERLAY)), + icon: , + }, + ]} + autoFocus={false} + onButtonClick={handleButtonClick} + rowsCount={inputs.length + outputs.length} + buttonLabel={t('content.companyData.table.buttonAddress')} + toolbarVariant="premium" + searchPlaceholder={t('content.companyData.table.search')} + columnHeadersBackgroundColor={'#FFFFFF'} + searchDebounce={1000} + noRowsMsg={ + !isFetching && !isOutputLoading && !isInputLoading + ? t('content.companyData.table.noRowsMsg') + : '' + } + title={t('content.companyData.table.title')} + getRowId={(row: { [key: string]: string }) => row.createdAt} + rows={inputs.concat(outputs)} + onCellClick={onRowClick} + error={errorObj.status === 0 ? null : errorObj} + columns={[ + { + field: 'site', + headerAlign: 'left', + align: 'left', + headerName: t('content.companyData.table.site'), + flex: 1.5, + valueGetter: ({ row }: { row: CompanyDataType }) => + row.site?.name ?? '', + }, + { + field: 'address', + headerAlign: 'left', + align: 'left', + headerName: t('content.companyData.table.location'), + flex: 2, + valueGetter: ({ row }: { row: CompanyDataType }) => + row.address + ? `${row.address.name ?? ''} ${row.address.physicalPostalAddress.street?.name ?? ''} ${row.address.physicalPostalAddress.street?.houseNumber ?? ''} ${row.address.physicalPostalAddress.city ?? ''} ${row.address.physicalPostalAddress.postalCode ?? ''} ${row.address.physicalPostalAddress.country ?? ''}` + : '', + }, + { + field: 'type', + headerAlign: 'left', + align: 'left', + headerName: t('content.companyData.table.type'), + flex: 1, + valueGetter: ({ row }: { row: CompanyDataType }) => + row.address.addressType === AddressType.SiteMainAddress + ? 'S' + : 'A', + }, + { + field: 'status', + headerName: t('content.companyData.table.status'), + align: 'left', + flex: 1, + renderCell: ({ row }: { row: CompanyDataType }) => { + if (sharingStates.length > 0) { const status = getStatus(row.externalId) return ( ) - }, + } }, - { - field: 'details', - headerName: t('content.companyData.table.details'), - align: 'left', - flex: 1, - renderCell: () => { - return ( - { - // do nothing - }} - > - - - ) - }, + }, + { + field: 'details', + headerName: t('content.companyData.table.details'), + align: 'left', + flex: 1, + renderCell: () => { + return ( + { + // do nothing + }} + > + + + ) }, - ]} - disableColumnMenu - /> - )} + }, + ]} + disableColumnMenu + /> {details && (