1- import React , { useState , useEffect , useCallback } from 'react' ;
1+ import React , { useState , useEffect , useCallback , useContext } from 'react' ;
2+ import {
3+ ProjectDetailContext ,
4+ ProjectDetailContextReturnTypes ,
5+ } from '@/contexts/ProjectDetailContext' ;
26import Image from 'next/image' ;
37import { useClipboard } from 'use-clipboard-copy' ;
48import {
@@ -10,17 +14,17 @@ import {
1014 WalletDeposit ,
1115 WalletWithdraw ,
1216 Transactions ,
17+ WalletDividend ,
1318} from './WalletStyles' ;
14- import { Notification } from '@/components/global' ;
1519import { BsInfoCircle } from 'react-icons/bs' ;
1620import { BiCopy } from 'react-icons/bi' ;
1721import Tooltip from '@mui/material/Tooltip' ;
1822import { CURRENCY_SYMBOL } from '@/data/appInfo' ;
19- import { BarcodeGenerator } from '@/components/global' ;
23+ import { BarcodeGenerator , Button , Notification } from '@/components/global' ;
2024import { shortenWalletAddress } from '@/helpers/formatters' ;
21- import { Button } from '@/components/global' ;
2225import DepositIcon from 'public/images/global/wallet/deposit-icon.png' ;
2326import LockIcon from 'public/images/global/wallet/lock.png' ;
27+ import useWallet from '@/wallet/useWallet' ;
2428
2529const walletInfoData = {
2630 currentBalance : 'Current ETH balance in the wallet.' ,
@@ -73,11 +77,12 @@ const Wallet = () => {
7377 description = { walletInfoData . outstandingDividend }
7478 />
7579 </ WalletInfo >
80+ < DividendDisbursement />
7681 < WalletTransaction >
7782 < WalletDepositCard />
7883 < WalletWithdrawCard />
7984 </ WalletTransaction >
80- < AllTransactions />
85+ { /* <AllTransactions /> */ }
8186 </ WalletContainer >
8287 < Notification
8388 message = { notificationMessage }
@@ -163,6 +168,11 @@ const WalletDepositCard = () => {
163168} ;
164169
165170const WalletWithdrawCard = ( ) => {
171+ const { wallet } = useWallet ( ) ;
172+ const { project } = useContext (
173+ ProjectDetailContext
174+ ) as ProjectDetailContextReturnTypes ;
175+
166176 const [ withdrawal , setWithdrawal ] = useState ( {
167177 message : '' ,
168178 amount : '' ,
@@ -173,6 +183,13 @@ const WalletWithdrawCard = () => {
173183
174184 setWithdrawal ( ( prevState ) => ( { ...prevState , [ name ] : value } ) ) ;
175185 } ;
186+
187+ const handleWithdraw = ( ) => {
188+ if ( wallet . walletAddress === project ?. project . projectWalletAddress ) {
189+ console . log ( 'withdraw' ) ;
190+ }
191+ } ;
192+
176193 return (
177194 < WalletWithdraw >
178195 < div >
@@ -209,7 +226,7 @@ const WalletWithdrawCard = () => {
209226 < Button
210227 buttonTitle = "Withdraw"
211228 buttonType = "action"
212- buttonFunction = { ( ) => { } }
229+ buttonFunction = { handleWithdraw }
213230 />
214231 </ div >
215232 { false && (
@@ -227,17 +244,22 @@ const WalletWithdrawCard = () => {
227244 </ div >
228245 ) }
229246 </ div >
230-
231- < div className = "access" >
232- < div >
233- < Image src = { LockIcon } alt = "locked" height = { 50 } width = { 50 } />
234- </ div >
235- </ div >
247+ { wallet . walletAddress !== project ?. project . projectWalletAddress && (
248+ < Tooltip
249+ title = "You are not authorised to withdraw funds from this wallet"
250+ placement = "top"
251+ >
252+ < div className = "access" >
253+ < div >
254+ < Image src = { LockIcon } alt = "locked" height = { 30 } width = { 30 } />
255+ </ div >
256+ </ div >
257+ </ Tooltip >
258+ ) }
236259 </ WalletWithdraw >
237260 ) ;
238261} ;
239262
240- // Deposit, Withdraw, Dividend
241263const AllTransactions = ( ) => {
242264 return (
243265 < Transactions >
@@ -271,4 +293,44 @@ const AllTransactions = () => {
271293 ) ;
272294} ;
273295
296+ const DividendDisbursement = ( ) => {
297+ const { wallet } = useWallet ( ) ;
298+ const { project } = useContext (
299+ ProjectDetailContext
300+ ) as ProjectDetailContextReturnTypes ;
301+
302+ const handleDisburseDividend = ( ) => {
303+ if ( wallet . walletAddress === project ?. project . projectWalletAddress ) {
304+ console . log ( 'disbursement' ) ;
305+ }
306+ } ;
307+
308+ return (
309+ < WalletDividend >
310+ < div >
311+ < h3 > Disburse dividends to investors</ h3 >
312+ </ div >
313+ < div >
314+ < Button
315+ buttonTitle = "Pay Dividend"
316+ buttonType = "action"
317+ buttonFunction = { handleDisburseDividend }
318+ />
319+ </ div >
320+ { wallet . walletAddress !== project ?. project . projectWalletAddress && (
321+ < Tooltip
322+ title = "You are not authorised to disburse dividends"
323+ placement = "top"
324+ >
325+ < div className = "access" >
326+ < div >
327+ < Image src = { LockIcon } alt = "locked" height = { 30 } width = { 30 } />
328+ </ div >
329+ </ div >
330+ </ Tooltip >
331+ ) }
332+ </ WalletDividend >
333+ ) ;
334+ } ;
335+
274336export default Wallet ;
0 commit comments