Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #969 #1082

Merged
merged 14 commits into from
Feb 27, 2025
28 changes: 25 additions & 3 deletions components/identities/updateProfilePic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SelectedCollections from "./selectedCollections";
import PfpGallery from "./pfpGallery";
import useWhitelistedNFTs from "@/hooks/useWhitelistedNFTs";
import { useAccount } from "@starknet-react/core";
import Button from "@/components/UI/button";

type UpdateProfilePicProps = {
tokenId: string;
Expand All @@ -26,7 +27,7 @@ const UpdateProfilePic: FunctionComponent<UpdateProfilePicProps> = ({
null
);

const selectPfp = (nft: StarkscanNftProps) => {
const selectPfp = (nft: StarkscanNftProps | null) => {
setOpenModal(true);
setSelectedPfp(nft);
};
Expand All @@ -39,7 +40,7 @@ const UpdateProfilePic: FunctionComponent<UpdateProfilePicProps> = ({
}
};

const hasNoNfts = userNfts.length === 0;
const hasNoNfts = userNfts.length === 1;

return (
<>
Expand All @@ -50,8 +51,29 @@ const UpdateProfilePic: FunctionComponent<UpdateProfilePicProps> = ({
selectedPfp={selectedPfp}
userNfts={userNfts}
isLoading={isLoading}
title="Our Suggestions"
title="Choose your NFT Profile picture"
/>
{true &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove unnecessary conditional rendering.

The {true && conditional is redundant since it always evaluates to true.

-          {true && 
+          <>

And update line 75 accordingly:

-          }
+          </>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{true &&
<>
{/* ... existing child components or elements ... */}
</>

<>
<div className="flex justify-center mt-1">
<Button
onClick={() => selectPfp(selectedPfp)}
disabled={selectedPfp === null}
>
CONFIRM PROFILE PICTURE
</Button>
</div>
<div className="flex justify-center">
<button
className={styles.btnWrapperCancelBtn}
onClick={back}
>
CANCEL
</button>
</div>
</>
}

</div>
{!hasNoNfts && (
<div className={styles.gallery}>
Expand Down
Loading