Start working on Movie itempage #26
This commit is contained in:
6 files changed
+708
-568
No files matched your search
@@ -45,6 +45,7 @@ import {
|
||||
UserLoginManual,
|
||||
} from "./routes/login/root";
|
||||
import LibraryView from "./routes/library/root.jsx";
|
||||
import ItemMovie from "./routes/item/Movie/root.jsx";
|
||||
|
||||
import { SideMenu } from "./components/menu/sidemenu.jsx";
|
||||
import { AppBar } from "./components/appBar/appBar.jsx";
|
||||
@@ -349,6 +350,10 @@ function App() {
|
||||
path="/library/:id"
|
||||
element={<LibraryView />}
|
||||
/>
|
||||
<Route
|
||||
path="/item/Movie/:id"
|
||||
element={<ItemMovie />}
|
||||
/>
|
||||
|
||||
{/* Logical Routes */}
|
||||
|
||||
|
||||
@@ -282,9 +282,7 @@ export const Card = ({
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleMarkAsPlayOrUnMarkAsPlay(
|
||||
watchedStatus,
|
||||
);
|
||||
handleMarkAsPlayOrUnMarkAsPlay();
|
||||
}}
|
||||
>
|
||||
<MdiCheck
|
||||
@@ -297,7 +295,12 @@ export const Card = ({
|
||||
</IconButton>
|
||||
)}
|
||||
{allowedLikeButton.includes(iconType) && (
|
||||
<IconButton onClick={handleLiking}>
|
||||
<IconButton
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleLiking();
|
||||
}}
|
||||
>
|
||||
{isFavourite ? (
|
||||
<MdiHeart
|
||||
sx={{ color: pink[700] }}
|
||||
|
||||
+510
-547
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,163 @@
|
||||
/** @format */
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
import Box from "@mui/material/Box";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Stack from "@mui/material/Stack";
|
||||
import Chip from "@mui/material/Chip";
|
||||
import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||
import Divider from "@mui/material/Divider";
|
||||
|
||||
import { setBackdrop, showAppBar } from "../../../utils/slice/appBar";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { MdiStarHalfFull } from "../../../components/icons/mdiStarHalfFull";
|
||||
import { getRuntimeFull } from "../../../utils/date/time";
|
||||
|
||||
const ItemMovie = () => {
|
||||
const { id } = useParams();
|
||||
const dispatch = useDispatch();
|
||||
const appBarVisiblity = useSelector((state) => state.appBar.visible);
|
||||
const [scrollTarget, setScrollTarget] = useState(undefined);
|
||||
|
||||
const trigger = useScrollTrigger({
|
||||
disableHysteresis: true,
|
||||
threshold: 0,
|
||||
target: scrollTarget,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!appBarVisiblity) {
|
||||
dispatch(showAppBar());
|
||||
}
|
||||
dispatch(setBackdrop(trigger));
|
||||
}, [trigger]);
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
queryFn: async () => {
|
||||
let usr = await getUserApi(window.api).getCurrentUser();
|
||||
return usr.data;
|
||||
},
|
||||
});
|
||||
|
||||
const item = useQuery({
|
||||
queryKey: ["item,Movie", id],
|
||||
queryFn: async () => {
|
||||
const result = await getUserLibraryApi(window.api).getItem({
|
||||
userId: user.data.Id,
|
||||
itemId: id,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: !!user.data,
|
||||
});
|
||||
if (item.isLoading) {
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<CircularProgress />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
if (item.isSuccess) {
|
||||
return (
|
||||
<Box
|
||||
recomponent="main"
|
||||
className="scrollY"
|
||||
sx={{
|
||||
flexGrow: 1,
|
||||
pt: 11,
|
||||
px: 3,
|
||||
pb: 3,
|
||||
position: "relative",
|
||||
}}
|
||||
f={(node) => {
|
||||
if (node) {
|
||||
setScrollTarget(node);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Box className="item-detail-header">
|
||||
<Box className="item-detail-title-name">
|
||||
<Typography variant="h4">
|
||||
{item.data.Name}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={2}
|
||||
divider={
|
||||
<Divider
|
||||
variant="middle"
|
||||
flexItem
|
||||
orientation="vertical"
|
||||
/>
|
||||
}
|
||||
ex={{ alignItems: "center" }}
|
||||
>
|
||||
<Typography
|
||||
sx={{ flexGrow: 0 }}
|
||||
variant="subtitle1"
|
||||
>
|
||||
{item.data.ProductionYear}
|
||||
</Typography>
|
||||
<Chip
|
||||
variant="outlined"
|
||||
label={
|
||||
!!item.data.OfficialRating
|
||||
? item.data.OfficialRating
|
||||
: "Not Rated"
|
||||
}
|
||||
/>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
gap: "0.25em",
|
||||
alignItems: "center",
|
||||
}}
|
||||
className="item-detail-info-rating"
|
||||
>
|
||||
{!!item.data.CommunityRating ? (
|
||||
<>
|
||||
<MdiStarHalfFull />
|
||||
<Typography variant="subtitle1">
|
||||
{Math.round(
|
||||
item.data
|
||||
.CommunityRating *
|
||||
10,
|
||||
) / 10}
|
||||
</Typography>
|
||||
</>
|
||||
) : (
|
||||
<Typography variant="subtitle1">
|
||||
No Community Rating
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
<Typography variant="subtitle1">
|
||||
{getRuntimeFull(item.data.RunTimeTicks)}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
if (item.isError) {
|
||||
return <h1>{"Something went wrong :("}</h1>;
|
||||
}
|
||||
};
|
||||
|
||||
export default ItemMovie;
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
setBackdrop,
|
||||
showBackButton,
|
||||
} from "../../utils/slice/appBar";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useParams, useNavigate } from "react-router-dom";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
@@ -27,8 +27,6 @@ import Accordion from "@mui/material/Accordion";
|
||||
import AccordionSummary from "@mui/material/AccordionSummary";
|
||||
import AccordionDetails from "@mui/material/AccordionDetails";
|
||||
import Button from "@mui/material/Button";
|
||||
import List from "@mui/material/List";
|
||||
import ListItem from "@mui/material/ListItem";
|
||||
|
||||
import { theme } from "../../theme";
|
||||
|
||||
@@ -42,13 +40,14 @@ import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||
|
||||
import { Card } from "../../components/card/card";
|
||||
import { EmptyNotice } from "../../components/emptyNotice/emptyNotice";
|
||||
|
||||
import { MdiSortDescending } from "../../components/icons/mdiSortDescending";
|
||||
import { MdiSortAscending } from "../../components/icons/mdiSortAscending";
|
||||
import { MdiChevronRight } from "../../components/icons/mdiChevronRight";
|
||||
import { MdiChevronDown } from "../../components/icons/mdiChevronDown";
|
||||
import { MdiFilterOutline } from "../../components/icons/mdiFilterOutline";
|
||||
|
||||
const LibraryView = () => {
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const appBarVisiblity = useSelector((state) => state.appBar.visible);
|
||||
|
||||
@@ -93,7 +92,6 @@ const LibraryView = () => {
|
||||
});
|
||||
|
||||
if (currentLib.isSuccess) {
|
||||
// console.log(currentLib.data.)
|
||||
dispatch(showBackButton());
|
||||
}
|
||||
|
||||
@@ -216,7 +214,6 @@ const LibraryView = () => {
|
||||
}, [currentLib.isSuccess]);
|
||||
|
||||
const fetchLibItems = async (libraryId) => {
|
||||
console.log(libraryId);
|
||||
let result;
|
||||
if (currentViewType == "MusicArtist") {
|
||||
result = await getArtistsApi(window.api).getAlbumArtists({
|
||||
@@ -327,17 +324,6 @@ const LibraryView = () => {
|
||||
setFilterButtonAnchorEl(null);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log(
|
||||
isPlayed,
|
||||
isUnPlayed,
|
||||
isResumable,
|
||||
isFavourite,
|
||||
isLiked,
|
||||
isUnliked,
|
||||
);
|
||||
}, [isPlayed, isUnPlayed, isResumable, isFavourite, isLiked, isUnliked]);
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -822,6 +808,11 @@ const LibraryView = () => {
|
||||
: ""
|
||||
}
|
||||
currentUser={user.data}
|
||||
onClickEvent={() => {
|
||||
navigate(
|
||||
`/item/${item.Type}/${item.Id}`,
|
||||
);
|
||||
}}
|
||||
></Card>
|
||||
</Grid2>
|
||||
);
|
||||
|
||||
@@ -22,3 +22,18 @@ export const getRuntime = (ticks) => {
|
||||
}
|
||||
return formatedTime;
|
||||
};
|
||||
|
||||
export const getRuntimeFull = (ticks) => {
|
||||
let time = ticksToMs(ticks);
|
||||
let formatedTime = "";
|
||||
let timeSec = Math.round(time / 1000);
|
||||
let timeMin = Math.round(timeSec / 60);
|
||||
if (timeMin > 60) {
|
||||
let timeHr = Math.floor(timeMin / 60);
|
||||
timeMin -= timeHr * 60;
|
||||
formatedTime = `${timeHr}hour ${timeMin}minutes`;
|
||||
} else {
|
||||
formatedTime = `${timeMin}minutes`;
|
||||
}
|
||||
return formatedTime;
|
||||
};
|
||||
Reference in new issue
Block a user