Browse Source

feat: update home games

Before 1 year ago
parent
commit
ce126f3f2f
1 changed files with 9 additions and 7 deletions
  1. 9 7
      src/app/[locale]/_home/HomeGames.tsx

+ 9 - 7
src/app/[locale]/_home/HomeGames.tsx

@@ -1,5 +1,5 @@
 "use client";
-import { getGamesApi } from "@/api/home";
+import { Category, GameListRep, getGamesApi } from "@/api/home";
 import Box from "@/components/Box";
 import { SwiperGroup } from "@/components/Card";
 import { useRouter } from "@/i18n";
@@ -73,7 +73,7 @@ const Tabs: FC = () => {
         </Swiper>
     );
 };
-const Manufacturer = (props: { data: EntityGameListRep[] }) => {
+const Manufacturer = (props: { data: GameListRep[] }) => {
     const { data } = props;
     const elements = data.map((item, index) => {
         return <img key={index} src={item.game_icon} alt="" />;
@@ -83,15 +83,16 @@ const Manufacturer = (props: { data: EntityGameListRep[] }) => {
 };
 
 const HomeSwiper: FC<PropsWithChildren<Props>> = (props) => {
-    const [groupGames, setGroupGames] = useState<EntityHomeRep[]>([]);
+    const [groupGames, setGroupGames] = useState<Category[]>([]);
     const router = useRouter();
     useEffect(() => {
         getGamesApi().then((res) => {
-            setGroupGames(res.data);
+            const games = res.data[0];
+            setGroupGames(games.category);
         });
     }, []);
-    return null;
-    const todoHandler = (item: EntityCategory) => {
+
+    const todoHandler = (item: Category) => {
         router.push(`/gameList/${item.line_config_amount}`);
     };
 
@@ -101,7 +102,7 @@ const HomeSwiper: FC<PropsWithChildren<Props>> = (props) => {
                 <Tabs></Tabs>
             </Box>
             {groupGames.map((group, index) => {
-                if (group.to_tal !== 3) {
+                if (group.type !== 2) {
                     return (
                         <SwiperGroup
                             key={index}
@@ -111,6 +112,7 @@ const HomeSwiper: FC<PropsWithChildren<Props>> = (props) => {
                         ></SwiperGroup>
                     );
                 } else {
+                    // 厂商
                     return (
                         <SwiperGroup
                             key={index}