-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from citydaoproject/claim-popups
add claim and claim success popups + fix eligible NFT shown on button
- Loading branch information
Showing
13 changed files
with
274 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { FC, useState } from 'react'; | ||
import Modal from 'react-modal'; | ||
|
||
import { useModal } from '../../hooks/useModal'; | ||
|
||
type ClaimModalProps = { | ||
eligibleNftsCount: number; | ||
onButtonClick: () => void; | ||
onClose: () => void; | ||
}; | ||
export const ClaimModal: FC<ClaimModalProps> = ({ eligibleNftsCount, onButtonClick }) => { | ||
const { isClaimModalOpen, handleCloseClaimModal } = useModal(); | ||
const [isTermsAccepted, setIsTermsAccepted] = useState<boolean>(false); | ||
return ( | ||
<Modal | ||
isOpen={isClaimModalOpen} | ||
onRequestClose={handleCloseClaimModal} | ||
overlayClassName="react-modal-overlay" | ||
className="react-modal-content" | ||
> | ||
<div className="claim-popup"> | ||
<img src="/citydao-parcel-0-logo.png" alt="Parcel Zero NFT" /> | ||
<div className="popup-title">Parcel 0 Claim</div> | ||
You are eligible to claim | ||
<span className="text-primary"> | ||
{` ${eligibleNftsCount}`} Parcel 0 NFT{eligibleNftsCount > 1 ? 's' : ''}. | ||
</span> | ||
<img className="parcel-art" src={'/citydao-parcel-0-NFT-Art-sm.png'} alt="" /> | ||
<div className="terms"> | ||
<input | ||
id="cb1" | ||
type="checkbox" | ||
checked={isTermsAccepted} | ||
onChange={(e) => setIsTermsAccepted(e.target.checked)} | ||
/> | ||
<label htmlFor="cb1"> | ||
Accept Parcel 0 <span className="text-primary">Terms & Conditions</span> | ||
</label> | ||
</div> | ||
<button className="btn-accept" disabled={!isTermsAccepted} onClick={onButtonClick}> | ||
AGREE & CLAIM | ||
</button> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
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 * from './ClaimModal'; |
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,37 @@ | ||
import { FC } from 'react'; | ||
import Modal from 'react-modal'; | ||
|
||
import { useModal } from '../../hooks/useModal'; | ||
|
||
type ClaimSuccessModalProps = { | ||
eligibleNftsCount: number; | ||
}; | ||
export const ClaimSuccessModal: FC<ClaimSuccessModalProps> = ({ eligibleNftsCount }) => { | ||
const { isClaimSuccessModalOpen, handleCloseClaimSuccessModal } = useModal(); | ||
return ( | ||
<Modal | ||
isOpen={isClaimSuccessModalOpen} | ||
onRequestClose={handleCloseClaimSuccessModal} | ||
overlayClassName="react-modal-overlay" | ||
className="react-modal-content" | ||
> | ||
<div className="claim-popup"> | ||
<img className="parcel-0-logo-md" src="/citydao-parcel-0-logo-md.png" alt="Parcel Zero NFT" /> | ||
<div className="popup-title">Parcel 0 Claim</div> | ||
<div className="popup-content"> | ||
Success! You just claimed | ||
<span className="text-primary"> | ||
{` ${eligibleNftsCount}`} Parcel 0 Plot{eligibleNftsCount > 1 ? 's' : ''}. | ||
</span> | ||
<p> | ||
Plot location will be revealed on June 15th, | ||
<br /> 2022. | ||
</p> | ||
</div> | ||
<button className="btn-close" onClick={handleCloseClaimSuccessModal}> | ||
Close | ||
</button> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
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 * from './ClaimSuccessModal'; |
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,51 @@ | ||
import { createContext, useState, ReactNode } from 'react'; | ||
|
||
interface ModalContextData { | ||
isClaimModalOpen: boolean; | ||
handleOpenClaimModal(): void; | ||
handleCloseClaimModal(): void; | ||
isClaimSuccessModalOpen: boolean; | ||
handleOpenClaimSuccessModal(): void; | ||
handleCloseClaimSuccessModal(): void; | ||
} | ||
interface ModalProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const ModalContext = createContext({} as ModalContextData); | ||
|
||
export function ModalProvider({ children }: ModalProviderProps) { | ||
const [isClaimModalOpen, setisClaimModalOpen] = useState(false); | ||
const [isClaimSuccessModalOpen, setisClaimSuccessModalOpen] = useState(false); | ||
|
||
function handleOpenClaimModal() { | ||
setisClaimModalOpen(true); | ||
} | ||
|
||
function handleCloseClaimModal() { | ||
setisClaimModalOpen(false); | ||
} | ||
|
||
function handleOpenClaimSuccessModal() { | ||
setisClaimSuccessModalOpen(true); | ||
} | ||
|
||
function handleCloseClaimSuccessModal() { | ||
setisClaimSuccessModalOpen(false); | ||
} | ||
|
||
return ( | ||
<ModalContext.Provider | ||
value={{ | ||
isClaimModalOpen, | ||
handleOpenClaimModal, | ||
handleCloseClaimModal, | ||
isClaimSuccessModalOpen, | ||
handleOpenClaimSuccessModal, | ||
handleCloseClaimSuccessModal, | ||
}} | ||
> | ||
{children} | ||
</ModalContext.Provider> | ||
); | ||
} |
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,9 @@ | ||
import { useContext } from 'react'; | ||
|
||
import { ModalContext } from '../context/ModalContext'; | ||
|
||
export function useModal() { | ||
const context = useContext(ModalContext); | ||
|
||
return context; | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.