|
@@ -1,7 +1,8 @@
|
|
|
"use client";
|
|
|
-import { Link } from "@/i18n/routing";
|
|
|
+import { getWheelApi } from "@/api/cashWheel";
|
|
|
+import { useRouter } from "@/i18n/routing";
|
|
|
import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
|
|
|
-import { Badge } from "antd-mobile";
|
|
|
+import { Badge, Toast } from "antd-mobile";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import { FC } from "react";
|
|
|
import "./style.scss";
|
|
@@ -17,7 +18,7 @@ export interface ItemComProps {
|
|
|
|
|
|
const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
|
|
|
const t = useTranslations("ProfilePage");
|
|
|
-
|
|
|
+ const router = useRouter();
|
|
|
const { unread, userUnread } = useGlobalNoticeStore((state) => ({
|
|
|
unread: state.unread,
|
|
|
userUnread: state.userUnred,
|
|
@@ -61,12 +62,25 @@ const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
|
|
|
},
|
|
|
{ label: "initial", desc: "", icon: "", url: "/", content: null },
|
|
|
];
|
|
|
+ const routerHandler = (item: any) => {
|
|
|
+ if (item.url === "/cashWheel") {
|
|
|
+ getWheelApi().then((res) => {
|
|
|
+ if (!Array.isArray(res.data) && !!res.data.activities) {
|
|
|
+ router.push(item.url);
|
|
|
+ } else {
|
|
|
+ Toast.show("The event is not open");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ router.push(item.url);
|
|
|
+ }
|
|
|
+ };
|
|
|
return (
|
|
|
<div className="itemCom-box">
|
|
|
{links.map((item, index) => (
|
|
|
- <Link
|
|
|
+ <div
|
|
|
className={`${index == 0 ? "free" : ""} box-item`}
|
|
|
- href={item.url}
|
|
|
+ onClick={() => routerHandler(item)}
|
|
|
key={index}
|
|
|
>
|
|
|
<div className={`${item.desc ? "box-item__left" : ""}`}>
|
|
@@ -85,7 +99,7 @@ const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
|
|
|
<div>
|
|
|
<span className="iconfont icon-xiangyou1"></span>
|
|
|
</div>
|
|
|
- </Link>
|
|
|
+ </div>
|
|
|
))}
|
|
|
</div>
|
|
|
);
|