From d9b16569cbc59f31da02291a0a0a12c112d98e3e Mon Sep 17 00:00:00 2001 From: aeddaqqa Date: Fri, 20 Sep 2024 10:14:32 +0100 Subject: [PATCH] fix(partnerConfig): fix matching partner with current logged in wallet --- src/views/partners/MatchingPartners.tsx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/views/partners/MatchingPartners.tsx b/src/views/partners/MatchingPartners.tsx index 5f4e2b51..b8b92d9e 100644 --- a/src/views/partners/MatchingPartners.tsx +++ b/src/views/partners/MatchingPartners.tsx @@ -1,8 +1,9 @@ import { Box, Typography } from '@mui/material' -import React from 'react' +import React, { useMemo } from 'react' import { useNavigate } from 'react-router' import PartnerCard from '../../components/Partners/PartnerCard' import { usePartnerConfigurationContext } from '../../helpers/partnerConfigurationContext' +import { useSmartContract } from '../../helpers/useSmartContract' import { useListMatchingPartnersQuery } from '../../redux/services/partners' const MatchingPartners = ({ state }) => { @@ -17,8 +18,21 @@ const MatchingPartners = ({ state }) => { supportedResult: value?.state?.stepsConfig[1]?.services, wantedResult: value?.state?.stepsConfig[2]?.services, }) + const sc = useSmartContract() + const matchingPartnersFiltred = useMemo(() => { + return partners?.data + ? partners?.data?.filter(elem => elem.attributes.cChainAddress != sc?.wallet?.address) + : [] + }, [partners]) const navigate = useNavigate() - if (isLoading || isFetching || error || !partners || partners?.data?.length === 0) return <> + if ( + isLoading || + isFetching || + error || + !matchingPartnersFiltred || + matchingPartnersFiltred?.data?.length === 0 + ) + return <> return ( <> Matching Partners @@ -30,8 +44,8 @@ const MatchingPartners = ({ state }) => { maxWidth: theme => theme.customWidth.layoutMaxWitdh, }} > - {partners.data && - partners.data.map((partner, index) => ( + {matchingPartnersFiltred && + matchingPartnersFiltred.map((partner, index) => ( { navigate(partner.attributes.companyName)