|
@@ -1,23 +1,44 @@
|
|
|
"use client";
|
|
|
-import { PrizeTypes } from "@/api/home";
|
|
|
+import { BannerRep, PrizeTypes } from "@/api/home";
|
|
|
import { Card } from "@/components/Card";
|
|
|
import { Tabs } from "antd-mobile";
|
|
|
import clsx from "clsx";
|
|
|
-import { FC } from "react";
|
|
|
+import React, { FC } from "react";
|
|
|
import { Autoplay, FreeMode } from "swiper/modules";
|
|
|
import { Swiper, SwiperSlide } from "swiper/react";
|
|
|
import styles from "./prize.module.scss";
|
|
|
interface Props {
|
|
|
data: PrizeTypes[];
|
|
|
+ notices?: BannerRep[];
|
|
|
type: "list" | "card" | "notice";
|
|
|
}
|
|
|
|
|
|
const HomePrize: FC<Props> = (props) => {
|
|
|
- const { data, type } = props;
|
|
|
- // const t = useTranslations("HomePage");
|
|
|
- // const tt = useTranslations("Game");
|
|
|
+ const { data, type, notices } = props;
|
|
|
|
|
|
- if (!data?.length) return null;
|
|
|
+ const renderData = React.useMemo(() => {
|
|
|
+ if (type !== "notice") return data;
|
|
|
+ const result: any = [];
|
|
|
+ if (!!data?.length) {
|
|
|
+ data.forEach((item) => {
|
|
|
+ result.push({
|
|
|
+ text: ` ${item.phone ? item.phone.slice(0, 1) + "*****" + item.phone.slice(-3) : ""}
|
|
|
+ acabou de retirar {prize.amount} R$`,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!!notices?.length) {
|
|
|
+ notices?.forEach((item) => {
|
|
|
+ result.push({
|
|
|
+ text: item.content,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }, [data, notices, type]);
|
|
|
+
|
|
|
+ if (!renderData?.length) return null;
|
|
|
|
|
|
if (type === "notice") {
|
|
|
return (
|
|
@@ -43,18 +64,14 @@ const HomePrize: FC<Props> = (props) => {
|
|
|
modules={[Autoplay, FreeMode]}
|
|
|
className="homeNoticeSwiper"
|
|
|
>
|
|
|
- {[...(data || []), ...(data || [])].map((prize, index) => (
|
|
|
+ {renderData.map((item: any, index: number) => (
|
|
|
<SwiperSlide key={index}>
|
|
|
<div
|
|
|
className={
|
|
|
- "textBox inline-block text-[.12rem] text-[var(--textColor1)]"
|
|
|
+ "textBox inline-block !text-[.12rem] text-[var(--textColor1)]"
|
|
|
}
|
|
|
- >
|
|
|
- {prize.phone
|
|
|
- ? prize.phone.slice(0, 1) + "*****" + prize.phone.slice(-3)
|
|
|
- : ""}{" "}
|
|
|
- acabou de retirar {prize.amount} R$
|
|
|
- </div>
|
|
|
+ dangerouslySetInnerHTML={{ __html: item.text }}
|
|
|
+ ></div>
|
|
|
</SwiperSlide>
|
|
|
))}
|
|
|
</Swiper>
|