diff --git a/src/api/user.ts b/src/api/user.ts
index ca7d6f42..5a7fa7ee 100644
--- a/src/api/user.ts
+++ b/src/api/user.ts
@@ -15,6 +15,7 @@ export interface PutPostUser {
avatarMediaPath?: string;
beneficiary?: any;
bio?: string;
+ borrower?: any;
children?: number;
councilMember?: any;
country?: string;
diff --git a/src/components/CheckPermission.tsx b/src/components/CheckPermission.tsx
new file mode 100644
index 00000000..c773a2f4
--- /dev/null
+++ b/src/components/CheckPermission.tsx
@@ -0,0 +1,38 @@
+import {
+ Box,
+ Card,
+ CircledIcon,
+ Display,
+ ViewContainer
+} from '@impact-market/ui';
+import Message from 'src/libs/Prismic/components/Message';
+import React from 'react';
+import styled from 'styled-components';
+
+const CardStyled = styled(Card)`
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ gap: 1rem;
+ padding: 2rem;
+`;
+
+const CheckPermission = ({ title }: { title?: string }) => (
+
+ {title && (
+
+ {title}
+
+ )}
+
+
+
+
+
+
+
+);
+
+export default CheckPermission;
diff --git a/src/components/ConnectWallet.tsx b/src/components/ConnectWallet.tsx
new file mode 100644
index 00000000..7c37a97c
--- /dev/null
+++ b/src/components/ConnectWallet.tsx
@@ -0,0 +1,72 @@
+import {
+ Box,
+ Button,
+ Card,
+ CircledIcon,
+ Display,
+ ViewContainer
+} from '@impact-market/ui';
+import Message from 'src/libs/Prismic/components/Message';
+import React, { useState } from 'react';
+import String from '../libs/Prismic/components/String';
+import styled from 'styled-components';
+import useWallet from 'src/hooks/useWallet';
+
+const CardStyled = styled(Card)`
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ gap: 1rem;
+ padding: 2rem;
+`;
+
+const ConnectWallet = ({ title }: { title?: string }) => {
+ const { connect } = useWallet();
+
+ const ConnectButton = (props: any) => {
+ const [isConnecting, setIsConnecting] = useState(false);
+
+ const handleConnectClick = async () => {
+ setIsConnecting(true);
+
+ await connect();
+
+ setIsConnecting(false);
+ };
+
+ return (
+
+ );
+ };
+
+ return (
+
+ {title && (
+
+ {title}
+
+ )}
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default ConnectWallet;
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index b09a4123..f501eef6 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -86,6 +86,9 @@ const getUserType = (user: User) => {
if (user?.roles?.includes('loanManager')) {
return 'loan-manager';
}
+ if (user?.roles?.includes('borrower')) {
+ return 'borrower';
+ }
return 'donor';
};
diff --git a/src/constants/userTypes.ts b/src/constants/userTypes.ts
index 31de44e1..acce2ee0 100644
--- a/src/constants/userTypes.ts
+++ b/src/constants/userTypes.ts
@@ -1,6 +1,7 @@
const types = {
ambassador: 'ambassador',
beneficiary: 'beneficiary',
+ borrower: 'borrower',
councilMember: 'councilMember',
demo: 'demo',
donor: 'donor',
diff --git a/src/hooks/useGuard.tsx b/src/hooks/useGuard.tsx
index 4ab2cbde..e8384671 100644
--- a/src/hooks/useGuard.tsx
+++ b/src/hooks/useGuard.tsx
@@ -12,6 +12,7 @@ import {
getUserTypes,
userAmbassador,
userBeneficiary,
+ userBorrower,
userCouncilMember,
userLoanManager,
userManager
@@ -91,6 +92,10 @@ const useGuard = (options: UseGuardType) => {
if (type?.includes(userCouncilMember)) {
userPaths = userPaths.concat(councilMemberRoutes);
}
+
+ if (type?.includes(userBorrower)) {
+ userPaths = userPaths.concat(borrowerRoutes);
+ }
}
// TEMPORARY
diff --git a/src/utils/routes.ts b/src/utils/routes.ts
index 9cf95dec..16b649c1 100644
--- a/src/utils/routes.ts
+++ b/src/utils/routes.ts
@@ -26,7 +26,8 @@ export const publicRoutes: Routes = [
...laePublicRoutes,
'/microcredit/application',
'/microcredit/apply',
- '/microcredit/form/[id]'
+ '/microcredit/form/[id]',
+ '/microcredit'
];
export const privateRoutes: Routes = ['/profile', '/settings', '/mycommunity'];
diff --git a/src/utils/users.ts b/src/utils/users.ts
index e89795f2..1979e945 100644
--- a/src/utils/users.ts
+++ b/src/utils/users.ts
@@ -11,6 +11,7 @@ export const userManager = 'manager';
export const userBeneficiary = 'beneficiary';
export const userCouncilMember = 'councilMember';
export const userLoanManager = 'loanManager';
+export const userBorrower = 'borrower';
export const getUserTypes = (user: PutPostUser) => {
const types = [userDonor];
@@ -20,6 +21,7 @@ export const getUserTypes = (user: PutPostUser) => {
if (user?.councilMember) types.push(userCouncilMember);
if (user?.ambassador) types.push(userAmbassador);
if (user?.loanManager) types.push(userLoanManager);
+ if (user?.borrower) types.push(userBorrower);
return types;
};
diff --git a/src/views/MicroCredit/index.tsx b/src/views/MicroCredit/index.tsx
index dbf626ab..59b4617d 100644
--- a/src/views/MicroCredit/index.tsx
+++ b/src/views/MicroCredit/index.tsx
@@ -8,6 +8,7 @@ import { useLazyGetBorrowerQuery } from '../../api/microcredit';
import { useRouter } from 'next/router';
import { useSelector } from 'react-redux';
import ClaimLoan from './ClaimLoan';
+import ConnectWallet from 'src/components/ConnectWallet';
import LoanCompleted from './LoanCompleted';
import LoanRejected from './LoanRejected';
import LoanRepayment from './LoanRepayment';
@@ -17,7 +18,6 @@ import String from '../../libs/Prismic/components/String';
import useFilters from 'src/hooks/useFilters';
import useTranslations from '../../libs/Prismic/hooks/useTranslations';
// import InfoAccordion from './InfoAccordion';
-
import BigNumber from 'bignumber.js';
import processTransactionError from 'src/utils/processTransactionError';
import usePactPriceUSD from 'src/hooks/usePactPriceUSD';
@@ -53,7 +53,7 @@ const MicroCredit = (props: any) => {
).toString();
getEstimatedLoanRewards(result);
- }, [loan]);
+ }, [loan, auth?.user?.address]);
const router = useRouter();
const { getByKey } = useFilters();
@@ -131,9 +131,8 @@ const MicroCredit = (props: any) => {
useEffect(() => {
if (isErrorGetBorrower) {
processTransactionError(errorGetBorrower, 'loading_borrower_page');
- router.push('/');
}
- }, [isErrorGetBorrower]);
+ }, [isErrorGetBorrower, auth?.user?.address]);
useEffect(() => {
const getLoans = async () => {
@@ -171,20 +170,20 @@ const MicroCredit = (props: any) => {
} else {
setLoanId(activeLoanId);
}
- } else {
- router.push('/');
}
};
getLoans().catch((e) => {
+ console.log(e);
processTransactionError(e, 'loading_borrower_page');
- router.push('/');
});
- }, []);
+ }, [auth?.user?.address]);
useEffect(() => {
setIsOverviewOpen(loan.startDate === 0);
- }, [isReady]);
+ }, [isReady, auth?.user?.address]);
+
+ if (!auth?.user?.address) return ;
return (
{
(!isReady && loading) || !isPactPriceReady || !isRewardsReady
}
>
- {/* */}
{getByKey('contractAddress') && (
router.back()}>