From 1530fa3937a0a5c826f8d8dd71d4557666366869 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Wed, 26 Mar 2025 00:51:30 +0500 Subject: [PATCH] refactor: release section --- .../ReleaseCourusel/ReleaseCourusel.tsx | 1 - .../ReleaseLink/ReleaseLinkUpdate.tsx | 18 +++++++ .../ReleaseLink.16_9FullImage_old.tsx | 0 .../ReleaseLink.16_9Poster_old.tsx | 0 .../ReleaseLink.Poster_old.tsx | 0 app/components/ReleaseLinkOld/ReleaseLink.tsx | 52 +++++++++++++++++++ .../ReleaseLinkOld/ReleaseLinkUpdate.tsx | 25 +++++++++ app/components/ReleasePoster/Chips.tsx | 46 ++++++++++++---- .../ReleasePoster/PosterWithStuff.tsx | 36 +++++-------- .../ReleaseSection/ReleaseSection.tsx | 23 ++++++-- app/pages/Related.tsx | 22 ++------ 11 files changed, 167 insertions(+), 56 deletions(-) rename app/components/{ReleaseLink => ReleaseLinkOld}/ReleaseLink.16_9FullImage_old.tsx (100%) rename app/components/{ReleaseLink => ReleaseLinkOld}/ReleaseLink.16_9Poster_old.tsx (100%) rename app/components/{ReleaseLink => ReleaseLinkOld}/ReleaseLink.Poster_old.tsx (100%) create mode 100644 app/components/ReleaseLinkOld/ReleaseLink.tsx create mode 100644 app/components/ReleaseLinkOld/ReleaseLinkUpdate.tsx diff --git a/app/components/ReleaseCourusel/ReleaseCourusel.tsx b/app/components/ReleaseCourusel/ReleaseCourusel.tsx index 32a85da..69bd9ee 100644 --- a/app/components/ReleaseCourusel/ReleaseCourusel.tsx +++ b/app/components/ReleaseCourusel/ReleaseCourusel.tsx @@ -53,7 +53,6 @@ export const ReleaseCourusel = (props: { diff --git a/app/components/ReleaseLink/ReleaseLinkUpdate.tsx b/app/components/ReleaseLink/ReleaseLinkUpdate.tsx index 4467f96..e448809 100644 --- a/app/components/ReleaseLink/ReleaseLinkUpdate.tsx +++ b/app/components/ReleaseLink/ReleaseLinkUpdate.tsx @@ -5,17 +5,35 @@ export const ReleaseLink = (props: { image: string; title_ru: string; title_original: string; + description?: string; genres?: string; grade?: number; id: number; settings?: { showGenres?: boolean; + showDescription?: boolean; + }; + chipsSettings?: { + enabled: boolean; + gradeHidden?: boolean; + statusHidden?: boolean; + categoryHidden?: boolean; + episodesHidden?: boolean; + listHidden?: boolean; + favHidden?: boolean; + lastWatchedHidden?: boolean; }; profile_list_status?: number; status?: { name: string; }; + category?: { + name: string; + }; status_id?: number; + episodes_released?: string; + episodes_total?: string; + is_favorite?: boolean; }) => { return ( diff --git a/app/components/ReleaseLink/ReleaseLink.16_9FullImage_old.tsx b/app/components/ReleaseLinkOld/ReleaseLink.16_9FullImage_old.tsx similarity index 100% rename from app/components/ReleaseLink/ReleaseLink.16_9FullImage_old.tsx rename to app/components/ReleaseLinkOld/ReleaseLink.16_9FullImage_old.tsx diff --git a/app/components/ReleaseLink/ReleaseLink.16_9Poster_old.tsx b/app/components/ReleaseLinkOld/ReleaseLink.16_9Poster_old.tsx similarity index 100% rename from app/components/ReleaseLink/ReleaseLink.16_9Poster_old.tsx rename to app/components/ReleaseLinkOld/ReleaseLink.16_9Poster_old.tsx diff --git a/app/components/ReleaseLink/ReleaseLink.Poster_old.tsx b/app/components/ReleaseLinkOld/ReleaseLink.Poster_old.tsx similarity index 100% rename from app/components/ReleaseLink/ReleaseLink.Poster_old.tsx rename to app/components/ReleaseLinkOld/ReleaseLink.Poster_old.tsx diff --git a/app/components/ReleaseLinkOld/ReleaseLink.tsx b/app/components/ReleaseLinkOld/ReleaseLink.tsx new file mode 100644 index 0000000..8bc9e80 --- /dev/null +++ b/app/components/ReleaseLinkOld/ReleaseLink.tsx @@ -0,0 +1,52 @@ +import Link from "next/link"; +import { Poster } from "../ReleasePoster/Poster"; +import { Chip } from "../Chip/Chip"; +// import { ReleaseLink169 } from "./ReleaseLink.16_9FullImage"; +// import { ReleaseLink169Poster } from "./ReleaseLink.16_9Poster"; +// import { ReleaseLinkPoster } from "./ReleaseLink.Poster"; + +const profile_lists = { + // 0: "Не смотрю", + 1: { name: "Смотрю", bg_color: "bg-green-500" }, + 2: { name: "В планах", bg_color: "bg-purple-500" }, + 3: { name: "Просмотрено", bg_color: "bg-blue-500" }, + 4: { name: "Отложено", bg_color: "bg-yellow-500" }, + 5: { name: "Брошено", bg_color: "bg-red-500" }, +}; + +export const ReleaseLink = (props: { + // type?: "16_9" | "poster"; + image: string; + title_ru: string; + title_original: string; + genres?: string; + grade?: number; + id: number; + settings?: { + showGenres?: boolean; + }; + profile_list_status?: number; + status?: { + name: string; + }; + status_id?: number; +}) => { + // const type = props.type || "16_9"; + + // if (type == "16_9") { + // return ( + // <> + //
TYPE=16/9
+ + // {/*
*/} + // {/*
*/} + // + // ); + // } + // if (props.type == "poster") { + return ( + <>You NEED to fix this. Replace import to `ReleaseLinkUpdate` + ); + // return ; + // } +}; diff --git a/app/components/ReleaseLinkOld/ReleaseLinkUpdate.tsx b/app/components/ReleaseLinkOld/ReleaseLinkUpdate.tsx new file mode 100644 index 0000000..4467f96 --- /dev/null +++ b/app/components/ReleaseLinkOld/ReleaseLinkUpdate.tsx @@ -0,0 +1,25 @@ +import Link from "next/link"; +import { PosterWithStuff } from "../ReleasePoster/PosterWithStuff"; + +export const ReleaseLink = (props: { + image: string; + title_ru: string; + title_original: string; + genres?: string; + grade?: number; + id: number; + settings?: { + showGenres?: boolean; + }; + profile_list_status?: number; + status?: { + name: string; + }; + status_id?: number; +}) => { + return ( + + + + ); +}; diff --git a/app/components/ReleasePoster/Chips.tsx b/app/components/ReleasePoster/Chips.tsx index 0787772..8e1784b 100644 --- a/app/components/ReleasePoster/Chips.tsx +++ b/app/components/ReleasePoster/Chips.tsx @@ -1,3 +1,4 @@ +import { sinceUnixDate } from "#/api/utils"; import { Chip } from "../Chip/Chip"; interface ChipProps { @@ -10,6 +11,8 @@ interface ChipProps { episodes_total?: any; category?: any; is_favorite?: any; + last_view_episode?: any; + last_view_timestamp?: any; } export const ReleaseChips = ({ @@ -22,12 +25,24 @@ export const ReleaseChips = ({ episodes_total, category, is_favorite, + last_view_episode, + last_view_timestamp, }: ChipProps) => { + const chipSettings = { + enabled: true, + gradeHidden: false, + statusHidden: false, + categoryHidden: false, + episodesHidden: false, + listHidden: false, + favHidden: false, + lastWatchedHidden: true, + ...settings, + }; + return ( -
- {!settings.chips.gradeHidden && grade ? +
+ {!chipSettings.gradeHidden && grade ? : ""} - {!settings.chips.listHidden && user_list && ( + {!chipSettings.listHidden && user_list && ( )} - {!settings.chips.statusHidden && status ? + {!chipSettings.statusHidden && status ? : status_id != 0 && ( ) } - {!settings.chips.episodesHidden && ( + {!chipSettings.episodesHidden && ( )} - {!settings.chips.categoryHidden && category && ( - - )} - {!settings.chips.favHidden && is_favorite && ( + {!chipSettings.categoryHidden && category && } + {!chipSettings.favHidden && is_favorite && (
)} + {!chipSettings.lastWatchedHidden && last_view_episode && ( + + )}
); }; diff --git a/app/components/ReleasePoster/PosterWithStuff.tsx b/app/components/ReleasePoster/PosterWithStuff.tsx index f46cf2e..5f067ac 100644 --- a/app/components/ReleasePoster/PosterWithStuff.tsx +++ b/app/components/ReleasePoster/PosterWithStuff.tsx @@ -21,16 +21,16 @@ export const PosterWithStuff = (props: { settings?: { showGenres?: boolean; showDescription?: boolean; - chips?: { - enabled: boolean; - gradeHidden?: boolean; - statusHidden?: boolean; - categoryHidden?: boolean; - episodesHidden?: boolean; - listHidden?: boolean; - favHidden?: boolean; - lastWatchedHidden?: boolean; - }; + }; + chipsSettings?: { + enabled: boolean; + gradeHidden?: boolean; + statusHidden?: boolean; + categoryHidden?: boolean; + episodesHidden?: boolean; + listHidden?: boolean; + favHidden?: boolean; + lastWatchedHidden?: boolean; }; profile_list_status?: number; status?: { @@ -48,18 +48,10 @@ export const PosterWithStuff = (props: { const settings = { showGenres: true, showDescription: true, - chips: { - enabled: true, - gradeHidden: false, - statusHidden: false, - categoryHidden: false, - episodesHidden: false, - listHidden: false, - favHidden: false, - lastWatchedHidden: false, - }, ...props.settings, }; + const chipsSettings = props.chipsSettings || {} + const grade = props.grade ? Number(props.grade.toFixed(1)) : null; const profile_list_status = props.profile_list_status || null; let user_list = null; @@ -74,13 +66,13 @@ export const PosterWithStuff = (props: { } return ( -
+
diff --git a/app/components/ReleaseSection/ReleaseSection.tsx b/app/components/ReleaseSection/ReleaseSection.tsx index 734e388..a5b85c9 100644 --- a/app/components/ReleaseSection/ReleaseSection.tsx +++ b/app/components/ReleaseSection/ReleaseSection.tsx @@ -1,4 +1,4 @@ -import { ReleaseLink } from "../ReleaseLink/ReleaseLink"; +import { ReleaseLink } from "../ReleaseLink/ReleaseLinkUpdate"; export const ReleaseSection = (props: { sectionTitle?: string; @@ -14,7 +14,24 @@ export const ReleaseSection = (props: {
)}
-
+
+ {props.content.map((release) => { + return ( +
+ +
+ ); + })} +
+ {/*
{props.content.map((release) => { return (
@@ -23,7 +40,7 @@ export const ReleaseSection = (props: { ); })} {props.content.length == 1 &&
} -
+
*/}
); diff --git a/app/pages/Related.tsx b/app/pages/Related.tsx index 1cb7343..9865c8a 100644 --- a/app/pages/Related.tsx +++ b/app/pages/Related.tsx @@ -69,20 +69,6 @@ export function RelatedPage(props: { id: number | string; title: string }) {
{content.map((release, index) => { const genres = []; - const settings = { - showGenres: true, - showDescription: true, - chips: { - enabled: true, - gradeHidden: false, - statusHidden: false, - categoryHidden: false, - episodesHidden: false, - listHidden: false, - favHidden: false, - lastWatchedHidden: false, - }, - }; const grade = release.grade ? Number(release.grade.toFixed(1)) : null; const profile_list_status = release.profile_list_status || null; @@ -111,7 +97,7 @@ export function RelatedPage(props: { id: number | string; title: string }) {
- +
@@ -122,11 +108,9 @@ export function RelatedPage(props: { id: number | string; title: string }) { {...release} user_list={user_list} grade={grade} - settings={settings} />
- {settings.showGenres && - genres.length > 0 && + {genres.length > 0 && genres.map((genre: string, index: number) => { return ( )} - {settings.showDescription && release.description && ( + {release.description && (

{release.description}