Skip to content

Commit

Permalink
update balance after upgrade nft
Browse files Browse the repository at this point in the history
  • Loading branch information
MickWang committed Jul 30, 2024
1 parent cf411b8 commit c20c62c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/DashboardS2/DailyRoulette/DailyDrawModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const DailyDrawModal: React.FC<IProps> = (props: IProps) => {
const [mintStatus, setMintStatus] = useState<MintStatus | undefined>();
const [failMessage, setFailMessage] = useState("");
const { switchChain } = useSwitchChain();
const { updateFactory } = useUpdateNftBalanceStore();
const { updateFactor } = useUpdateNftBalanceStore();

const { sendTrademarkMintTx } = useNovaNFT();
const { modalInstance, onDrawed, remain } = props;
Expand Down Expand Up @@ -159,7 +159,7 @@ const DailyDrawModal: React.FC<IProps> = (props: IProps) => {
mintResultModal.onOpen();
onDrawed(); // update remain times after mint tx
setMintParams(undefined);
updateFactory();
updateFactor();
} catch (e) {
console.log(e);
setMintStatus(MintStatus.Failed);
Expand All @@ -178,7 +178,7 @@ const DailyDrawModal: React.FC<IProps> = (props: IProps) => {
mintResultModal,
onDrawed,
sendTrademarkMintTx,
updateFactory,
updateFactor,
]);

const handleSkip = async () => {
Expand Down
12 changes: 6 additions & 6 deletions src/components/DashboardS2/Tabs/PortfolioComponents/LynksNFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import { Abi } from "viem";
import SbtUpgradeModal from "@/components/Dashboard/NovaCharacterComponents/SbtUpgradeModal";
import { useUpdateNftBalanceStore } from "@/hooks/useUpdateNftBalanceStore";


export default function SbtNFT() {
const { address } = useAccount();
const [lynksBalance, setLynksBalance] = useState(0);
const { publicClient, trademarkNFT } = useNovaNFT();
const { getLynksNFT } = useNovaNFT();
const { nft, loading: mintLoading, fetchLoading } = useSbtNft();
const [update, setUpdate] = useState(0);
const upgradeModal = useDisclosure();
const [upgradable, setUpgradable] = useState(false);
const { factor } = useUpdateNftBalanceStore();
const { factor, updateFactor } = useUpdateNftBalanceStore();

useEffect(() => {
(async () => {
Expand Down Expand Up @@ -49,7 +47,7 @@ export default function SbtNFT() {
}
}
})();
}, [address, getLynksNFT, publicClient, trademarkNFT, update,factor]);
}, [address, getLynksNFT, publicClient, trademarkNFT, factor]);

useEffect(() => {
(async () => {
Expand All @@ -65,7 +63,7 @@ export default function SbtNFT() {
setLynksBalance(balance);
}
})();
}, [address, getLynksNFT]);
}, [address, getLynksNFT, factor]);

const handleMintNow = useCallback(() => {
if (fetchLoading) {
Expand Down Expand Up @@ -112,7 +110,9 @@ export default function SbtNFT() {
nft={nft}
mintLoading={mintLoading}
upgradeModal={upgradeModal}
onUpgraded={() => setUpdate((v) => v + 1)}
onUpgraded={() => {
updateFactor();
}}
/>
</NftContainer>
);
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useUpdateNftBalanceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { create } from "zustand";

interface UpdateNftBalanceStore {
factor: number;
updateFactory: () => void;
updateFactor: () => void;
}

export const useUpdateNftBalanceStore = create<UpdateNftBalanceStore>(
(set) => ({
factor: 0,
updateFactory: () => set((state) => ({ factor: state.factor + 1 })),
updateFactor: () => set((state) => ({ factor: state.factor + 1 })),
})
);

0 comments on commit c20c62c

Please sign in to comment.