Skip to content

Commit

Permalink
feat(PartnerConfig): added check to register as partner button
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddaqqa committed Oct 21, 2024
1 parent 40ed4e2 commit acc50e8
Showing 1 changed file with 41 additions and 20 deletions.
61 changes: 41 additions & 20 deletions src/components/Partners/PartnersFilter.tsx
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -14,6 +18,21 @@ interface PartnersFilterProps {
const PartnersFilter: React.FC<PartnersFilterProps> = ({ 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 (
<Box
sx={{
Expand Down Expand Up @@ -76,28 +95,30 @@ const PartnersFilter: React.FC<PartnersFilterProps> = ({ state, dispatchPartners
/>
</Box>
</Box>
<Box
sx={{
flex: '1',
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'flex-start',
}}
>
<Button
variant="contained"
component="a"
href={REGISTER_PARTNER_URL}
target="_blank"
rel="noopener noreferrer"
{(!auth || !partnerCChainAddress) && (
<Box
sx={{
whiteSpace: 'nowrap',
minWidth: 'max-content',
flex: '1',
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'flex-start',
}}
>
Register as Partner
</Button>
</Box>
<Button
variant="contained"
component="a"
href={REGISTER_PARTNER_URL}
target="_blank"
rel="noopener noreferrer"
sx={{
whiteSpace: 'nowrap',
minWidth: 'max-content',
}}
>
Register as Partner
</Button>
</Box>
)}
</Box>
)
}
Expand Down

0 comments on commit acc50e8

Please sign in to comment.