-
+
{
+ await getHomeData();
+ }}
+ renderText={(status) => {
+ return {statusRecord[status]}
;
+ }}
+ disabled={!Token}
+ >
+
+
+
+
- {address ? (
-
-
- {shortenString(address, 6, 4)}
- {
- loginOut();
- setUserData(undefined);
- }}
- name="tuichu"
- className={classes.userinfo_top_right_wallet_disconnect}
- color={"#fff"}
- />
-
-
- {userData && (
- <>
-
- {getLevelName(userData.level)}
-
- >
- )}
-
-
- ) : (
- <>
-
{
- open();
+ {address ? (
+
+
+ {shortenString(address, 6, 4)}
+ {
+ loginOut();
+ setUserData(undefined);
}}
- >
- {t("链接钱包")}
-
- >
- )}
-
-
- -
-
- {userData?.directPushNode || 0}
-
-
- {t("Direct Node")}
-
-
- -
-
- {userData?.teamNode || 0}
-
-
- {t("Team Node")}
-
-
- -
-
- {userData?.revenueUsdt || 0}
-
USDT
-
-
- {t("Push income")}
-
-
-
-
-
-
-
- - setTabIndex(0)}
- >
- NODE
-
-
-
-
- {tabIndex == 0 && (
- <>
- {address ? (
+ name="tuichu"
+ className={classes.userinfo_top_right_wallet_disconnect}
+ color={"#fff"}
+ />
+
+
+ {userData && (
<>
- {userData?.nodeNumber && userData?.nodeNumber > 0 ? (
-
-
- You own {userData.nodeNumber} nodes
- {
- navigate("/mint");
- }}
- >
- {t("Buy Node")}
-
-
-
-
-
- {t("Start mining after node subscription ends.")}
-
-
- ) : (
-
-
+ {getLevelName(userData.level)}
+
+ >
+ )}
+
+
+ ) : (
+ <>
+
{
+ open();
+ }}
+ >
+ {t("链接钱包")}
+
+ >
+ )}
+
+
+ -
+
+ {userData?.directPushNode || 0}
+
+
+ {t("Direct Node")}
+
+
+ -
+
+ {userData?.teamNode || 0}
+
+
+ {t("Team Node")}
+
+
+ -
+
+ {userData?.revenueUsdt || 0}
+
USDT
+
+
+ {t("Push income")}
+
+
+
+
+
+
+
+ - setTabIndex(0)}
+ >
+ NODE
+
+
+
+
+ {tabIndex == 0 && (
+ <>
+ {address ? (
+ <>
+ {userData?.nodeNumber && userData?.nodeNumber > 0 ? (
+
+
+ You own {userData.nodeNumber} nodes
+ {
navigate("/mint");
}}
>
- {t("Buy Node")}
+ {t("Buy Node")}
-
-
{t("Buy Edge AI Node.")}
+
- )}
- >
- ) : (
- <>
-
-
- {t(
- "The wallet is not linked and cannot show you the Node."
- )}
+
+
+ {t("Start mining after node subscription ends.")}
- >
- )}
- >
- )}
-
-
-
-
-
- {t("邀请")}
- {address && (
- {
- navigate("/invitationlist");
- }}
- >
- {t("邀请列表")}{" "}
-
-
- )}
-
-
-
-
{t("邀请链接")}
-
- {address ? (
- <>
- {userData?.nodeNumber && userData?.nodeNumber > 0 ? (
- <>
-
{shortenString(userInviteLink, 15, 15)}
-
{
- copyText(userInviteLink);
- }}
- className={classes.invite_content_icon}
- name="fuzhi"
- color={"#fff"}
- />{" "}
- >
) : (
- <>
-
- {t("Buy Edge AI Node to get invitation link")}
-
- >
+
+
{
+ navigate("/mint");
+ }}
+ >
+ {t("Buy Node")}
+
+
+
{t("Buy Edge AI Node.")}
+
)}
>
) : (
<>
- {t("Link wallet to get invitation link")}
+
+
+ {t(
+ "The wallet is not linked and cannot show you the Node."
+ )}
+
+
>
)}
-
-
-
- {t(
- "Invite your friends to become YOTTA nodes and you will get a 20% rebate."
- )}
-
-
+ >
+ )}
-
- >
+
+
+
+ {t("邀请")}
+ {address && (
+ {
+ navigate("/invitationlist");
+ }}
+ >
+ {t("邀请列表")}{" "}
+
+
+ )}
+
+
+
+
{t("邀请链接")}
+
+ {address ? (
+ <>
+ {userData?.nodeNumber && userData?.nodeNumber > 0 ? (
+ <>
+ {shortenString(userInviteLink, 15, 15)}
+ {
+ copyText(userInviteLink);
+ }}
+ className={classes.invite_content_icon}
+ name="fuzhi"
+ color={"#fff"}
+ />{" "}
+ >
+ ) : (
+ <>
+
+ {t("Buy Edge AI Node to get invitation link")}
+
+ >
+ )}
+ >
+ ) : (
+ <>
+ {t("Link wallet to get invitation link")}
+ >
+ )}
+
+
+
+ {t(
+ "Invite your friends to become YOTTA nodes and you will get a 20% rebate."
+ )}
+
+
+
+
+
);
}
+
+function Desktop() {
+ const {
+ getHomeData,
+ statusRecord,
+ Token,
+ address,
+ setUserData,
+ userData,
+ tabIndex,
+ t,
+ setTabIndex,
+ navigate,
+ userInviteLink,
+ } = useHome();
+ const {
+ nodeConfig,
+ num,
+ setNum,
+ approveUsdt,
+ balance,
+ approveLoadingToast,
+ costNum,
+ setApproveUsdt,
+ buyLoadingToast,
+ orderInfo,
+ updateNodeConfig,
+ startPollingCheckBuyStatus,
+ } = useMint();
+ const { columns, list, loadMore, hasMore } = useInvitationList();
+ return <>>;
+}
+
+export default {
+ Mobile,
+ Desktop,
+};
diff --git a/src/pages/InvitationList.tsx b/src/pages/InvitationList.tsx
index 8689cee..d3095b8 100644
--- a/src/pages/InvitationList.tsx
+++ b/src/pages/InvitationList.tsx
@@ -4,40 +4,12 @@
* @LastEditTime: 2024-06-27 15:33:01
* @Author: John
*/
-import usePagination from "@/hook/usePagination";
-import { api_recommended_list } from "@/server/api";
-import { RecommendedListItem } from "@/server/module";
import { Empty, InfiniteScroll } from "antd-mobile";
-import DataTable, { TableColumn } from "react-data-table-component";
-import { useTranslation } from "react-i18next";
+import DataTable from "react-data-table-component";
+import useInvitationList from "./Feature/useInvitationList";
export default function () {
- const { t } = useTranslation();
- const columns: TableColumn
[] = [
- {
- name: t("地址"),
- selector: (row) => row.walletAddress,
- grow: 9,
- },
- {
- name: "Node",
- selector: (row) => row.nodeNumber,
- grow: 1,
- // @ts-ignore
- right: "true",
- },
- ];
-
- const { list, hasMore, loadMore } = usePagination({
- service({ pageNum, pageSize }) {
- return new Promise(async (reslove) => {
- const { data } = await api_recommended_list().send({
- queryParams: { pageNum, pageSize },
- });
- reslove(data?.data.records || []);
- });
- },
- });
+ const { columns, list, loadMore, hasMore } = useInvitationList();
return (
<>
diff --git a/src/pages/Mint.module.css b/src/pages/Mint-m.module.css
similarity index 100%
rename from src/pages/Mint.module.css
rename to src/pages/Mint-m.module.css
diff --git a/src/pages/Mint.tsx b/src/pages/Mint.tsx
index 6b64117..72074b6 100644
--- a/src/pages/Mint.tsx
+++ b/src/pages/Mint.tsx
@@ -1,110 +1,36 @@
/*
* @LastEditors: John
* @Date: 2024-06-18 15:28:03
- * @LastEditTime: 2024-06-27 17:17:09
+ * @LastEditTime: 2024-06-28 14:33:02
* @Author: John
*/
import { cn, filterAddressBeforeZero, filterAmountBeforeZero } from "@/utils";
-import classes from "./Mint.module.css";
+import classes from "./Mint-m.module.css";
import nft_bg from "@/assets/nft_bg.svg";
import Button from "antd-mobile/es/components/button";
import Space from "antd-mobile/es/components/space";
-import { useTranslation } from "react-i18next";
-import { useEffect, useMemo, useRef, useState } from "react";
-import {
- api_get_homepage_user_data,
- api_get_nft_configuration_data,
- api_node_order,
- api_users_cancel_orders,
-} from "@/server/api";
-import {
- NftConfigurationData,
- NftOrder,
- NodeOrder,
- UserHomeData,
-} from "@/server/module";
-import {
- authorizedU,
- getApproveUsdt,
- getBalance,
- payByContract,
-} from "@/contract/utils";
-import { Dialog, Modal, Stepper, Toast } from "antd-mobile";
-import useUserStore from "@/store/User";
-import usePollingCheckBuyStatus from "@/hook/usePollingCheckBuyStatus";
-import { ToastHandler } from "antd-mobile/es/components/toast";
+import { api_node_order } from "@/server/api";
+import { authorizedU, getApproveUsdt, payByContract } from "@/contract/utils";
+import { Stepper, Toast } from "antd-mobile";
import { BaseError } from "wagmi";
-import { useNavigate } from "react-router-dom";
import { toWei } from "web3-utils";
+import useMint from "./Feature/useMint";
export default function () {
- const { t } = useTranslation();
- const { Token } = useUserStore();
- const [nodeConfig, setNodeConfig] = useState();
- const [approveUsdt, setApproveUsdt] = useState(0n);
- const [balance, setBalance] = useState(0n);
- const orderInfo = useRef();
- const navigate = useNavigate();
- const [num, setNum] = useState(1);
-
- const buyLoadingToast = useRef();
- const approveLoadingToast = useRef();
const {
- transcationStatus,
+ nodeConfig,
+ num,
+ setNum,
+ approveUsdt,
+ t,
+ balance,
+ approveLoadingToast,
+ costNum,
+ setApproveUsdt,
+ buyLoadingToast,
+ orderInfo,
+ updateNodeConfig,
startPollingCheckBuyStatus,
- stopPollingCheckBuyStatus,
- } = usePollingCheckBuyStatus("NORMAL");
-
- const costNum = useMemo(
- () =>
- BigInt(
- toWei(`${parseFloat(`${nodeConfig?.nodePrice || "0"}`) * num}`, "ether")
- ),
- [nodeConfig?.nodePrice, num]
- );
-
- useEffect(() => {
- updateNodeConfig();
-
- return () => {};
- }, []);
-
- useEffect(() => {
- (async () => {
- Toast.show({ icon: "loading", content: t("正在获取已授权金额") });
- setBalance(await getBalance());
- setApproveUsdt(await getApproveUsdt());
- Toast.clear();
- })();
-
- return () => {};
- }, [Token]);
-
- async function updateNodeConfig() {
- const { data } = await api_get_homepage_user_data().send({});
- setNodeConfig(data?.data);
- }
- useEffect(() => {
- if (transcationStatus == "success") {
- buyLoadingToast.current?.close();
- stopPollingCheckBuyStatus();
- Dialog.alert({
- content: `${t(
- "Buy successful. Please return to the homepage to view."
- )}`,
- confirmText: "OK",
- onConfirm() {
- navigate("/");
- },
- });
- }
-
- return () => {};
- }, [transcationStatus]);
-
- useEffect(() => {
- return () => {};
- }, []);
-
+ } = useMint();
return (
<>
diff --git a/src/utils/index.ts b/src/utils/index.ts
index e74f9a9..78e7c54 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,7 +1,7 @@
/*
* @LastEditors: John
* @Date: 2024-06-17 18:19:27
- * @LastEditTime: 2024-06-27 11:40:59
+ * @LastEditTime: 2024-06-28 15:32:57
* @Author: John
*/
import { type ClassValue, clsx } from "clsx";