2025-05-12 13:14:29 -04:00
|
|
|
"use client";
|
|
|
|
|
|
2025-05-11 00:37:32 -04:00
|
|
|
import { useRouter } from 'next/navigation';
|
2025-05-12 13:14:29 -04:00
|
|
|
import { useState, useEffect } from 'react';
|
2025-05-11 00:37:32 -04:00
|
|
|
|
2025-05-11 08:53:46 -04:00
|
|
|
export default function AddPodcastCard({ stream }: { stream?: string | string[] }) {
|
2025-05-12 13:14:29 -04:00
|
|
|
const router = useRouter(),
|
|
|
|
|
defaultBottomOffset = 16,
|
|
|
|
|
[bottomOffset, setBottomOffset] = useState(defaultBottomOffset);
|
2025-05-11 00:37:32 -04:00
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
|
router.push(`${process.env.NEXT_PUBLIC_API_BASE_URL}/${stream}/publish`);
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-12 13:14:29 -04:00
|
|
|
useEffect(() => {
|
|
|
|
|
const handleScroll = () => {
|
|
|
|
|
const footer = document.querySelector('footer');
|
|
|
|
|
if (!footer) return;
|
|
|
|
|
|
|
|
|
|
const footerRect = footer.getBoundingClientRect(),
|
|
|
|
|
viewportHeight = window.innerHeight,
|
|
|
|
|
footerVisibleHeight = Math.max(0, viewportHeight - footerRect.top);
|
|
|
|
|
|
|
|
|
|
setBottomOffset(footerVisibleHeight + 16);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('scroll', handleScroll);
|
|
|
|
|
return () => window.removeEventListener('scroll', handleScroll);
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-05-11 00:37:32 -04:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
onClick={handleClick}
|
2025-05-12 13:14:29 -04:00
|
|
|
style={{ bottom: `${bottomOffset}px` }}
|
|
|
|
|
className="fixed bottom-[70px] right-4 w-16 h-16 z-10 shadow-md rounded-full flex items-center justify-center bg-purple-500 cursor-pointer hover:bg-purple-600 transition-colors"
|
2025-05-11 00:37:32 -04:00
|
|
|
>
|
2025-05-12 13:14:29 -04:00
|
|
|
<span className="text-3xl font-bold text-white">+</span>
|
2025-05-11 00:37:32 -04:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|