Start adding search page #34
This commit is contained in:
9 files changed
+815
-17
No files matched your search
+8
-3
@@ -45,9 +45,10 @@ import { UserLogin, LoginWithImage, UserLoginManual } from "./routes/login";
|
||||
import LibraryView from "./routes/library";
|
||||
import ItemDetail from "./routes/item";
|
||||
import SeriesTitlePage from "./routes/series/index.jsx";
|
||||
import FavouritePage from "./routes/favourite/index.jsx";
|
||||
import FavoritePage from "./routes/favorite/index.jsx";
|
||||
import Settings from "./routes/settings";
|
||||
import About from "./routes/about";
|
||||
import SearchPage from "./routes/search";
|
||||
|
||||
import { VideoPlayer } from "./routes/player/videoPlayer.jsx";
|
||||
|
||||
@@ -546,8 +547,12 @@ function App() {
|
||||
element={<SeriesTitlePage />}
|
||||
/>
|
||||
<Route
|
||||
path="/favourite"
|
||||
element={<FavouritePage />}
|
||||
path="/search"
|
||||
element={<SearchPage />}
|
||||
/>
|
||||
<Route
|
||||
path="/favorite"
|
||||
element={<FavoritePage />}
|
||||
/>
|
||||
<Route
|
||||
path="/settings"
|
||||
|
||||
@@ -145,7 +145,7 @@ export const AppBar = () => {
|
||||
</IconButton>
|
||||
</div>
|
||||
<div style={{ display: "flex", gap: "1.2em" }}>
|
||||
<IconButton disabled>
|
||||
<IconButton onClick={() => navigate("/search")}>
|
||||
<MdiMagnify />
|
||||
</IconButton>
|
||||
<IconButton disabled>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/** @format */
|
||||
@@ -0,0 +1,7 @@
|
||||
/** @format */
|
||||
|
||||
const FavoritePage = () => {
|
||||
<></>;
|
||||
};
|
||||
|
||||
export default FavoritePage;
|
||||
@@ -1,7 +0,0 @@
|
||||
/** @format */
|
||||
|
||||
const FavouritePage = () => {
|
||||
return <></>;
|
||||
};
|
||||
|
||||
export default FavouritePage;
|
||||
@@ -0,0 +1,739 @@
|
||||
/** @format */
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import TextField from "@mui/material/TextField";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
|
||||
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||
|
||||
import { MdiMagnify } from "../../components/icons/mdiMagnify";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||
|
||||
import useDebounce from "../../utils/hooks/useDebounce";
|
||||
|
||||
import "./search.module.scss";
|
||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||
import { Card } from "../../components/card/card";
|
||||
|
||||
const SearchPage = () => {
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const searchParam = useDebounce(searchTerm, 500);
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
queryFn: async () => {
|
||||
let usr = await getUserApi(window.api).getCurrentUser();
|
||||
return usr.data;
|
||||
},
|
||||
networkMode: "always",
|
||||
});
|
||||
|
||||
const items = useQuery({
|
||||
queryKey: ["search", "items", searchParam],
|
||||
queryFn: async () => {
|
||||
const result = await getItemsApi(window.api).getItemsByUserId({
|
||||
userId: user.data.Id,
|
||||
searchTerm: searchTerm,
|
||||
includeItemTypes: [
|
||||
BaseItemKind.Movie,
|
||||
BaseItemKind.Series,
|
||||
BaseItemKind.Audio,
|
||||
BaseItemKind.MusicAlbum,
|
||||
BaseItemKind.Book,
|
||||
BaseItemKind.MusicArtist,
|
||||
BaseItemKind.Person,
|
||||
],
|
||||
recursive: true,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: user.isSuccess,
|
||||
});
|
||||
|
||||
/**
|
||||
* @typedef {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} BaseItemDto
|
||||
* @type {[BaseItemDto[], Function]}
|
||||
*/
|
||||
const [movies, setMovies] = useState([]);
|
||||
const [series, setSeries] = useState([]);
|
||||
const [audios, setAudios] = useState([]);
|
||||
const [musicAlbum, setMusicAlbum] = useState([]);
|
||||
const [books, setBooks] = useState([]);
|
||||
const [musicArtists, setMusicArtists] = useState([]);
|
||||
const [persons, setPersons] = useState([]);
|
||||
|
||||
const itemLimit = 16;
|
||||
|
||||
useEffect(() => {
|
||||
if (items.isSuccess) {
|
||||
setMovies(
|
||||
items.data.Items.filter(
|
||||
(item) => item.Type == BaseItemKind.Movie,
|
||||
).slice(0, itemLimit),
|
||||
);
|
||||
setSeries(
|
||||
items.data.Items.filter(
|
||||
(item) => item.Type == BaseItemKind.Series,
|
||||
).slice(0, itemLimit),
|
||||
);
|
||||
setAudios(
|
||||
items.data.Items.filter(
|
||||
(item) => item.Type == BaseItemKind.Audio,
|
||||
).slice(0, itemLimit),
|
||||
);
|
||||
setMusicAlbum(
|
||||
items.data.Items.filter(
|
||||
(item) => item.Type == BaseItemKind.MusicAlbum,
|
||||
).slice(0, itemLimit),
|
||||
);
|
||||
setBooks(
|
||||
items.data.Items.filter(
|
||||
(item) => item.Type == BaseItemKind.Book,
|
||||
).slice(0, itemLimit),
|
||||
);
|
||||
setMusicArtists(
|
||||
items.data.Items.filter(
|
||||
(item) => item.Type == BaseItemKind.MusicArtist,
|
||||
).slice(0, itemLimit),
|
||||
);
|
||||
setPersons(
|
||||
items.data.Items.filter(
|
||||
(item) => item.Type == BaseItemKind.Person,
|
||||
).slice(0, itemLimit),
|
||||
);
|
||||
}
|
||||
}, [items.isSuccess]);
|
||||
|
||||
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||
|
||||
useEffect(() => {
|
||||
// Removing app's backdrop
|
||||
setBackdrop("", "");
|
||||
}, []);
|
||||
return (
|
||||
<div
|
||||
className="scrollY"
|
||||
style={{
|
||||
paddingTop: "4.2em",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "0.5em",
|
||||
}}
|
||||
>
|
||||
<div className="search-header">
|
||||
<TextField
|
||||
variant="outlined"
|
||||
style={{
|
||||
width: "50%",
|
||||
}}
|
||||
placeholder="Search"
|
||||
hiddenLabel
|
||||
className="search-searchbar"
|
||||
inputProps={{
|
||||
className: "search-searchbar-input",
|
||||
}}
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
{items.isLoading ? (
|
||||
<div
|
||||
style={{
|
||||
height: "calc(100vh - 9em)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<LinearProgress
|
||||
style={{
|
||||
width: "25%",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
style={{
|
||||
height: "100%",
|
||||
}}
|
||||
>
|
||||
{movies.length > 0 && (
|
||||
<CardScroller
|
||||
title="Movies"
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{movies.map((item, index) => (
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item.SeriesId}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Type ==
|
||||
BaseItemKind.Series
|
||||
? `${
|
||||
item.ProductionYear
|
||||
} - ${
|
||||
!!item.EndDate
|
||||
? new Date(
|
||||
item.EndDate,
|
||||
).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item.Type ==
|
||||
BaseItemKind.Person ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item.Type ==
|
||||
BaseItemKind.MusicAlbum ||
|
||||
item.Type ==
|
||||
BaseItemKind.Audio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={[]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes
|
||||
?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</CardScroller>
|
||||
)}
|
||||
{series.length > 0 && (
|
||||
<CardScroller
|
||||
title="TV Shows"
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{series.map((item, index) => (
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item.SeriesId}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Type ==
|
||||
BaseItemKind.Series
|
||||
? `${
|
||||
item.ProductionYear
|
||||
} - ${
|
||||
!!item.EndDate
|
||||
? new Date(
|
||||
item.EndDate,
|
||||
).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item.Type ==
|
||||
BaseItemKind.Person ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item.Type ==
|
||||
BaseItemKind.MusicAlbum ||
|
||||
item.Type ==
|
||||
BaseItemKind.Audio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={[]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes
|
||||
?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</CardScroller>
|
||||
)}
|
||||
{audios.length > 0 && (
|
||||
<CardScroller
|
||||
title="Audio"
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{audios.map((item, index) => (
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item.SeriesId}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Type ==
|
||||
BaseItemKind.Series
|
||||
? `${
|
||||
item.ProductionYear
|
||||
} - ${
|
||||
!!item.EndDate
|
||||
? new Date(
|
||||
item.EndDate,
|
||||
).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item.Type ==
|
||||
BaseItemKind.Person ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item.Type ==
|
||||
BaseItemKind.MusicAlbum ||
|
||||
item.Type ==
|
||||
BaseItemKind.Audio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={[]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes
|
||||
?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</CardScroller>
|
||||
)}
|
||||
{musicAlbum.length > 0 && (
|
||||
<CardScroller
|
||||
title="Albums"
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{musicAlbum.map((item, index) => (
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item.SeriesId}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Type ==
|
||||
BaseItemKind.Series
|
||||
? `${
|
||||
item.ProductionYear
|
||||
} - ${
|
||||
!!item.EndDate
|
||||
? new Date(
|
||||
item.EndDate,
|
||||
).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item.Type ==
|
||||
BaseItemKind.Person ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item.Type ==
|
||||
BaseItemKind.MusicAlbum ||
|
||||
item.Type ==
|
||||
BaseItemKind.Audio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={[]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes
|
||||
?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</CardScroller>
|
||||
)}
|
||||
{books.length > 0 && (
|
||||
<CardScroller
|
||||
title="Books"
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{books.map((item, index) => (
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item.SeriesId}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Type ==
|
||||
BaseItemKind.Series
|
||||
? `${
|
||||
item.ProductionYear
|
||||
} - ${
|
||||
!!item.EndDate
|
||||
? new Date(
|
||||
item.EndDate,
|
||||
).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item.Type ==
|
||||
BaseItemKind.Person ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item.Type ==
|
||||
BaseItemKind.MusicAlbum ||
|
||||
item.Type ==
|
||||
BaseItemKind.Audio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={[]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes
|
||||
?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</CardScroller>
|
||||
)}
|
||||
{musicArtists.length > 0 && (
|
||||
<CardScroller
|
||||
title="Artists"
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{musicArtists.map((item, index) => (
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item.SeriesId}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Type ==
|
||||
BaseItemKind.Series
|
||||
? `${
|
||||
item.ProductionYear
|
||||
} - ${
|
||||
!!item.EndDate
|
||||
? new Date(
|
||||
item.EndDate,
|
||||
).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item.Type ==
|
||||
BaseItemKind.Person ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item.Type ==
|
||||
BaseItemKind.MusicAlbum ||
|
||||
item.Type ==
|
||||
BaseItemKind.Audio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={[]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes
|
||||
?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</CardScroller>
|
||||
)}
|
||||
{persons.length > 0 && (
|
||||
<CardScroller
|
||||
title="People"
|
||||
displayCards={8}
|
||||
disableDecoration
|
||||
>
|
||||
{persons.map((item, index) => (
|
||||
<Card
|
||||
item={item}
|
||||
seriesId={item.SeriesId}
|
||||
cardTitle={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? item.SeriesName
|
||||
: item.Name
|
||||
}
|
||||
imageType={"Primary"}
|
||||
cardCaption={
|
||||
item.Type ==
|
||||
BaseItemKind.Episode
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: item.Type ==
|
||||
BaseItemKind.Series
|
||||
? `${
|
||||
item.ProductionYear
|
||||
} - ${
|
||||
!!item.EndDate
|
||||
? new Date(
|
||||
item.EndDate,
|
||||
).toLocaleString(
|
||||
[],
|
||||
{
|
||||
year: "numeric",
|
||||
},
|
||||
)
|
||||
: "Present"
|
||||
}`
|
||||
: item.ProductionYear
|
||||
}
|
||||
disableOverlay={
|
||||
item.Type ==
|
||||
BaseItemKind.Person ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio
|
||||
}
|
||||
cardType={
|
||||
item.Type ==
|
||||
BaseItemKind.MusicAlbum ||
|
||||
item.Type ==
|
||||
BaseItemKind.Audio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Genre ||
|
||||
item.Type ==
|
||||
BaseItemKind.MusicGenre ||
|
||||
item.Type ==
|
||||
BaseItemKind.Studio ||
|
||||
item.Type ==
|
||||
BaseItemKind.Playlist
|
||||
? "square"
|
||||
: "portrait"
|
||||
}
|
||||
queryKey={[]}
|
||||
userId={user.data.Id}
|
||||
imageBlurhash={
|
||||
!!item.ImageBlurHashes
|
||||
?.Primary &&
|
||||
item.ImageBlurHashes?.Primary[
|
||||
Object.keys(
|
||||
item.ImageBlurHashes
|
||||
.Primary,
|
||||
)[0]
|
||||
]
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</CardScroller>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SearchPage;
|
||||
@@ -0,0 +1,24 @@
|
||||
/** @format */
|
||||
|
||||
.search {
|
||||
&-header {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 1em;
|
||||
height: 4em;
|
||||
}
|
||||
&-searchbar {
|
||||
border-radius: 100px !important;
|
||||
background: rgb(255 255 255 / 0.09);
|
||||
border: none !important;
|
||||
.MuiInputBase-root.MuiOutlinedInput-root.MuiInputBase-colorPrimary.MuiInputBase-formControl.MuiInputBase-hiddenLabel.css-187yyed-MuiInputBase-root-MuiOutlinedInput-root {
|
||||
border-radius: 100px !important;
|
||||
}
|
||||
&-input {
|
||||
text-align: center;
|
||||
padding: 0.75em 1.5em !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/** @format */
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
// see https://github.com/tannerlinsley/react-query/issues/293
|
||||
// see https://usehooks.com/useDebounce/
|
||||
export default function useDebounce(value, delay) {
|
||||
// State and setters for debounced value
|
||||
const [debouncedValue, setDebouncedValue] = useState(value);
|
||||
|
||||
useEffect(
|
||||
() => {
|
||||
// Update debounced value after delay
|
||||
const handler = setTimeout(() => {
|
||||
setDebouncedValue(value);
|
||||
}, delay);
|
||||
|
||||
// Cancel the timeout if value changes (also on delay change or unmount)
|
||||
// This is how we prevent debounced value from updating if value is changed ...
|
||||
// .. within the delay period. Timeout gets cleared and restarted.
|
||||
return () => {
|
||||
clearTimeout(handler);
|
||||
};
|
||||
},
|
||||
[value, delay], // Only re-call effect if value or delay changes
|
||||
);
|
||||
|
||||
return debouncedValue;
|
||||
}
|
||||
Reference in new issue
Block a user