mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-21 02:12:24 +00:00
update whole season watched overlay and styles
This commit is contained in:
parent
1d70f002e7
commit
a9a9cbf6ea
2 changed files with 26 additions and 78 deletions
|
|
@ -1,57 +0,0 @@
|
||||||
import { Button } from "@/components/buttons/Button";
|
|
||||||
import {
|
|
||||||
OverlayDisplay,
|
|
||||||
OverlayPortal,
|
|
||||||
} from "@/components/overlays/OverlayDisplay";
|
|
||||||
|
|
||||||
interface ConfirmOverlayProps {
|
|
||||||
isOpen: boolean;
|
|
||||||
message: string;
|
|
||||||
onConfirm: (event: React.MouseEvent) => void;
|
|
||||||
onCancel: () => void;
|
|
||||||
confirmButtonTheme?: "white" | "purple" | "secondary" | "danger" | "glass";
|
|
||||||
cancelButtonTheme?: "white" | "purple" | "secondary" | "danger" | "glass";
|
|
||||||
backdropOpacity?: number;
|
|
||||||
backdropColor?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ConfirmOverlay({
|
|
||||||
isOpen,
|
|
||||||
message,
|
|
||||||
onConfirm,
|
|
||||||
onCancel,
|
|
||||||
confirmButtonTheme = "purple",
|
|
||||||
cancelButtonTheme = "secondary",
|
|
||||||
backdropOpacity = 0.5,
|
|
||||||
backdropColor = "black",
|
|
||||||
}: ConfirmOverlayProps) {
|
|
||||||
return (
|
|
||||||
<OverlayPortal show={isOpen}>
|
|
||||||
<div
|
|
||||||
className={`fixed inset-0 bg-${backdropColor} bg-opacity-${backdropOpacity * 100} flex items-center justify-center z-50`}
|
|
||||||
>
|
|
||||||
<OverlayDisplay>
|
|
||||||
<div className="bg-background-main text-white p-4 rounded-lg shadow-md flex flex-col items-center pointer-events-auto gap-3">
|
|
||||||
<p className="mb-4, text-center">{message}</p>
|
|
||||||
<div className="flex space-x-2">
|
|
||||||
<Button
|
|
||||||
theme={confirmButtonTheme}
|
|
||||||
onClick={onConfirm}
|
|
||||||
padding="px-3 py-1"
|
|
||||||
>
|
|
||||||
Confirm
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
theme={cancelButtonTheme}
|
|
||||||
onClick={onCancel}
|
|
||||||
padding="px-3 py-1"
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</OverlayDisplay>
|
|
||||||
</div>
|
|
||||||
</OverlayPortal>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { Link } from "react-router-dom";
|
||||||
import { Button } from "@/components/buttons/Button";
|
import { Button } from "@/components/buttons/Button";
|
||||||
import { Dropdown } from "@/components/form/Dropdown";
|
import { Dropdown } from "@/components/form/Dropdown";
|
||||||
import { Icon, Icons } from "@/components/Icon";
|
import { Icon, Icons } from "@/components/Icon";
|
||||||
import { ConfirmOverlay } from "@/components/overlays/details/ConfirmOverlay";
|
import { Modal, ModalCard, useModal } from "@/components/overlays/Modal";
|
||||||
import { hasAired } from "@/components/player/utils/aired";
|
import { hasAired } from "@/components/player/utils/aired";
|
||||||
import { useProgressStore } from "@/stores/progress";
|
import { useProgressStore } from "@/stores/progress";
|
||||||
|
|
||||||
|
|
@ -27,7 +27,6 @@ export function EpisodeCarousel({
|
||||||
const [customSeason, setCustomSeason] = useState("");
|
const [customSeason, setCustomSeason] = useState("");
|
||||||
const [customEpisode, setCustomEpisode] = useState("");
|
const [customEpisode, setCustomEpisode] = useState("");
|
||||||
const [SeasonWatched, setSeasonWatched] = useState(false);
|
const [SeasonWatched, setSeasonWatched] = useState(false);
|
||||||
const [isConfirmOpen, setIsConfirmOpen] = useState(false);
|
|
||||||
const [expandedEpisodes, setExpandedEpisodes] = useState<{
|
const [expandedEpisodes, setExpandedEpisodes] = useState<{
|
||||||
[key: number]: boolean;
|
[key: number]: boolean;
|
||||||
}>({});
|
}>({});
|
||||||
|
|
@ -41,6 +40,7 @@ export function EpisodeCarousel({
|
||||||
[key: number]: HTMLParagraphElement | null;
|
[key: number]: HTMLParagraphElement | null;
|
||||||
}>({});
|
}>({});
|
||||||
const updateItem = useProgressStore((s) => s.updateItem);
|
const updateItem = useProgressStore((s) => s.updateItem);
|
||||||
|
const confirmModal = useModal("season-watch-confirm");
|
||||||
|
|
||||||
const handleScroll = (direction: "left" | "right") => {
|
const handleScroll = (direction: "left" | "right") => {
|
||||||
if (!carouselRef.current) return;
|
if (!carouselRef.current) return;
|
||||||
|
|
@ -211,11 +211,11 @@ export function EpisodeCarousel({
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
setIsConfirmOpen(true);
|
confirmModal.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setIsConfirmOpen(false);
|
confirmModal.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
const currentSeasonEpisodes = episodes.filter(
|
const currentSeasonEpisodes = episodes.filter(
|
||||||
|
|
@ -259,10 +259,10 @@ export function EpisodeCarousel({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setIsConfirmOpen(false);
|
confirmModal.hide();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error in handleConfirm:", error);
|
console.error("Error in handleConfirm:", error);
|
||||||
setIsConfirmOpen(false);
|
confirmModal.hide();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -337,8 +337,6 @@ export function EpisodeCarousel({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let toggle: boolean;
|
|
||||||
|
|
||||||
if (episodeWatchedStatus.length >= 1) {
|
if (episodeWatchedStatus.length >= 1) {
|
||||||
setSeasonWatched(true); // If no episodes are watched, we want to mark all as watched
|
setSeasonWatched(true); // If no episodes are watched, we want to mark all as watched
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -410,23 +408,30 @@ export function EpisodeCarousel({
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Season Watched Confirmation */}
|
||||||
<div className="flex items-center justify-between gap-2">
|
<div className="flex items-center justify-between gap-2">
|
||||||
{isConfirmOpen && (
|
<Modal id={confirmModal.id}>
|
||||||
<ConfirmOverlay
|
<ModalCard>
|
||||||
isOpen={isConfirmOpen}
|
<h3 className="text-lg font-semibold text-white mb-4">
|
||||||
message={
|
{SeasonWatched
|
||||||
SeasonWatched
|
? t("media.seasonWatched")
|
||||||
? "Are you sure you want to mark the season as watched?"
|
: t("media.seasonUnwatched")}
|
||||||
: "Are you sure you want to mark the season as unwatched?"
|
</h3>
|
||||||
}
|
<div className="flex justify-end gap-2">
|
||||||
onConfirm={handleConfirm}
|
<Button theme="secondary" onClick={handleCancel}>
|
||||||
onCancel={handleCancel}
|
{t("actions.cancel")}
|
||||||
/>
|
</Button>
|
||||||
)}
|
<Button theme="purple" onClick={handleConfirm}>
|
||||||
|
{t("actions.confirm")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</ModalCard>
|
||||||
|
</Modal>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={(e) => toggleSeasonWatchStatus(e)}
|
onClick={(e) => toggleSeasonWatchStatus(e)}
|
||||||
className="p-1.5 bg-black/50 rounded-full hover:bg-black/80 transition-colors"
|
className="p-1.5 bg-dropdown-background hover:bg-dropdown-hoverBackground transition-colors rounded-full"
|
||||||
title={t("Mark season as watched")}
|
title={t("Mark season as watched")}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue