Skip to content

Commit

Permalink
Replace withdraw action for revenue split for non token channels
Browse files Browse the repository at this point in the history
  • Loading branch information
ikprk committed Jul 25, 2024
1 parent 41fa61a commit 46e7e40
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useNavigate } from 'react-router'
import { CSSTransition } from 'react-transition-group'
import useResizeObserver from 'use-resize-observer'

import { useGetFullCreatorTokenQuery } from '@/api/queries/__generated__/creatorTokens.generated'
import { StartRevenueShare } from '@/components/_crt/StartRevenueShareModal'
import { absoluteRoutes } from '@/config/routes'
import { useAuth } from '@/providers/auth/auth.hooks'
import { useAuthStore } from '@/providers/auth/auth.store'
Expand Down Expand Up @@ -37,9 +39,16 @@ export const MemberDropdown = forwardRef<HTMLDivElement, MemberDropdownProps>(
} = useAuthStore()
const [showWithdrawDialog, setShowWithdrawDialog] = useState(false)
const [disableScrollDuringAnimation, setDisableScrollDuringAnimation] = useState(true)
const [openRevenueShareModal, setOpenRevenueShareModal] = useState(false)

const [showSendDialog, setShowSendDialog] = useState(false)
const selectedChannel = activeMembership?.channels.find((chanel) => chanel.id === channelId)
const { data: tokenData } = useGetFullCreatorTokenQuery({
variables: {
id: activeChannel?.creatorToken?.token.id ?? '',
},
skip: !activeChannel?.creatorToken?.token.id,
})
const memoizedChannelStateBloatBond = useMemo(() => {
return new BN(selectedChannel?.channelStateBloatBond || 0)
}, [selectedChannel?.channelStateBloatBond])
Expand Down Expand Up @@ -131,6 +140,13 @@ export const MemberDropdown = forwardRef<HTMLDivElement, MemberDropdownProps>(
totalBalance={totalBalance}
channelId={channelId}
/>
{tokenData?.creatorTokenById ? (
<StartRevenueShare
show={openRevenueShareModal}
token={tokenData.creatorTokenById}
onClose={() => setOpenRevenueShareModal(false)}
/>
) : null}
<SendFundsDialog show={showSendDialog} onExitClick={toggleSendDialog} accountBalance={accountBalance} />

<CSSTransition classNames={transitions.names.dropdown} in={isActive} timeout={0} mountOnEnter unmountOnExit>
Expand Down Expand Up @@ -161,9 +177,14 @@ export const MemberDropdown = forwardRef<HTMLDivElement, MemberDropdownProps>(
channelId={channelId}
unseenNotificationsCounts={unseenNotificationsCounts}
onSignOut={handleLogout}
onShowFundsDialog={() =>
onShowFundsDialog={() => {
if (activeChannel?.creatorToken?.token.id) {
setOpenRevenueShareModal(true)
return
}

dropdownType === 'channel' ? setShowWithdrawDialog(true) : setShowSendDialog(true)
}
}}
accountBalance={accountBalance}
onAddNewChannel={handleAddNewChannel}
channelBalance={channelBalance}
Expand Down

0 comments on commit 46e7e40

Please sign in to comment.