diff --git a/src/components/ContentViewer.tsx b/src/components/ContentViewer.tsx index b9e6869..c4e2a48 100644 --- a/src/components/ContentViewer.tsx +++ b/src/components/ContentViewer.tsx @@ -2,7 +2,7 @@ import { PDP, currentProfile } from "@/utils/Common.ts"; import { AllForOne, changeRating, downloadBook, getFromDB } from "@/utils/Fetchers.ts"; import { IBook } from "@/interfaces/IBook.ts"; import { providerEnum } from "@/utils/utils.ts"; -import { ArrowBack, ArrowForward, AutoStories, Check, Close, Done, Download, Edit, Favorite, PlayArrow, QuestionMark, Refresh, YoutubeSearchedFor } from "@mui/icons-material"; +import { ArrowBack, ArrowForward, AutoStories, Check, Close, Done, Download, Edit, Favorite, OpenInNew, PlayArrow, QuestionMark, Refresh, YoutubeSearchedFor } from "@mui/icons-material"; import { Avatar, Box, Chip, CircularProgress, Container, IconButton, Paper, Stack, Tooltip, Typography, styled } from "@mui/material"; import Rating from "@mui/material/Rating/Rating"; import Grid2 from "@mui/material/Unstable_Grid2/Grid2"; @@ -46,6 +46,8 @@ function ContentViewer({ provider, TheBook, type, handleAddBreadcrumbs }: { }; const APINOTFOUND = /[a-zA-Z]/g.test(TheBook.ID_book); + console.log("TheBook", TheBook); + const fetchCharacters = async () => { if (type === "volume") { if (TheBook.characters !== "null") { @@ -146,22 +148,31 @@ function ContentViewer({ provider, TheBook, type, handleAddBreadcrumbs }: { } } const handleAsyncBG = async () => { - if (TheBook.URLCover != null && TheBook.URLCover !== "null") { - console.log("TheBook.URLCover", TheBook.URLCover); - const options = { + let options; + if (TheBook.BG_cover != null && TheBook.BG_cover !== "null") { + options = { + method: "GET", headers: { + "Content-Type": "application/json", "img": TheBook.BG_cover + } + }; + } else if (TheBook.URLCover != null && TheBook.URLCover !== "null") { + options = { method: "GET", headers: { "Content-Type": "application/json", "img": TheBook.URLCover } }; - await fetch(PDP + "/img/getPalette/" + currentProfile.getToken, options).then(function (response) { - return response.text(); - }).then(function (data) { - const Blurcolors = data; - setTimeout(function () { - document.getElementsByTagName("body")[0].style.backgroundColor = Blurcolors; - }, 500); - }); + } else { + return "#000000"; } + await fetch(PDP + "/img/getPalette/" + currentProfile.getToken, options).then(function (response) { + return response.text(); + }).then(function (data) { + const Blurcolors = data; + setTimeout(function () { + document.getElementsByTagName("body")[0].style.backgroundColor = Blurcolors; + }, 500); + }); + }; handleAsyncBG(); }, [TheBook.URLCover]); @@ -199,7 +210,7 @@ function ContentViewer({ provider, TheBook, type, handleAddBreadcrumbs }: { } } > - # + # @@ -234,15 +245,15 @@ function ContentViewer({ provider, TheBook, type, handleAddBreadcrumbs }: { { type === "volume" ? ( (provider === providerEnum.Marvel) ? -

{TheBook.NOM}open_in_new

+

{TheBook.NOM}

: (provider === providerEnum.Anilist) ?

{TheBook.NOM}

:

{TheBook.NOM}

) : (provider === providerEnum.Marvel) ?

{TheBook.NOM}open_in_new

: (provider === providerEnum.Anilist) ? -

{TheBook.NOM}

: -

{TheBook.NOM}

+

{TheBook.NOM}

: +

{TheBook.NOM}

} -
+
{ type === "volume" ? (TheBook.dates !== "null" ? t("dates") + JSON.parse(TheBook.dates).map((date: { type: string; date: string; }, index: number) => { @@ -358,7 +375,7 @@ function ContentViewer({ provider, TheBook, type, handleAddBreadcrumbs }: { (JSON.parse(TheBook.end_date) == null || JSON.parse(TheBook.end_date) > new Date().getFullYear()) ? "?" : JSON.parse(TheBook.end_date) : "" : "" }
- + { - return (index !== JSON.parse(TheBook.genres).length - 1) ? el + ", " : el; + return (index !== JSON.parse(TheBook.genres).length - 1) ? el + " / " : el; }) }
{ - type === "volume" ? TheBook.issueNumber === (null || "null" || "") ? "" : t("Numberofthisvolumewithintheseries") + TheBook.issueNumber : ((provider === providerEnum.Marvel) ? (t("NumberComics")) : (t("NumberChapter"))) + TheBook["chapters"] + type === "volume" ? TheBook.issueNumber === (null || "null" || "") ? "" : t("Numberofthisvolumewithintheseries") + ": " + TheBook.issueNumber : ((provider === providerEnum.Marvel) ? (t("NumberComics")) : (t("NumberChapter"))) + ": " + TheBook.issueNumber }
@@ -620,40 +638,41 @@ function ContentViewer({ provider, TheBook, type, handleAddBreadcrumbs }: {
{ - (TheBook.volumes != null && TheBook.volumes !== "null") ? t("numberOfVolume") + TheBook.volumes : "" + (TheBook.volumes != null && TheBook.volumes !== "null") ? t("numberOfVolume") + ": " + TheBook.volumes : "" }
{ - TheBook.characters !== "null" ?
{ - const options = { - method: "POST", headers: { - "Content-Type": "application/json" - }, body: JSON.stringify({ - "token": currentProfile.getToken, - "table": "Books", - "column": "last_page", - "whereEl": TheBook.ID_book, - "value": e.target.value, - "where": "ID_book" - }, null, 2) - }; - await fetch(PDP + "/DB/update", options).catch((err) => { - Toaster(err, "error"); - }); - } + type == "volume" ? ( + TheBook.characters !== "null" ?
/ {TheBook.pageCount} {t('pagesRead')}
: "" + onBlur={ + async (e) => { + const options = { + method: "POST", headers: { + "Content-Type": "application/json" + }, body: JSON.stringify({ + "token": currentProfile.getToken, + "table": "Books", + "column": "last_page", + "whereEl": TheBook.ID_book, + "value": e.target.value, + "where": "ID_book" + }, null, 2) + }; + await fetch(PDP + "/DB/update", options).catch((err) => { + Toaster(err, "error"); + }); + } + } + />/ {TheBook.pageCount} {t('pagesRead')}
: "") : "" }

- We take care of your comics + {t("overlaymsg_takecare")}

: <>}