fixed code

This commit is contained in:
SlimusMinus
2026-08-11 00:24:07 +03:00
parent c50b75eece
commit 7f59ee1f38
95 changed files with 3623 additions and 2830 deletions

21
src/hooks/useModals.jsx Normal file
View File

@@ -0,0 +1,21 @@
import { useState, useCallback } from "react";
/**
* Управляет всеми модалками MainFeed через единое состояние,
* чтобы гарантировать что открыта максимум одна модалка сразу.
*
* Типы: "create" | "edit" | "profile" | "auth" | "rules" | "viewer"
*/
export function useModals() {
const [modal, setModal] = useState(null); // { type, payload }
const open = useCallback((type, payload = null) => {
setModal({ type, payload });
}, []);
const close = useCallback(() => setModal(null), []);
const isOpen = useCallback((type) => modal?.type === type, [modal]);
return { modal, open, close, isOpen };
}