Claim your POAP to show you met {name} at frENSday!
diff --git a/components/POAPModal/stages/AlreadyClaimed.tsx b/components/POAPModal/stages/AlreadyClaimed.tsx
new file mode 100644
index 0000000..3e322f8
--- /dev/null
+++ b/components/POAPModal/stages/AlreadyClaimed.tsx
@@ -0,0 +1,18 @@
+import { FC } from 'react';
+
+export const AlreadyClaimed: FC<{ to: string }> = ({ to }) => {
+ return (
+
+
It appears you already have this POAP 🎉
+
You should see it in your collection
+
+ View Collection
+
+
+ );
+};
diff --git a/components/POAPModal/stages/ClaimError.tsx b/components/POAPModal/stages/ClaimError.tsx
new file mode 100644
index 0000000..48dca9b
--- /dev/null
+++ b/components/POAPModal/stages/ClaimError.tsx
@@ -0,0 +1,26 @@
+// eslint-disable-next-line unicorn/prefer-node-protocol, simple-import-sort/imports
+import { inspect } from 'util';
+import { FC } from 'react';
+import { AlreadyClaimed } from './AlreadyClaimed';
+
+export const ClaimError: FC<{ data: unknown; recipient: string }> = ({
+ data,
+ recipient,
+}) => {
+ if (
+ data['statusCode'] == 400 &&
+ data['error'] == 'Bad Request' &&
+ data['message'] == 'You already minted a POAP for this drop.'
+ ) {
+ return
;
+ }
+
+ return (
+
+
There was an error claiming this POAP.
+
+ {inspect(data)}
+
+
+ );
+};
diff --git a/components/POAPModal/stages/Expired.tsx b/components/POAPModal/stages/Expired.tsx
index 8c4605f..3b5443c 100644
--- a/components/POAPModal/stages/Expired.tsx
+++ b/components/POAPModal/stages/Expired.tsx
@@ -8,7 +8,7 @@ export const ExpiredPOAP: FC<{}> = () => {
via the IYK Dashboard
diff --git a/components/POAPModal/stages/MintToProfile.tsx b/components/POAPModal/stages/MintToProfile.tsx
index 08a6de2..c04254b 100644
--- a/components/POAPModal/stages/MintToProfile.tsx
+++ b/components/POAPModal/stages/MintToProfile.tsx
@@ -3,6 +3,9 @@ import clsx from 'clsx';
import { FC, useState } from 'react';
import { FiCheck, FiLoader } from 'react-icons/fi';
+import { mintPOAP } from '../../../hooks/mintPOAP';
+import { IYKRefResponse as IYKReferenceResponse } from '../../../hooks/useIYKRef';
+
const eth_address_regex = /^0x[\dA-Fa-f]{40}$/;
export const MintToProfile: FC<{
@@ -11,7 +14,17 @@ export const MintToProfile: FC<{
event_name: string;
onCallChange: () => void;
onCallClose: () => void;
-}> = ({ address, poap_name, event_name, onCallChange, onCallClose }) => {
+ iykData: IYKReferenceResponse;
+ onMintToProfileError: (error: unknown) => void;
+}> = ({
+ address,
+ poap_name,
+ event_name,
+ iykData,
+ onCallChange,
+ onCallClose,
+ onMintToProfileError,
+}) => {
const isAddress = eth_address_regex.test(address);
const [stage, setStage] = useState<'start' | 'minting' | 'minted'>('start');
@@ -26,7 +39,7 @@ export const MintToProfile: FC<{
'btn w-full py-3 space-x-2 transition-all',
stage === 'minted' && '!bg-ens-light-green-primary'
)}
- onClick={() => {
+ onClick={async () => {
if (stage === 'minted') {
onCallClose();
@@ -35,9 +48,21 @@ export const MintToProfile: FC<{
setStage('minting');
- setTimeout(() => {
+ try {
+ const [data, error] = await mintPOAP(
+ iykData.poapEvents[0].otp,
+ address,
+ iykData.poapEvents[0].poapEventId
+ );
+
+ if (error) {
+ throw error;
+ }
+
setStage('minted');
- }, 1000);
+ } catch (error) {
+ onMintToProfileError(error);
+ }
}}
disabled={stage === 'minting'}
>
diff --git a/components/POAPModal/stages/NameInput.tsx b/components/POAPModal/stages/NameInput.tsx
index a3deee7..c2ed172 100644
--- a/components/POAPModal/stages/NameInput.tsx
+++ b/components/POAPModal/stages/NameInput.tsx
@@ -61,9 +61,6 @@ export const NameInput: FC<{
disabled={loading}
/>