Skip to content

Commit

Permalink
feature: gamer passport save eligibiloty check results
Browse files Browse the repository at this point in the history
  • Loading branch information
newbreedofgeek committed Aug 7, 2024
1 parent 5a515b4 commit fecd833
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/pages/GamerPassport/ActionModals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ActionButton } from "./SharedComps";

export const ActionModalStep1 = (props: any) => {
const { showActionModel, handleHideActionModel } = props;
const { handleStep1Passed, handleStep1PSNUserName } = props;
const { handleStep1Passed, handleStep1PSNUserName, handleStep1EligibilityCheckResults } = props;

const [psnUserName, setPsnUserName] = useState<string>("");
const [eligibilityCheckLoading, setEligibilityCheckLoading] = useState<boolean>(false);
Expand All @@ -34,6 +34,7 @@ export const ActionModalStep1 = (props: any) => {
} else if (!eligibilityDecision.accountIdGood || !eligibilityDecision.titlesGood) {
setEligibilityUserNameNotSuitable(true);
} else {
handleStep1EligibilityCheckResults(JSON.stringify(eligibilityDecision));
handleStep1Passed(true);
handleStep1PSNUserName(psnUserName);
handleHideActionModel();
Expand Down Expand Up @@ -86,6 +87,7 @@ export const ActionModalStep1 = (props: any) => {
* Make sure you enter YOUR username, as you will be asked to prove ownership to claim your rewards! Bruh, we will find out! 😎
</p>
<div
className="mt-8"
onClick={() => {
if (psnUserName.trim().length > 2 && !eligibilityCheckLoading) {
checkEligibilityViaAPI();
Expand Down Expand Up @@ -157,7 +159,7 @@ export const ActionModalStep1 = (props: any) => {
export const ActionModalStep3 = (props: any) => {
const { publicKey, signMessage } = useWallet();
const { showActionModel, handleHideActionModel } = props;
const { step1PSNUserName, step2SolanaAddress, handleStep3Passed } = props;
const { step1PSNUserName, step1PSNEligibilityCheckResults, step2SolanaAddress, handleStep3Passed } = props;

const [userSaveToLogAttempted, setUserSaveToLogAttempted] = useState<boolean>(false);
const [userSavedToLog, setUserSavedToLog] = useState<boolean>(false);
Expand All @@ -180,6 +182,7 @@ export const ActionModalStep3 = (props: any) => {

const checkRes = await axios.post(`${getApiWeb2Apps()}/datadexapi/gamepassport/addNewUserToLog`, {
"psnUsername": step1PSNUserName,
"eligibilityCheckResults": step1PSNEligibilityCheckResults,
"solAddress": step2SolanaAddress,
"signatureNonce": preAccessNonce,
"solSignature": encodedSignature,
Expand Down Expand Up @@ -224,7 +227,7 @@ export const ActionModalStep3 = (props: any) => {
{!userSaveToLogAttempted && (
<>
<div>
<p className="font-bold italic opacity-80">
<p className="text-sm font-bold italic opacity-80">
Itheum is all about empowering you with data ownership! So, we want to be fully transparent about how your data is collected and used. (It
would be ironic if we weren't, right?).
</p>
Expand Down Expand Up @@ -259,6 +262,9 @@ export const ActionModalStep3 = (props: any) => {
<p>Solana Address : {step2SolanaAddress}</p>
</div>
<div className="mt-8">
<p className="text-sm text-green-400 mt-3">
* Note that clicking the button below will ask you to sign a message to prove wallet ownership. No gas or funds are used!
</p>
<div
onClick={() => {
if (!saveToLogLoading) {
Expand Down
15 changes: 13 additions & 2 deletions src/pages/GamerPassport/GamerPassport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const GamerPassport = () => {
const [step1InProgress] = useState<boolean>(true);
const [step1Passed, setStep1Passed] = useState<boolean>(false);
const [step1PSNUserName, setStep1PSNUserName] = useState<string>("");
const [step1PSNEligibilityCheckResults, setStep1EligibilityCheckResults] = useState<string>("");

// Step 2
const [step2Passed, setStep2Passed] = useState<boolean>(false);
Expand Down Expand Up @@ -99,8 +100,16 @@ export const GamerPassport = () => {
setStep3InProgress(false);
setAppBootingUp(false); // if user is NOT logged in, at this point the app is "booted in"
} else {
// wallet connected; check if this is a user ALREADY joined an setup onboarding form if needed
checkIfUserHasJoined();
if (!step1Passed) {
// wallet connected; check if this is a user ALREADY joined an setup onboarding form if needed
// ... only do this if user is NOT in the middle on onboarding and just completed step 1
// ... or else, if the connect a wallet they used before it breaks
checkIfUserHasJoined();
} else {
setStep2Passed(true);
setStep2SolanaAddress(addressSol);
setStep3InProgress(true);
}
}
}, [addressSol]);

Expand Down Expand Up @@ -489,10 +498,12 @@ export const GamerPassport = () => {
setStep1Passed(val);
}}
handleStep1PSNUserName={setStep1PSNUserName}
handleStep1EligibilityCheckResults={setStep1EligibilityCheckResults}
/>

<ActionModalStep3
step1PSNUserName={step1PSNUserName}
step1PSNEligibilityCheckResults={step1PSNEligibilityCheckResults}
step2SolanaAddress={step2SolanaAddress}
showActionModel={showActionModalStep3}
handleHideActionModel={() => setShowActionModalStep3(false)}
Expand Down

0 comments on commit fecd833

Please sign in to comment.