ldc-ovoteam/resources/ts/front/Components/Base/VideoEmbedWithConsent.tsx
K Muller db25bec3e5 feat: ✨ add :
- sentry
- variables in manifest
- some dynamic pages
- breadcrumbs
- dynamic page resolver
2026-04-07 16:21:09 +02:00

62 lines
1.7 KiB
TypeScript

import { Loader } from "lucide-react";
import { cn, GetTranslation } from "@/lib/utils";
import { VideoProviderName } from "@/front/lib/constants";
import { useCookieNotice } from "@/hooks/use-cookie-notice";
type Props = {
service: VideoProviderName;
embedUrl: string;
title: string;
className?: string;
iframeContainerClassName?: string;
};
const VideoEmbedWithConsent = ({
service,
embedUrl,
title,
className = "",
iframeContainerClassName = ""
}: Props) => {
const { status, loading, accept } = useCookieNotice(service);
const warning = GetTranslation(`cookie-notice.custom.${service}.warning`);
const acceptLabel = GetTranslation(`cookie-notice.custom.${service}.accept`);
return (
<div className={`video-inlaid text-center ${className}`}>
{!status ? (
loading ? (
<div className="py-48 flex justify-center">
<Loader className="size-8 text-primary-foreground/40 animate-spin" />
</div>
) : (
<div className="py-48 flex gap-2 justify-center flex-col md:flex-row">
<p>{warning}</p>
<button
className="underline font-bold hover:opacity-80 transition"
type="button"
onClick={accept}
>
{acceptLabel}
</button>
</div>
)
) : (
<div className={cn("h-[81vh]", iframeContainerClassName)}>
<iframe
className="border-none"
width="100%"
height="100%"
src={embedUrl}
title={title}
allow="autoplay; encrypted-media"
allowFullScreen
/>
</div>
)}
</div>
);
};
export default VideoEmbedWithConsent;