Skip to content

Commit

Permalink
Merge pull request #238 from chain4travel/aeddaqqa/partner-config-v2
Browse files Browse the repository at this point in the history
fix(partnerConfig): fix matching partner with current logged in wallet
  • Loading branch information
aeddaqqa authored Sep 20, 2024
2 parents 4a4abaf + d9b1656 commit 0bcbe0f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/views/partners/MatchingPartners.tsx
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand All @@ -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 (
<>
<Typography variant="h5">Matching Partners</Typography>
Expand All @@ -30,8 +44,8 @@ const MatchingPartners = ({ state }) => {
maxWidth: theme => theme.customWidth.layoutMaxWitdh,
}}
>
{partners.data &&
partners.data.map((partner, index) => (
{matchingPartnersFiltred &&
matchingPartnersFiltred.map((partner, index) => (
<PartnerCard
onClick={() => {
navigate(partner.attributes.companyName)
Expand Down

0 comments on commit 0bcbe0f

Please sign in to comment.