Skip to content

Commit 94e080d

Browse files
authored
Merge pull request #48 from folathecoder/smart-contract-integration
Smart contract integration
2 parents c890974 + bee9cf6 commit 94e080d

File tree

18 files changed

+1660
-794
lines changed

18 files changed

+1660
-794
lines changed

src/components/home/heroSection/projectCard/projectCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const ProjectCard = () => {
1919
<ProjectContainer>
2020
<ProjectWrapperScroll>
2121
{fetchingProjects === 2 &&
22-
projects?.slice(0, 6).map((project, index) => {
22+
projects?.slice(-6).map((project, index) => {
2323
return (
2424
<UniqueProject
2525
key={project.projectId}

src/components/project/Children/MiniChildren/Wallet/Wallet.tsx

Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
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';
26
import Image from 'next/image';
37
import { useClipboard } from 'use-clipboard-copy';
48
import {
@@ -10,17 +14,17 @@ import {
1014
WalletDeposit,
1115
WalletWithdraw,
1216
Transactions,
17+
WalletDividend,
1318
} from './WalletStyles';
14-
import { Notification } from '@/components/global';
1519
import { BsInfoCircle } from 'react-icons/bs';
1620
import { BiCopy } from 'react-icons/bi';
1721
import Tooltip from '@mui/material/Tooltip';
1822
import { CURRENCY_SYMBOL } from '@/data/appInfo';
19-
import { BarcodeGenerator } from '@/components/global';
23+
import { BarcodeGenerator, Button, Notification } from '@/components/global';
2024
import { shortenWalletAddress } from '@/helpers/formatters';
21-
import { Button } from '@/components/global';
2225
import DepositIcon from 'public/images/global/wallet/deposit-icon.png';
2326
import LockIcon from 'public/images/global/wallet/lock.png';
27+
import useWallet from '@/wallet/useWallet';
2428

2529
const 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

165170
const 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
241263
const 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+
274336
export default Wallet;

src/components/project/Children/MiniChildren/Wallet/WalletStyles.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export const WalletInfoCard = styled.div`
5757
export const WalletTransaction = styled.div`
5858
display: grid;
5959
width: 100%;
60-
/* min-height: 10rem; */
6160
grid-template-columns: 1fr;
6261
gap: 1rem;
6362
@@ -245,3 +244,31 @@ export const Transactions = styled.ul`
245244
text-underline-offset: 5px;
246245
}
247246
`;
247+
248+
export const WalletDividend = styled.div`
249+
min-height: 92px;
250+
width: 100%;
251+
border-radius: 0.5rem;
252+
display: flex;
253+
align-items: center;
254+
padding: 1rem;
255+
background-color: var(--color-bg-300);
256+
margin: 1rem 0rem;
257+
justify-content: space-between;
258+
gap: 2rem;
259+
flex-wrap: wrap;
260+
position: relative;
261+
262+
.access {
263+
background-color: hsla(218, 80%, 2%, 0.8);
264+
position: absolute;
265+
top: 0;
266+
bottom: 0;
267+
left: 0;
268+
right: 0;
269+
border: 0.1rem solid var(--color-border-100);
270+
border-radius: 0.5rem;
271+
display: grid;
272+
place-items: center;
273+
}
274+
`;

0 commit comments

Comments
 (0)