Skip to content

Commit

Permalink
worked on adding green modal flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Im Khem authored and Im Khem committed Jul 28, 2023
1 parent c50b854 commit b3ec80f
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 54 deletions.
5 changes: 3 additions & 2 deletions src/refactor/masanew.stories.tsx
Expand Up @@ -24,8 +24,8 @@ import {
AuthenticateModal,
CreateCreditScoreModal,
CreateIdentityModal,
CreateGreenModal,
} from './ui/components/modals';
import { useGreenModal } from './ui/components/modals/create-green/use-green-modal';

// * nextjs fix
// * TODO: move this to index.ts file at some point
Expand Down Expand Up @@ -469,6 +469,7 @@ const GreenInfo = () => {
const ModalFlow = () => {
const { isDisconnected } = useWallet();
const { hasSession } = useSession();
const { showChainingModal } = useGreenModal();

return (
<ul>
Expand Down Expand Up @@ -504,7 +505,7 @@ const ModalFlow = () => {
</Button>
</li>
<li>
<Button type="button" onClick={() => NiceModal.show(CreateGreenModal)}>
<Button type="button" onClick={showChainingModal}>
Create Masa Green
</Button>
</li>
Expand Down
50 changes: 24 additions & 26 deletions src/refactor/ui/components/modals/create-green/air-drop.tsx
@@ -1,32 +1,30 @@
import React from 'react';
import { useMasa } from '../../../../provider';
import { SubflowPage } from '../../interface-subflow';

export const AirdropPage: React.FunctionComponent<SubflowPage> = ({
next,
}: SubflowPage) => {
const { useModalSize } = useMasa();

useModalSize?.({ width: 800, height: 400 });
import { useModal } from '@ebay/nice-modal-react';
import { Modal } from '../modal';

export const AirDropModal = () => {
const modal = useModal();
return (
<div className="airdrop-interface">
<h2>100,000 $Masa Token Airdrop</h2>
<div>
<p>
Earn 10 $MASA tokens for each new user you successfully refer to Masa
</p>
<p>
Each friend you refer must mint a Masa Green SBT to be considered a
successful referral
</p>
</div>
<Modal>
<section className="airdrop-interface">
<h2>100,000 $Masa Token Airdrop</h2>
<div>
<p>
Earn 10 $MASA tokens for each new user you successfully refer to
Masa
</p>
<p>
Each friend you refer must mint a Masa Green SBT to be considered a
successful referral
</p>
</div>

<div className="">
<button className="masa-button" onClick={next}>
Get verified to start referrals
</button>
</div>
</div>
<div className="">
<button className="masa-button" onClick={() => modal.resolve()}>
Get verified to start referrals
</button>
</div>
</section>
</Modal>
);
};
41 changes: 15 additions & 26 deletions src/refactor/ui/components/modals/create-green/create-green.tsx
@@ -1,31 +1,20 @@
import React from 'react';

import NiceModal from '@ebay/nice-modal-react';
import NiceModal, { useModal } from '@ebay/nice-modal-react';
import { Modal } from '../modal';

export const CreateGreenModal: React.FunctionComponent<SubflowPage> =
NiceModal.create(() => {
return (
<Modal>
<div className="airdrop-interface">
<h2>100,000 $Masa Token Airdrop</h2>
<div>
<p>
Earn 10 $MASA tokens for each new user you successfully refer to
Masa
</p>
<p>
Each friend you refer must mint a Masa Green SBT to be considered
a successful referral
</p>
</div>
export const CreateGreenModal = NiceModal.create(({ currentStep }) => {

Check failure on line 6 in src/refactor/ui/components/modals/create-green/create-green.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node

Property 'currentStep' does not exist on type '{}'.
const steps = ['AirDrop', 'NotABot', 'PhoneNumber', 'Mint'];
const modal = useModal();

<div className="">
<button className="masa-button">
Get verified to start referrals
</button>
</div>
</div>
</Modal>
);
});
return (
<Modal>
<section>
<h1>{steps[currentStep]}</h1>
<br />
<br />
<button onClick={() => modal.resolve()}>Next</button>
</section>
</Modal>
);
});
29 changes: 29 additions & 0 deletions src/refactor/ui/components/modals/create-green/not-a-bot-modal.tsx
@@ -0,0 +1,29 @@
import React, { useEffect } from 'react';
import NiceModal, { useModal } from '@ebay/nice-modal-react';

Check failure on line 2 in src/refactor/ui/components/modals/create-green/not-a-bot-modal.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node

'NiceModal' is declared but its value is never read.
import { Modal } from '../modal';

const BOT_DISCLAIMER_TIMEOUT_SECONDS = 5;

export const NotABotModal = () => {
const modal = useModal();

useEffect(() => {
const timer = setTimeout(() => {
modal.resolve();
}, BOT_DISCLAIMER_TIMEOUT_SECONDS * 1000);

return () => clearTimeout(timer);
}, [modal]);

return (
<Modal>
<section className="not-a-bot-interface">
<h2>
To be eligible for Masa Green, we kindly ask that you prove you are
not a bot.
</h2>
<p className="bot-icon">🤖</p>
</section>
</Modal>
);
};
16 changes: 16 additions & 0 deletions src/refactor/ui/components/modals/create-green/use-green-modal.ts
@@ -0,0 +1,16 @@
import React from 'react';

Check failure on line 1 in src/refactor/ui/components/modals/create-green/use-green-modal.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node

'React' is declared but its value is never read.
import { useModal } from '@ebay/nice-modal-react';
import { CreateGreenModal } from './create-green';

export const useGreenModal = () => {
const chainingModal = useModal(CreateGreenModal);

const showChainingModal = async () => {
for (let i = 0; i < 3; i++) {
console.log({ i });
await chainingModal.show({ currentStep: i });

Check failure on line 11 in src/refactor/ui/components/modals/create-green/use-green-modal.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node

Argument of type '{ currentStep: number; }' is not assignable to parameter of type 'Omit<Omit<NiceModalHocProps, "id">, never> & Partial<Omit<NiceModalHocProps, "id">>'.
await chainingModal.hide();
}
};
return { showChainingModal };
};

0 comments on commit b3ec80f

Please sign in to comment.