14 lines
503 B
TypeScript
14 lines
503 B
TypeScript
import { eventoVisibile, useEventi } from "./eventi";
|
|||
|
|
import { usePuoGestireEventi } from "./ruoli";
|
||
|
|
import { useGiocatoreId } from "./user-store";
|
||
|
|
|
||
|
|
/** Gli eventi che l'utente corrente può vedere (calendario, home, elenco). */
|
||
|
|
export function useEventiVisibili() {
|
||
|
|
const { eventi, ...resto } = useEventi();
|
||
|
|
const giocatoreId = useGiocatoreId();
|
||
|
|
const vedeTutto = usePuoGestireEventi();
|
||
|
|
return {
|
||
|
|
...resto,
|
||
|
|
eventi: eventi.filter((e) => eventoVisibile(e, giocatoreId, vedeTutto)),
|
||
|
|
};
|
||
|
|
}
|