diff --git a/components/content-card/components/character-tooltip.tsx b/components/content-card/components/character-tooltip.tsx index c5030673..f81d9e12 100644 --- a/components/content-card/components/character-tooltip.tsx +++ b/components/content-card/components/character-tooltip.tsx @@ -1,13 +1,9 @@ 'use client'; -import * as React from 'react'; import { FC, PropsWithChildren, memo } from 'react'; -import Link from 'next/link'; - +import ContentCard from '@/components/content-card/content-card'; import MDViewer from '@/components/markdown/viewer/MD-viewer'; -import H5 from '@/components/typography/h5'; -import { Badge } from '@/components/ui/badge'; import { HoverCard, HoverCardArrow, @@ -16,13 +12,9 @@ import { HoverCardTrigger, } from '@/components/ui/hover-card'; import { Label } from '@/components/ui/label'; -import WatchListButton from '@/components/watchlist-button/watchlist-button'; -import ContentCard from '@/components/content-card/content-card'; - -import useCharacterInfo from '@/services/hooks/characters/useCharacterInfo'; -import useCharacterAnime from '@/services/hooks/characters/useCharacterAnime'; import useSession from '@/services/hooks/auth/useSession'; -import { MEDIA_TYPE, RELEASE_STATUS } from '@/utils/constants'; +import useCharacterAnime from '@/services/hooks/characters/useCharacterAnime'; +import useCharacterInfo from '@/services/hooks/characters/useCharacterInfo'; interface TooltipDataProps { slug: string; @@ -36,86 +28,75 @@ interface Props extends PropsWithChildren { const TooltipData: FC = ({ slug }) => { const { user: loggedUser } = useSession(); const { data } = useCharacterInfo({ slug }); - const anime = useCharacterAnime({ slug }); - anime?.list?.sort((a, b) => b.anime.score - a.anime.score) + const { list } = useCharacterAnime({ slug }); + + const characterAnime = list?.sort( + (a, b) => b.anime.score - a.anime.score, + )[0]; if (!data) { return ( -
-
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
-
); +
+ ); } return ( - <> - {data.description_ua && anime.list ? ( -
-
- -
-
-
- -
-
-
- - {data.description_ua} - -
-
-
- {(anime.list[0] && ( -
- - -
- ))} -
) - :( -
-
-
-
- -
-
-
- -
+
+ +
+
+ +
+
+
+ + {data.description_ua} +
+
+ {characterAnime && ( +
+ +
)} - +
); }; -const CharacterTooltip: FC = ({ slug, children, withTrigger, ...props }) => { +const CharacterTooltip: FC = ({ + slug, + children, + withTrigger, + ...props +}) => { if (!slug) { return null; } diff --git a/components/ui/hover-card.tsx b/components/ui/hover-card.tsx index 0e1d4018..d423d3b0 100644 --- a/components/ui/hover-card.tsx +++ b/components/ui/hover-card.tsx @@ -23,7 +23,7 @@ const HoverCardContent = React.forwardRef< align={align} sideOffset={sideOffset} className={cn( - 'z-50 w-16 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', + 'z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', className, )} {...props} @@ -33,8 +33,8 @@ HoverCardContent.displayName = HoverCardPrimitive.Content.displayName; export { HoverCard, - HoverCardTrigger, + HoverCardArrow, HoverCardContent, HoverCardPortal, - HoverCardArrow, + HoverCardTrigger, }; diff --git a/next.config.mjs b/next.config.mjs index c0ca0e8e..265529c4 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,6 +1,7 @@ -import bundleAnalyzer from '@next/bundle-analyzer'; import Icons from 'unplugin-icons/webpack'; +import bundleAnalyzer from '@next/bundle-analyzer'; + /** @type {import('next').NextConfig} */ const nextConfig = { eslint: { @@ -31,7 +32,7 @@ const nextConfig = { async rewrites() { return [ { - source: "/api/:path*", + source: '/api/:path*', destination: `${process.env.API_URL}/:path*`, }, ]; @@ -41,5 +42,4 @@ const withBundleAnalyzer = bundleAnalyzer({ enabled: process.env.ANALYZE === 'true', }); - export default withBundleAnalyzer(nextConfig); diff --git a/services/api/characters/getCharacterAnime.tsx b/services/api/characters/getCharacterAnime.tsx index 780954dc..6485206d 100644 --- a/services/api/characters/getCharacterAnime.tsx +++ b/services/api/characters/getCharacterAnime.tsx @@ -1,12 +1,11 @@ import { BaseFetchRequestProps, - FetchRequestProps, fetchRequest, } from '@/services/api/fetchRequest'; -export interface Response extends API.WithPagination {} +export interface Response extends API.WithPagination {} -export type Anime = { +export type CharacterAnime = { main: boolean; anime: API.Anime; };