-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
187 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
.next | ||
.dockerignore | ||
.env.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
.btn { | ||
@apply bg-[#7116EB] relative rounded-lg flex items-center justify-center gap-2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use client'; | ||
|
||
import { FC } from 'react'; | ||
|
||
import { IYKRefResponse as IYKReferenceResponse } from '../hooks/useIYKRef'; | ||
import { POAPMetadata } from '../hooks/usePOAPData'; | ||
|
||
export const POAPModal: FC<{ | ||
data: IYKReferenceResponse; | ||
name: string; | ||
metadata: POAPMetadata; | ||
}> = ({ data, name, metadata }) => { | ||
return ( | ||
<div className="fixed bottom-0 inset-x-0 px-3 pb-4"> | ||
<div className="w-full max-w-md mx-auto"> | ||
<div className="p-4 text-center relative"> | ||
<div className="absolute inset-x-0 bottom-0 top-12 bg-[#14032C] rounded-3xl -z-10"></div> | ||
<div className="w-24 h-24 bg-slate-100 rounded-full mx-auto"> | ||
<img | ||
src={metadata.image_url} | ||
alt="" | ||
className="w-full h-full object-cover" | ||
/> | ||
</div> | ||
<div className=""> | ||
<div className="px-4 py-2 btn w-fit mx-auto -translate-y-3 font-bold"> | ||
Mint POAP | ||
</div> | ||
</div> | ||
Claim your POAP to show you met {name} at frENSday! | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { FC } from 'react'; | ||
|
||
import { IYKRefResponse as IYKReferenceResponse } from '../hooks/useIYKRef'; | ||
import { usePOAPData } from '../hooks/usePOAPData'; | ||
import { POAPModal } from './POAPModal'; | ||
|
||
export const SPOAPModal: FC<{ | ||
data: IYKReferenceResponse; | ||
name: string; | ||
}> = async ({ data, name }) => { | ||
if (data.poapEvents.length === 0) return; | ||
|
||
const [iyk_poap_event_data] = data.poapEvents; | ||
|
||
const metadata = await usePOAPData(iyk_poap_event_data.poapEventId); | ||
|
||
if (!metadata) return; | ||
|
||
return <POAPModal data={data} name={name} metadata={metadata} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* eslint-disable unicorn/prevent-abbreviations */ | ||
|
||
type IYKPOAPEvent = { | ||
id: number; | ||
poapEventId: number; | ||
otp: string; | ||
status: 'expired'; | ||
}; | ||
|
||
type IYKLinkedToken = { | ||
contractAddress: string; | ||
chainId: number; | ||
tokenId: string; | ||
}; | ||
|
||
export type IYKRefResponse = { | ||
uid: string; | ||
isValidRef: boolean; | ||
poapEvents: IYKPOAPEvent[]; | ||
linkedToken: IYKLinkedToken; | ||
}; | ||
|
||
export const useIYKRef = async (reference?: string) => { | ||
if (!reference) return; | ||
|
||
const response = await fetch('https://api.iyk.app/refs/' + reference, { | ||
headers: { 'x-api-key': process.env.IYK_API_KEY }, | ||
}); | ||
|
||
if (!response.ok) return; | ||
|
||
return (await response.json()) as IYKRefResponse; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const POAP_API_HOST = 'https://api.poap.tech'; | ||
|
||
export type POAPMetadata = { | ||
description: string; | ||
external_url: string; | ||
home_url: string; | ||
image_url: string; | ||
name: string; | ||
year: number; | ||
tags: string[]; | ||
attributes: { | ||
trait_type: string; | ||
value: string; | ||
}[]; | ||
}; | ||
|
||
export const usePOAPData = async ( | ||
poapEventId: number | ||
): Promise<POAPMetadata | undefined> => { | ||
const request = await fetch(`${POAP_API_HOST}/metadata/${poapEventId}/1`); | ||
|
||
if (!request.ok) return; | ||
|
||
return await request.json(); | ||
}; |