Skip to content

Commit

Permalink
update(partnernetowrk): fix duplicate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
manojava-gk committed Aug 24, 2023
1 parent 985f471 commit 1d3247c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
********************************************************************************/

import { GridColDef } from '@mui/x-data-grid'
import { IconButton } from '@catena-x/portal-shared-components'
import ArrowForwardIcon from '@mui/icons-material/ArrowForward'
// import { IconButton } from '@catena-x/portal-shared-components'
// import ArrowForwardIcon from '@mui/icons-material/ArrowForward'
import { BusinessPartner } from 'features/newPartnerNetwork/types'
import { Box } from '@mui/material'
import smallLogo from '../../../../../assets/logo/cx-logo-short.svg'
import { OVERLAYS } from 'types/Constants'
import { show } from 'features/control/overlay'
import { useDispatch } from 'react-redux'
// import { Box } from '@mui/material'
// import smallLogo from '../../../../../assets/logo/cx-logo-short.svg'
// import { OVERLAYS } from 'types/Constants'
// import { show } from 'features/control/overlay'
// import { useDispatch } from 'react-redux'

// Columns definitions of Partner Network page Data Grid
export const PartnerNetworksBPNTableColumns = (
translationHook: any
): Array<GridColDef> => {
const { t } = translationHook()
const dispatch = useDispatch()
// const dispatch = useDispatch()

return [
{
Expand All @@ -50,55 +50,55 @@ export const PartnerNetworksBPNTableColumns = (
sortable: false,
valueGetter: ({ row }: { row: BusinessPartner }) => row.bpnl,
},
{
field: 'cxmember', // Temporary field, doesnt exists yet
headerName: t('content.partnernetwork.columns.cxparticipant'),
flex: 1.5,
sortable: false,
renderCell: (params) =>
params?.row?.member ? (
<Box
component="img"
padding=".5rem"
src={smallLogo}
alt="membershipFlag"
sx={{
width: 40,
}}
/>
) : (
''
),
},
{
field: 'country',
headerName: t('content.partnernetwork.columns.country'),
flex: 1.5,
sortable: false,
valueGetter: ({ row }: { row: BusinessPartner }) =>
row?.legalAddress?.physicalPostalAddress?.country?.name ??
row?.legalAddress?.alternativePostalAddress?.country?.name ??
'',
},
{
field: 'detail',
headerName: 'Detail',
headerAlign: 'center',
flex: 0.8,
align: 'center',
renderCell: (params) =>
params?.row?.bpnl ? (
<IconButton
color="secondary"
size="small"
style={{ alignSelf: 'center' }}
onClick={() => dispatch(show(OVERLAYS.PARTNER, params.row.bpnl))}
>
<ArrowForwardIcon />
</IconButton>
) : (
<></>
),
},
// {
// field: 'cxmember', // Temporary field, doesnt exists yet
// headerName: t('content.partnernetwork.columns.cxparticipant'),
// flex: 1.5,
// sortable: false,
// renderCell: (params) =>
// params?.row?.member ? (
// <Box
// component="img"
// padding=".5rem"
// src={smallLogo}
// alt="membershipFlag"
// sx={{
// width: 40,
// }}
// />
// ) : (
// ''
// ),
// },
// {
// field: 'country',
// headerName: t('content.partnernetwork.columns.country'),
// flex: 1.5,
// sortable: false,
// valueGetter: ({ row }: { row: BusinessPartner }) =>
// row?.legalAddress?.physicalPostalAddress?.country?.name ??
// row?.legalAddress?.alternativePostalAddress?.country?.name ??
// '',
// },
// {
// field: 'detail',
// headerName: 'Detail',
// headerAlign: 'center',
// flex: 0.8,
// align: 'center',
// renderCell: (params) =>
// params?.row?.bpnl ? (
// <IconButton
// color="secondary"
// size="small"
// style={{ alignSelf: 'center' }}
// onClick={() => dispatch(show(OVERLAYS.PARTNER, params.row.bpnl))}
// >
// <ArrowForwardIcon />
// </IconButton>
// ) : (
// <></>
// ),
// },
]
}
14 changes: 2 additions & 12 deletions src/components/pages/PartnerNetwork/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ import {
} from 'features/newPartnerNetwork/partnerNetworkApiSlice'
import { PageHeader } from '@catena-x/portal-shared-components'
import { useSelector } from 'react-redux'
import { useEffect, useState } from 'react'
import { useState } from 'react'
import { updatePartnerSelector } from 'features/control/updates'
import { PartnerNetworksTableColumns } from 'components/pages/PartnerNetwork/partnerNetworkTableColumns'
import { BusinessPartner } from 'features/newPartnerNetwork/types'
import Patterns from 'types/Patterns'
import { PartnerNetworksBPNTableColumns } from './components/PartnerList/PartnerNetworksBPNTableColumns'
import { useFetchMemberCompaniesQuery } from 'features/newPartnerNetwork/partnerNetworkPortalApiSlice'
import {
isContentPresent,
Expand All @@ -47,17 +46,12 @@ const PartnerNetwork = () => {
const [refresh, setRefresh] = useState<number>(0)
const searchInputData = useSelector(updatePartnerSelector)
const columns = PartnerNetworksTableColumns(useTranslation)
const bpnColumns = PartnerNetworksBPNTableColumns(useTranslation)
const [showBPNColumn, setShowBPNColumn] = useState<boolean>(false)
const [mutationRequest] = useFetchBusinessPartnerAddressMutation()
const { data } = useFetchMemberCompaniesQuery()

const validateSearchText = (text: string): boolean =>
Patterns.SEARCH.test(text.trim())

const checkIfBPNLNumber = (text: string): boolean =>
Patterns.BPN.test(text.trim())

const [allItems, setAllItems] = useState<any>({})

const fetchAndApply = async (cData: any) => {
Expand Down Expand Up @@ -100,10 +94,6 @@ const PartnerNetwork = () => {
}
}

useEffect(() => {
if (allItems?.length) setShowBPNColumn(checkIfBPNLNumber(expr))
}, [allItems, expr])

return (
<main className="partner-network-page-container">
<PageHeader
Expand Down Expand Up @@ -132,7 +122,7 @@ const PartnerNetwork = () => {
fetchHookArgs={{ expr }}
fetchHookRefresh={refresh}
getRowId={(row: any) => row.bpnl ?? ''}
columns={!showBPNColumn ? columns : bpnColumns}
columns={columns}
callbackToPage={fetchAndApply}
allItems={allItems}
/>
Expand Down

0 comments on commit 1d3247c

Please sign in to comment.