-
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.
Introduce Partial POAP Redemption Support
- Loading branch information
Showing
12 changed files
with
292 additions
and
33 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
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export const SHOW_POAP_ANYWAYS = false; |
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,82 @@ | ||
import { formatAddress } from '@ens-tools/format'; | ||
import clsx from 'clsx'; | ||
import { FC, useState } from 'react'; | ||
import { FiCheck, FiLoader } from 'react-icons/fi'; | ||
|
||
const eth_address_regex = /^0x[\dA-Fa-f]{40}$/; | ||
|
||
export const MintToProfile: FC<{ | ||
address: string; | ||
poap_name: string; | ||
event_name: string; | ||
onCallChange: () => void; | ||
onCallClose: () => void; | ||
}> = ({ address, poap_name, event_name, onCallChange, onCallClose }) => { | ||
const isAddress = eth_address_regex.test(address); | ||
const [stage, setStage] = useState<'start' | 'minting' | 'minted'>('start'); | ||
|
||
return ( | ||
<div className="space-y-2 w-full"> | ||
<div className="w-full max-w-xs mx-auto"> | ||
Mint a POAP to show you met {poap_name} at {event_name}! | ||
</div> | ||
<div className="w-full"> | ||
<button | ||
className={clsx( | ||
'btn w-full py-3 space-x-2 transition-all', | ||
stage === 'minted' && '!bg-ens-light-green-primary' | ||
)} | ||
onClick={() => { | ||
if (stage === 'minted') { | ||
onCallClose(); | ||
|
||
return; | ||
} | ||
|
||
setStage('minting'); | ||
|
||
setTimeout(() => { | ||
setStage('minted'); | ||
}, 1000); | ||
}} | ||
disabled={stage === 'minting'} | ||
> | ||
{stage === 'start' && 'Mint POAP'} | ||
{stage === 'minting' && 'Minting...'} | ||
{stage === 'minted' && 'Minted'} | ||
{stage === 'minting' && ( | ||
<FiLoader className="animate-spin" /> | ||
)} | ||
{stage === 'minted' && <FiCheck />} | ||
</button> | ||
</div> | ||
<div className="w-full flex justify-between px-2"> | ||
<div className="flex items-center gap-1"> | ||
<div>to</div> | ||
<div className="flex items-center gap-1"> | ||
{!isAddress && ( | ||
<span className="w-4 h-4 rounded-full bg-ens-light-blue-surface border border-ens-light-border"> | ||
<img | ||
src={'https://enstate.rs/i/' + address} | ||
alt="" | ||
className="rounded-full w-full h-full border-none" | ||
/> | ||
</span> | ||
)} | ||
<span className="font-bold"> | ||
{isAddress ? formatAddress(address) : address} | ||
</span> | ||
</div> | ||
</div> | ||
{stage === 'start' && ( | ||
<button | ||
className="text-ens-light-blue-primary px-1" | ||
onClick={onCallChange} | ||
> | ||
Change | ||
</button> | ||
)} | ||
</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,80 @@ | ||
import clsx from 'clsx'; | ||
import { FC, useState } from 'react'; | ||
import { FiLoader, FiSearch } from 'react-icons/fi'; | ||
|
||
import { useEnstate } from '../../../hooks/useEnstate'; | ||
|
||
const eth_address_regex = /^0x[\dA-Fa-f]{40}$/; | ||
|
||
export const NameInput: FC<{ | ||
onSubmit: (_name: string) => void; | ||
poap_name: string; | ||
event_name: string; | ||
}> = ({ onSubmit, poap_name, event_name }) => { | ||
const [inputData, setInputData] = useState(''); | ||
const [loading, setLoading] = useState(false); | ||
|
||
const validENS = true; | ||
|
||
return ( | ||
<div className="w-full space-y-2"> | ||
<div className="w-full max-w-xs mx-auto"> | ||
Mint a POAP to show you met {poap_name} at {event_name}! | ||
</div> | ||
<form | ||
className="flex justify-stretch items-stretch gap-3 w-full" | ||
onSubmit={async (event) => { | ||
event.preventDefault(); | ||
|
||
if (eth_address_regex.test(inputData)) { | ||
onSubmit(inputData); | ||
|
||
return; | ||
} | ||
|
||
setLoading(true); | ||
|
||
try { | ||
const data = await useEnstate(inputData); | ||
|
||
if (data) { | ||
onSubmit(data.name); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}} | ||
> | ||
<div className="grow"> | ||
<input | ||
type="text" | ||
className={clsx( | ||
'rounded-lg h-full w-full border block px-3', | ||
validENS ? 'border-ens-light-blue-primary' : '' | ||
)} | ||
placeholder="Enter your ENS name or Eth address" | ||
onChange={(event) => { | ||
setInputData(event.target.value); | ||
}} | ||
disabled={loading} | ||
/> | ||
</div> | ||
{/* <button className="px-6 py-2 btn w-fit mx-auto font-bold text-sm"> | ||
Mint POAP | ||
</button> */} | ||
<button | ||
type="submit" | ||
className="p-4 btn w-fit mx-auto font-bold text-sm aspect-square" | ||
> | ||
{loading ? ( | ||
<FiLoader className="animate-spin" /> | ||
) : ( | ||
<FiSearch /> | ||
)} | ||
</button> | ||
</form> | ||
</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,15 @@ | ||
export const PendingApproval = () => { | ||
return ( | ||
<div> | ||
This POAP is still{' '} | ||
<a | ||
href="https://blog.poap.xyz/guidelines/" | ||
target="_blank" | ||
className="text-ens-light-blue-primary underline" | ||
> | ||
pending human review | ||
</a> | ||
. This can take up to ~1 hour. Please try again later. | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.