mvp для просмотра и загрузки фильмов

This commit is contained in:
Kayashov.SM
2025-09-10 17:48:29 +04:00
parent 96089b272d
commit 39ec47c6d7
22 changed files with 1002 additions and 55 deletions

View File

@@ -0,0 +1,47 @@
import * as React from 'react';
import {Toast, ToastContainer} from "react-bootstrap";
import {useState} from "react";
export const ToastContext = React.createContext(undefined);
export function ToastProvider({children}) {
const [toasts, setToasts] = useState([]);
// Функция для добавления нового тоста
const addToast = (message, variant = 'secondary') => {
const newToast = {
id: Date.now(), // Уникальный идентификатор
message,
variant,
};
setToasts([newToast, ...toasts]);
// Удаляем тост через 3 секунды
setTimeout(() => {
setToasts(toasts.filter(t => t.id !== newToast.id));
}, 3000);
};
return (
<ToastContext.Provider value={{ addToast }}>
{children}
<ToastContainer position="bottom-end">
{toasts.map(toast => (
<Toast
key={toast.id}
bg={toast.variant}
aria-atomic={true}
className="rounded me-2 mb-1 me-1 border-0"
autohide
delay={3000}
>
<Toast.Body className="text-white">
{toast.message}
</Toast.Body>
</Toast>
))}
</ToastContainer>
</ToastContext.Provider>
);
}