Skip to content

Commit

Permalink
Add Terms and Conditions dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharqiewicz committed Aug 16, 2024
1 parent 078b831 commit 1e31a45
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 8 deletions.
50 changes: 50 additions & 0 deletions src/components/TermsAndConditions/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { useState } from 'preact/compat';
import { Button, Checkbox, Link } from 'react-daisyui';
import { useLocalStorage } from '../../hooks/useLocalStorage';
import { Dialog } from '../Dialog';

export const TermsAndConditions = () => {
const { set, state } = useLocalStorage<string | undefined>({ key: 'TERMS_AND_CONDITIONS' });
const [checked, setChecked] = useState<boolean>(false);

const acceptTerms = () => {
set('accepted');
};

const content = (
<>
<div className="mb-5 text-lg">
<Link
style={{ textDecoration: 'underline' }}
color="accent"
target="_blank"
rel="noreferrer"
href="https://pendulumchain.org/legal/portal-terms-and-conditions"
>
View Terms and Conditions
</Link>
</div>
<div className="flex text-lg">
<Checkbox checked={checked} onClick={() => setChecked(!checked)} color="primary" size="md" />
<span className="pl-2">I have read and accept the terms and conditions</span>
</div>
</>
);

const actions = (
<Button className="w-full px-12 text-thin" color="primary" onClick={acceptTerms} disabled={!checked}>
Agree
</Button>
);

return (
<Dialog
content={content}
headerText="T&Cs"
visible={!state}
actions={actions}
hideCloseButton={true}
disableNativeEvents={true}
/>
);
};
20 changes: 12 additions & 8 deletions src/pages/swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { multiplyByPowerOfTen, stringifyBigWithSignificantDecimals } from '../..
import { ProgressPage } from '../progress';
import { SuccessPage } from '../success';
import { FailurePage } from '../failure';
import { TermsAndConditions } from '../../components/TermsAndConditions';

const Arrow = () => (
<div className="flex justify-center w-full my-5">
Expand Down Expand Up @@ -189,14 +190,17 @@ export const SwapPage = () => {
}));

const modals = (
<PoolSelectorModal
open={!!modalType}
onSelect={modalType === 'from' ? onFromChange : onToChange}
definitions={definitions}
selected={modalType === 'from' ? from : to}
onClose={() => setModalType(undefined)}
isLoading={false}
/>
<>
<TermsAndConditions />
<PoolSelectorModal
open={!!modalType}
onSelect={modalType === 'from' ? onFromChange : onToChange}
definitions={definitions}
selected={modalType === 'from' ? from : to}
onClose={() => setModalType(undefined)}
isLoading={false}
/>
</>
);

if (offrampingPhase === 'success') {
Expand Down

0 comments on commit 1e31a45

Please sign in to comment.