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

fix: redirect to settings on set primary on creating creator token #2467

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions packages/app/hooks/creator-token/use-creator-token-opt-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import Axios from "axios";
import useSWRMutation from "swr/mutation";

import { useAlert } from "@showtime-xyz/universal.alert";
import { useRouter } from "@showtime-xyz/universal.router";

import { axios } from "app/lib/axios";
import { Logger } from "app/lib/logger";
import { formatAPIErrorMessage, formatAddressShort } from "app/utilities";

import { useSetPrimaryWallet } from "../api/use-set-primary-wallet";
import { useAuth } from "../auth/use-auth";
import { useUser } from "../use-user";
import { useWallet } from "../use-wallet";

export const useCreatorTokenOptIn = () => {
const Alert = useAlert();
const wallet = useWallet();
const user = useUser();
const router = useRouter();
const { setPrimaryWallet } = useSetPrimaryWallet();
const auth = useAuth();

const state = useSWRMutation(
"creatorTokenOptIn",
Expand Down Expand Up @@ -57,21 +57,27 @@ export const useCreatorTokenOptIn = () => {
if (wallet.isMagicWallet) {
Alert.alert(
"Unsupported wallet",
"Please login using a web3 wallet to create the creator token",
"To enable creator token, please add a regular web3 wallet to your account and set that to primary",
[
{
text: "Log out",
text: "Okay",
onPress: () => {
router.push("/settings");
},
},
{
text: "Cancel",
style: "cancel",
onPress: () => {
auth.logout();
reject();
reject("User cancelled");
},
},
]
);
} else {
Alert.alert(
"Unsupported wallet set to Primary",
` Would you like to set current wallet (${formatAddressShort(
`Would you like to set current wallet (${formatAddressShort(
wallet.address
)}) to Primary? Primary wallet is used to create the creator token.`,
[
Expand All @@ -83,6 +89,13 @@ export const useCreatorTokenOptIn = () => {
}
},
},
{
text: "Cancel",
style: "cancel",
onPress: () => {
reject("User cancelled");
},
},
]
);
}
Expand Down
Loading