diff --git a/features/anime/actions/getAnimeBySlug.ts b/features/anime/actions/getAnimeBySlug.ts index b7c8302..1816f0c 100644 --- a/features/anime/actions/getAnimeBySlug.ts +++ b/features/anime/actions/getAnimeBySlug.ts @@ -1,4 +1,42 @@ -export const getAnimeBySlug = async (slug: string) => { +export interface GetAnimeBySlugResponse { + success: boolean; + status: number; + message: string; + data: { + id: string; + title: string; + titleAlternative: { + type: string; + title: string; + }[]; + genres: { + slug: string; + name: string; + }[]; + slug: string; + malId: number; + pictureMedium: string; + pictureLarge: string; + country: string; + score: string; + status: string; + startAiring: string; + endAiring: string; + synopsis: string; + ageRating: string; + mediaType: string; + source: string; + onDraft: boolean; + uploadedBy: string; + deletedAt: null | string; + createdAt: string; + updatedAt: string; + }; +} + +export const getAnimeBySlug = async ( + slug: string, +): Promise => { return { success: true, status: 200, @@ -20,6 +58,20 @@ export const getAnimeBySlug = async (slug: string) => { title: "Sakamoto Days", }, ], + genres: [ + { + slug: "action", + name: "Action", + }, + { + slug: "slice-of-life", + name: "Slice of Life", + }, + { + slug: "comedy", + name: "Comedy", + }, + ], slug: "sakamoto-days", malId: 58939, pictureMedium: "https://myanimelist.net/images/anime/1026/146459.webp", diff --git a/features/anime/sections/Information/main.client.tsx b/features/anime/sections/Information/main.client.tsx new file mode 100644 index 0000000..c2e1f8a --- /dev/null +++ b/features/anime/sections/Information/main.client.tsx @@ -0,0 +1,56 @@ +"use client"; +import { GetAnimeBySlugResponse } from "../../actions/getAnimeBySlug"; +import GenreTags from "@/shared/components/GenreTags"; + +const AnimeInformationClient = ({ data }: { data: GetAnimeBySlugResponse }) => { + return ( +
+
+ {data.data.title} +
+
+
+

+ {data.data.title} +

+

+ {data.data.titleAlternative[0].title} +

+
+
+ +
+ + + + + + + + + + + + + + + +
+ Score + {data.data.score}
+ Status + {data.data.status}
+ Airing + + {data.data.startAiring} - {data.data.endAiring} +
+
+
+ ); +}; + +export default AnimeInformationClient; diff --git a/features/anime/sections/Information/main.tsx b/features/anime/sections/Information/main.tsx index 0f54362..941c7e8 100644 --- a/features/anime/sections/Information/main.tsx +++ b/features/anime/sections/Information/main.tsx @@ -1,9 +1,14 @@ import { getAnimeBySlug } from "../../actions/getAnimeBySlug"; +import AnimeInformationClient from "./main.client"; const AnimeInformationMain = async () => { const data = async () => await getAnimeBySlug("sakamoto-days"); const result = await data(); - return
Data: {JSON.stringify(result)}
; + return ( +
+ +
+ ); }; export default AnimeInformationMain; diff --git a/features/home/sections/Hero/components/Swiper.tsx b/features/home/sections/Hero/components/Swiper.tsx index 6b06915..3ccca57 100644 --- a/features/home/sections/Hero/components/Swiper.tsx +++ b/features/home/sections/Hero/components/Swiper.tsx @@ -7,6 +7,7 @@ import { Swiper, SwiperSlide } from "swiper/react"; import { Icon } from "@iconify/react"; import Link from "next/link"; import AddToList from "./AddToList"; +import GenreTags from "@/shared/components/GenreTags"; export interface HeroSwiperProps { data: { @@ -50,14 +51,8 @@ const HeroSwiper = (props: HeroSwiperProps) => {

{slide.title}

-
- {slide.genres.map((genre) => ( - - - {genre.name} - - - ))} +
+

{slide.synopsis} diff --git a/shared/components/GenreTags.tsx b/shared/components/GenreTags.tsx new file mode 100644 index 0000000..fb4e55a --- /dev/null +++ b/shared/components/GenreTags.tsx @@ -0,0 +1,25 @@ +import Link from "next/link"; +import { Badge } from "../libs/shadcn/ui/badge"; + +type GenreTagsProps = { + genres: { + slug: string; + name: string; + }[]; +}; + +const GenreTags = ({ genres }: GenreTagsProps) => { + return ( +

+ {genres.map((genre, index) => ( + + + {genre.name} + + + ))} +
+ ); +}; + +export default GenreTags;