Skip to content

Commit

Permalink
Merge pull request #256 from chain4travel/suite
Browse files Browse the repository at this point in the history
Link Styling Enhancement and Currency Display Fix
  • Loading branch information
aeddaqqa authored Sep 30, 2024
2 parents 96a9547 + f01cfcc commit 5e27518
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 20 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
18 changes: 14 additions & 4 deletions src/layout/PartnersLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@ const ClaimProfile = () => {
first.
</Typography>
<Typography variant="body2" textAlign={'center'}>
Contact the Camino Network Foundation via <Link onClick={generateEmail}>email</Link>{' '}
Contact the Camino Network Foundation via{' '}
<Link
component="a"
sx={{
color: theme => theme.palette.text.primary,
textDecorationColor: 'inherit',
}}
onClick={generateEmail}
>
email
</Link>{' '}
to proceed.
</Typography>
<Button
Expand Down Expand Up @@ -94,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 @@ -103,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
3 changes: 2 additions & 1 deletion src/views/partners/Partner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,14 @@ const Partner = () => {
wantedServices={state.stepsConfig[2].services}
supportedServices={state.stepsConfig[1].services}
CMAccountAddress={value?.contractCMAccountAddress}
supportedCurrencies={partner.supportedCurrencies}
partner={partner}
/>
) : (
OwnBusinsessNotOnMessenger
)}
</Box>
) : (
// <></>
partner.contractAddress && (
<Box
sx={{
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 5e27518

Please sign in to comment.