Add more filter option to libView #9

This commit is contained in:
prayag17 committed 2023-04-07 15:09:58 +05:30
1 parent ef55f13d7b
commit 3833f4d626
3 files changed
+119 -6

No files matched your search

+9 -6
View File
@@ -64,12 +64,15 @@ export const Card = ({
: "1",
}}
>
{watchedStatus && (
<Chip
className="card-indicator"
label={<MdiCheck />}
/>
)}
<Chip
className="card-indicator"
label={<MdiCheck />}
sx={{
transition: "opacity 150ms",
opacity: watchedStatus ? 1 : 0,
}}
/>
{!!watchedCount && (
<Chip
className="card-indicator card-indicator-text"
+13
View File
@@ -0,0 +1,13 @@
/** @format */
import SvgIcon from "@mui/material/SvgIcon";
import { mdiFilterOutline } from "@mdi/js";
export const MdiFilterOutline = (props) => {
return (
<SvgIcon {...props}>
<path d={mdiFilterOutline}></path>
</SvgIcon>
);
};
+97
View File
@@ -46,6 +46,7 @@ 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 dispatch = useDispatch();
@@ -168,6 +169,19 @@ const LibraryView = () => {
},
];
const [isBluRay, setIsBluRay] = useState(false);
const [isDVD, setIsDVD] = useState(false);
const [isHD, setIsHD] = useState(false);
const [is4K, setIs4K] = useState(false);
const [is3D, setIs3D] = useState(false);
const availableVideoTypeFilters = [
{ title: "Blu-Ray", value: false, state: (val) => setIsBluRay(val) },
{ title: "DVD", value: false, state: (val) => setIsDVD(val) },
{ title: "HD", value: false, state: (val) => setIsHD(val) },
{ title: "4K", value: false, state: (val) => setIs4K(val) },
{ title: "3D", value: false, state: (val) => setIs3D(val) },
];
const [currentViewType, setCurrentViewType] = useState(undefined);
const [viewType, setViewType] = useState([]);
useEffect(() => {
@@ -250,6 +264,10 @@ const LibraryView = () => {
hasSpecialFeature: hasSpecialFeature ? true : undefined,
hasThemeSong: hasThemeSong ? true : undefined,
hasThemeVideo: hasThemeVideo ? true : undefined,
videoTypes: [isBluRay && "BluRay", isDVD && "Dvd"],
isHd: isHD ? true : undefined,
is4K: is4K ? true : undefined,
is3D: is3D ? true : undefined,
});
}
return result.data;
@@ -279,6 +297,7 @@ const LibraryView = () => {
hasThemeSong,
hasThemeVideo,
],
[isBluRay, isDVD, isHD, is4K, is3D],
],
],
queryFn: () => fetchLibItems(id),
@@ -404,11 +423,16 @@ const LibraryView = () => {
? "true"
: undefined
}
startIcon={
<MdiFilterOutline />
}
endIcon={
<MdiChevronDown />
}
onClick={openFiltersMenu}
color="white"
// sx={{ p: 1 }}
// size="small"
>
Filter
</Button>
@@ -578,6 +602,79 @@ const LibraryView = () => {
</AccordionDetails>
</Accordion>
)}
{!onlyStatusFilterViews.includes(
currentLib.data
.Items[0]
.CollectionType,
) && (
<Accordion>
<AccordionSummary
expandIcon={
<MdiChevronDown />
}
aria-controls="panel1bh-content"
id="panel1bh-header"
>
<Typography
sx={{
flexShrink: 0,
}}
noWrap
>
Video
Type
</Typography>
</AccordionSummary>
<Divider />
<AccordionDetails
sx={{
maxHeight:
"15em",
overflow:
"auto",
}}
>
<Stack>
{availableVideoTypeFilters.map(
(
item,
index,
) => {
return (
<MenuItem
sx={{
justifyContent:
"space-between",
}}
key={
index
}
>
{
item.title
}
<Checkbox
value={
item.value
}
onChange={(
e,
) =>
item.state(
e
.target
.checked,
)
}
/>
</MenuItem>
);
},
)}
</Stack>
</AccordionDetails>
</Accordion>
)}
</Menu>
</>
)}