import { createMemo, type Component } from "solid-js"; import { Community } from "../../components/Community"; import { dispatch, state } from "../../store/state"; import { CommunityActionTypes } from "../../store/community"; const CommunityView: Component = () => { const communityIds = createMemo(() => { const loggedUserId = state.user.loggedUserId; if (!loggedUserId) { return []; } const loggedUser = state.user.users[loggedUserId]; if (!loggedUser) { return []; } return loggedUser.communities ?? []; }); const onCommunityClick = (id: string) => { dispatch({ type: CommunityActionTypes.FETCH_COMMUNITY_START, payload: id, }); dispatch({ type: CommunityActionTypes.SET_ACTIVE_COMMUNITY, payload: id, }); }; const mapCommunity = (communityId: string) => { const community = state.community.communities[communityId]; if (!community) { return undefined; } return ( ); }; return (
{communityIds().map(mapCommunity)}
); }; export { CommunityView };