Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
fix: auth check in buy
Browse files Browse the repository at this point in the history
  • Loading branch information
intergalacticspacehighway committed Nov 14, 2023
1 parent 857f3b8 commit a60c3db
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/app/components/creator-token/buy-creator-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ import { useCreatorTokenPriceToSellNext } from "app/hooks/creator-token/use-crea
import { useCreatorTokenSell } from "app/hooks/creator-token/use-creator-token-sell";
import { useWalletUSDCBalance } from "app/hooks/creator-token/use-wallet-usdc-balance";
import { useRedirectToCreatorTokensShare } from "app/hooks/use-redirect-to-creator-token-share-screen";
import { useUser } from "app/hooks/use-user";
import { useWallet } from "app/hooks/use-wallet";
import { useWalletETHBalance } from "app/hooks/use-wallet-balance";
import { useNavigateToLogin } from "app/navigation/use-navigate-to";

import { toast } from "design-system/toast";
import { Toggle } from "design-system/toggle";
Expand Down Expand Up @@ -214,6 +216,8 @@ export const BuyCreatorToken = () => {
}
};

const navigateToLogin = useNavigateToLogin();
const { isAuthenticated } = useUser();
useEffect(() => {
if (selectedAction === "sell" && typeof tokenBalance.data !== "undefined") {
setTokenAmount(Math.min(1, Number(tokenBalance.data)));
Expand Down Expand Up @@ -475,7 +479,13 @@ export const BuyCreatorToken = () => {
marginRight: 16,
fontWeight: 600,
}}
onClick={() => {
onClick={(e) => {
if (!isAuthenticated) {
navigateToLogin();
e.preventDefault();
return;
}

function listenCrossmintMessage(event: any) {
if (event.data.type === "purchase.succeeded") {
if (profileData?.data?.profile) {
Expand Down

0 comments on commit a60c3db

Please sign in to comment.