diff --git a/src/components/TermsAndConditionsCard.tsx b/src/components/SelectRoleCard.tsx similarity index 88% rename from src/components/TermsAndConditionsCard.tsx rename to src/components/SelectRoleCard.tsx index 148bf8b..061a9e9 100644 --- a/src/components/TermsAndConditionsCard.tsx +++ b/src/components/SelectRoleCard.tsx @@ -9,7 +9,7 @@ export enum Role { Participant = 'participant' } -const TermsAndConditionsCard = ({ handleAccept, handleRoleChange }: { handleAccept: () => void, handleRoleChange: (role: Role) => void }) => { +const SelectRoleCard = ({ handleAccept, handleRoleChange }: { handleAccept: () => void, handleRoleChange: (role: Role) => void }) => { const [selectedRole, setSelectedRole] = useState(Role.Participant); const [checked, setChecked] = useState(false); const [isHidden, setIsHidden] = useState(false); @@ -75,9 +75,9 @@ const TermsAndConditionsCard = ({ handleAccept, handleRoleChange }: { handleAcce Continue - setisDialogOpen(false)}/> + setisDialogOpen(false)}/> ); }; -export default TermsAndConditionsCard; +export default SelectRoleCard; diff --git a/src/components/TermsAndConditionsBox.tsx b/src/components/TermsAndConditionsBox.tsx new file mode 100644 index 0000000..27256af --- /dev/null +++ b/src/components/TermsAndConditionsBox.tsx @@ -0,0 +1,53 @@ +import React, { useState } from 'react'; +import { Document, Page, pdfjs } from 'react-pdf'; + +import { Typography } from '@mui/material'; + +// https://github.com/wojtekmaj/react-pdf?tab=readme-ov-file#import-worker-recommended +pdfjs.GlobalWorkerOptions.workerSrc = new URL( + 'pdfjs-dist/build/pdf.worker.min.mjs', + import.meta.url, +).toString(); + +const TermsAndConditionsBox = ({height}: {height: string}) => { + const [numPages, setNumPages] = useState(); + + function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { + setNumPages(numPages); + } + + return ( + <> + + Terms and Conditions + +
+ + {Array.apply(null, Array(numPages)) + .map((x, i) => i + 1) + .map((page) => { + return ( + + ); + })} + +
+ + ); +}; + +export default TermsAndConditionsBox; diff --git a/src/components/TermsAndConditionsDialog.tsx b/src/components/TermsAndConditionsDialog.tsx index 4b3a08e..9e7a294 100644 --- a/src/components/TermsAndConditionsDialog.tsx +++ b/src/components/TermsAndConditionsDialog.tsx @@ -1,22 +1,25 @@ import React from 'react'; -import { Dialog, DialogContent, DialogTitle } from '@mui/material'; +import { Button, Dialog, DialogActions, DialogContent } from '@mui/material'; -import TermsAndConditions from '../pages/TermsAndConditions'; +import TermsAndConditionsBox from './TermsAndConditionsBox'; interface TermsDialogProps { - isValidator: boolean; open: boolean; onClose: () => void; } -const TermsAndConditionsDialog: React.FC = ({ isValidator, open, onClose }) => { +const TermsAndConditionsDialog: React.FC = ({ open, onClose }) => { return ( - Onboard as a {isValidator ? "validator" : "participant"} - + + + + ); }; diff --git a/src/pages/SignWithCosmos.tsx b/src/pages/SignWithCosmos.tsx index 50f0ddf..144ce76 100644 --- a/src/pages/SignWithCosmos.tsx +++ b/src/pages/SignWithCosmos.tsx @@ -11,7 +11,7 @@ import { import { StargateClient } from "@cosmjs/stargate"; import { useWalletConnectContext } from "../context/WalletConnectContext"; -import TermsAndConditionsCard, {Role} from "../components/TermsAndConditionsCard"; +import SelectRoleCard, {Role} from "../components/SelectRoleCard"; const SignWithCosmos = () => { const { session, signClient } = useWalletConnectContext(); @@ -152,7 +152,7 @@ const SignWithCosmos = () => { }} > Please accept terms and conditions to continue - setIsTncAccepted(true)} handleRoleChange={setRole}/> + setIsTncAccepted(true)} handleRoleChange={setRole}/> Send transaction to chain Cosmos Account: diff --git a/src/pages/TermsAndConditions.tsx b/src/pages/TermsAndConditions.tsx index 34aa574..25a9879 100644 --- a/src/pages/TermsAndConditions.tsx +++ b/src/pages/TermsAndConditions.tsx @@ -1,67 +1,25 @@ -import React, { useState } from 'react'; +import React from 'react'; import { useNavigate } from 'react-router-dom'; -import { Document, Page, pdfjs } from 'react-pdf'; -import { Container, Typography, Button, Box, Paper } from '@mui/material'; +import { Container, Button, Box, Paper } from '@mui/material'; -pdfjs.GlobalWorkerOptions.workerSrc = new URL( - 'pdfjs-dist/build/pdf.worker.min.mjs', - import.meta.url, -).toString(); +import TermsAndConditionsBox from '../components/TermsAndConditionsBox'; -const TermsAndConditions = ({title, onClose} : {title?: string, onClose?: () => void }) => { - const [numPages, setNumPages] = useState(); +const TermsAndConditions = () => { const navigate = useNavigate(); - function onDocumentLoadSuccess({ numPages }: { numPages: number }): void { - setNumPages(numPages); - } - const handleAccept = () => { navigate('/connect-wallet'); }; return ( - - - Terms and Conditions - -
- - {Array.apply(null, Array(numPages)) - .map((x, i) => i + 1) - .map((page) => { - return ( - - ); - })} - -
+ + - {title === 'dialog' ? ( - - ) : ( - - )} +