Skip to content

Commit

Permalink
🐛 is purchase ready
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMazout committed May 8, 2024
1 parent 6ba2779 commit 445fb9e
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions motivator/src/app/payment/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ type Props = {}

const Payment = (props: Props) => {
// Using wagmi hook to get status of user
const { address } = useAccount()
const { address, isConnected } = useAccount()

// Using session hook to get status of user
const [assessorSlotFinded, setAssessorSlotFinded] = useState(false)

const [isPurchaseReady, setIsPurchaseReady] = useState(isConnected)

const {
data: assessorSlot,
refetch,
Expand All @@ -39,6 +41,21 @@ const Payment = (props: Props) => {
}
}, [address, statusAssessorSlot])

useEffect(() => {
console.log('isConnected', isConnected)
console.log('statusAssessorSlot', statusAssessorSlot)
console.log('isPurchaseReady', isPurchaseReady)
if (
isConnected &&
statusAssessorSlot == 'success' &&
!isPurchaseReady
) {
setIsPurchaseReady(true)
} else {
setIsPurchaseReady(false)
}
}, [isConnected, statusAssessorSlot])

useEffect(() => {
if (assessorSlot?.res?.id) {
setAssessorSlotFinded(true)
Expand Down Expand Up @@ -171,12 +188,8 @@ const Payment = (props: Props) => {
<Button
onClick={handleOnClick}
variant={'submit'}
className={cn(
statusAssessorSlot == 'pending' ??
'disabled:cursor-not-allowed',
'w-1/2'
)}
disabled={statusAssessorSlot == 'pending'}
className={cn('disabled:cursor-not-allowed', 'w-1/2')}
disabled={!isPurchaseReady}
>
Send {value} $SETH
</Button>
Expand Down

0 comments on commit 445fb9e

Please sign in to comment.