Skip to content

Commit

Permalink
Merge pull request #257 from chain4travel/aeddaqqa/fixes
Browse files Browse the repository at this point in the history
fix(partnerConfig): added check for CMaccount created and claim profile
  • Loading branch information
aeddaqqa authored Sep 30, 2024
2 parents 8c1abe2 + 6b68800 commit f01cfcc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/components/Partners/PartnerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const PartnerCard: React.FC<PartnerCardProps> = ({ partner, clickable, onClick }
useEffect(() => {
if (pChainAddresses) {
let partnerAddresses = pChainAddresses.find(
elem => elem.Network.toLowerCase() === activeNetwork.name.toLowerCase(),
elem => elem.Network.toLowerCase() === activeNetwork?.name?.toLowerCase(),
)
if (partnerAddresses) chackValidatorStatus(partnerAddresses.pAddress)
}
Expand Down
10 changes: 5 additions & 5 deletions src/helpers/useSmartContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ export const SmartContractProvider: React.FC<SmartContractProviderProps> = ({ ch
)
try {
if (
activeNetwork.name.toLowerCase() !== 'columbus' &&
activeNetwork.name.toLowerCase() !== 'camino'
activeNetwork?.name?.toLowerCase() !== 'columbus' &&
activeNetwork?.name?.toLowerCase() !== 'camino'
)
return
let contractAddress =
activeNetwork.name.toLowerCase() === 'columbus'
activeNetwork?.name?.toLowerCase() === 'columbus'
? CONTRACTCMACCOUNTMANAGERADDRESSCOLUMBUS
: CONTRACTCMACCOUNTMANAGERADDRESSCAMINO
if (auth) {
Expand Down Expand Up @@ -148,8 +148,8 @@ export const SmartContractProvider: React.FC<SmartContractProviderProps> = ({ ch
const path = window.location.pathname
useEffect(() => {
if (
activeNetwork.name.toLowerCase() === 'columbus' ||
activeNetwork.name.toLowerCase() === 'camino'
activeNetwork?.name?.toLowerCase() === 'columbus' ||
activeNetwork?.name?.toLowerCase() === 'camino'
) {
setAccountReadContract(null)
setAccountWriteContract(null)
Expand Down
6 changes: 3 additions & 3 deletions src/layout/PartnersLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const PartnersLayout = () => {

const partnerCChainAddress = useMemo(() => {
let cAddress = data?.attributes?.cChainAddresses.find(
elem => elem.Network === activeNetwork.name.toLowerCase(),
elem => elem.Network === activeNetwork?.name?.toLowerCase(),
)
if (cAddress) return cAddress
return ''
Expand All @@ -113,8 +113,8 @@ const PartnersLayout = () => {
if (
path.includes('partners/messenger-configuration') &&
!store.state.isAuth &&
(activeNetwork.name.toLowerCase() !== 'columbus' ||
activeNetwork.name.toLowerCase() !== 'camino')
(activeNetwork?.name?.toLowerCase() !== 'columbus' ||
activeNetwork?.name?.toLowerCase() !== 'camino')
) {
return <Navigate to="/login" replace />
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/landing/LandingPage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Box, Grid, Typography } from '@mui/material'
import { changeActiveApp, getAllApps } from '../../redux/slices/app-config'

import LandingPageAppWidget from './LandingPageAppWidget'
import React from 'react'
import { getActiveNetwork } from '../../redux/slices/network'
import { useAppSelector } from '../../hooks/reduxHooks'
import { useDispatch } from 'react-redux'
import { useNavigate } from 'react-router'
import { useAppSelector } from '../../hooks/reduxHooks'
import { getActiveNetwork } from '../../redux/slices/network'
import LandingPageAppWidget from './LandingPageAppWidget'

export default function LandingPage() {
const activeNetwork = useAppSelector(getActiveNetwork)
Expand Down
25 changes: 21 additions & 4 deletions src/views/partners/MatchingPartners.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Box, Typography } from '@mui/material'
import React, { useEffect, useMemo } from 'react'
import { useNavigate } from 'react-router'
import store from 'wallet/store'
import PartnerCard from '../../components/Partners/PartnerCard'
import { usePartnerConfigurationContext } from '../../helpers/partnerConfigurationContext'
import { useSmartContract } from '../../helpers/useSmartContract'
import { useAppSelector } from '../../hooks/reduxHooks'
import { useListMatchingPartnersQuery } from '../../redux/services/partners'
import { useIsPartnerQuery, useListMatchingPartnersQuery } from '../../redux/services/partners'
import { getActiveNetwork } from '../../redux/slices/network'

const MatchingPartners = ({ state }) => {
Expand All @@ -21,29 +22,45 @@ const MatchingPartners = ({ state }) => {
supportedResult: value?.state?.stepsConfig[1]?.services,
wantedResult: value?.state?.stepsConfig[2]?.services,
})
const { data, refetch: refetchIsPartner } = useIsPartnerQuery({
cChainAddress: store?.state?.activeWallet?.ethAddress
? '0x' + store?.state?.activeWallet?.ethAddress
: '',
})
const activeNetwork = useAppSelector(getActiveNetwork)
const sc = useSmartContract()
const matchingPartnersFiltred = useMemo(() => {
return partners?.data
? partners?.data?.filter(elem => {
let address = elem?.attributes?.cChainAddresses.find(
elem => elem.Network.toLowerCase() === activeNetwork.name.toLowerCase(),
elem => elem.Network.toLowerCase() === activeNetwork?.name?.toLowerCase(),
)?.cAddress
if (address !== sc?.wallet?.address) return true
return false
})
: []
}, [partners])
const partnerCChainAddress = useMemo(() => {
let cAddress = data?.attributes?.cChainAddresses.find(
elem => elem.Network === activeNetwork?.name?.toLowerCase(),
)
if (cAddress) return cAddress
return ''
}, [data])
useEffect(() => {
if (activeNetwork) refetch()
if (activeNetwork) {
refetch()
refetchIsPartner()
}
}, [activeNetwork])
const navigate = useNavigate()
if (
isLoading ||
isFetching ||
error ||
!matchingPartnersFiltred ||
matchingPartnersFiltred?.length === 0
matchingPartnersFiltred?.length === 0 ||
!partnerCChainAddress
)
return <></>
return (
Expand Down
4 changes: 2 additions & 2 deletions src/views/settings/Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export default function Links({ type = 'else', partner }: { type?: string; partn
/>,
auth &&
store.state.activeWallet?.type !== 'multisig' &&
(activeNetwork.name.toLowerCase() === 'columbus' ||
activeNetwork.name.toLowerCase() === 'camino') && (
(activeNetwork?.name?.toLowerCase() === 'columbus' ||
activeNetwork?.name?.toLowerCase() === 'camino') && (
<Tab
onClick={() => navigate('/partners/messenger-configuration')}
className="tab"
Expand Down

0 comments on commit f01cfcc

Please sign in to comment.