diff --git a/src/components/Partners/PartnersFilter.tsx b/src/components/Partners/PartnersFilter.tsx index 713426d8..82ecb1e4 100644 --- a/src/components/Partners/PartnersFilter.tsx +++ b/src/components/Partners/PartnersFilter.tsx @@ -1,8 +1,12 @@ import { ActionType, StatePartnersType, partnersActions } from '../../helpers/partnersReducer' import { Box, Button, Checkbox, FormControlLabel, Typography } from '@mui/material' -import React from 'react' +import React, { useMemo } from 'react' +import store from 'wallet/store' import { REGISTER_PARTNER_URL } from '../../constants/route-paths' +import { useAppSelector } from '../../hooks/reduxHooks' +import { useIsPartnerQuery } from '../../redux/services/partners' +import { getActiveNetwork } from '../../redux/slices/network' import BusinessFieldFilter from './BusinessFieldFilter' import SearchInput from './SearchInput' @@ -14,6 +18,21 @@ interface PartnersFilterProps { const PartnersFilter: React.FC = ({ state, dispatchPartnersActions }) => { const searchByName = param => dispatchPartnersActions({ type: partnersActions.UPDATE_COMPANY_NAME, payload: param }) + + const activeNetwork = useAppSelector(getActiveNetwork) + const { data } = useIsPartnerQuery({ + cChainAddress: store?.state?.activeWallet?.ethAddress + ? '0x' + store?.state?.activeWallet?.ethAddress + : '', + }) + const partnerCChainAddress = useMemo(() => { + let cAddress = data?.attributes?.cChainAddresses.find( + elem => elem.Network === activeNetwork?.name?.toLowerCase(), + ) + if (cAddress) return cAddress + return '' + }, [data]) + const auth = useAppSelector(state => state.appConfig.isAuth) return ( = ({ state, dispatchPartners /> - - - + + + )} ) } diff --git a/src/views/partners/Partner.tsx b/src/views/partners/Partner.tsx index 7b7e8d05..5a1fbca7 100644 --- a/src/views/partners/Partner.tsx +++ b/src/views/partners/Partner.tsx @@ -446,16 +446,24 @@ const Partner = () => { useEffect(() => { if (activeNetwork) refetch() }, [activeNetwork]) - const chackValidatorStatus = async (address: string) => { - if (!partner.attributes.pChainAddress) setIsValidator(false) + + const partnerPChainAddress = useMemo(() => { + let pAddress = partner?.attributes?.pChainAddresses.find( + elem => elem.Network === activeNetwork?.name?.toLowerCase(), + )?.pAddress + if (pAddress) return pAddress + return '' + }, [partner, validators]) + + const chackValidatorStatus = async (address?: string) => { + if (partnerPChainAddress) setIsValidator(false) let nodeID = await getRegisteredNode(getAddress(address)) setIsValidator(!!validators.find(v => v.nodeID === nodeID)) } useEffect(() => { - if (partner?.attributes.pChainAddress) - chackValidatorStatus(partner.attributes.pChainAddress) - }, [partner, validators]) + if (partnerPChainAddress) chackValidatorStatus(partnerPChainAddress) + }, [partnerPChainAddress]) if (error || (!partner && !isFetching && !isLoading)) { navigate('/partners') @@ -523,23 +531,6 @@ const Partner = () => { }} > {partner.attributes.companyName} - {/* the badge validator will be added when the api support getting p-chain - address */} - {/* {!!isConsortiumMember && ( - theme.palette.background.gradient, - padding: '10px 14px 8px 12px', - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - borderRadius: theme => theme.shape.borderRadius, - width: 'fit-content', - }} - > - Validator - - )} */} {!!isValidator && ( @@ -564,7 +555,7 @@ const Partner = () => { )} - {partner.contractAddress && ( + {!!partner.contractAddress && (