Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 12x 12x 12x 12x 1x 6x 18x 14x 1x | import Alert from "components/Alert"; import Button from "components/Button"; import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner"; import { CalendarIcon } from "components/Icons"; import TextBody from "components/TextBody"; import { useTranslation } from "i18n"; import { COMMUNITIES } from "i18n/namespaces"; import { useRouter } from "next/router"; import { Community } from "proto/communities_pb"; import { routeToNewEvent } from "routes"; import { theme } from "theme"; import hasAtLeastOnePage from "utils/hasAtLeastOnePage"; import makeStyles from "utils/makeStyles"; import { SectionTitle, useCommunityPageStyles } from "../CommunityPage"; import { useListCommunityEvents } from "../hooks"; import CommunityLongEventCard from "./CommunityLongEventCard"; interface CommunityEventsListProps { community: Community.AsObject; } const useStyles = makeStyles((theme) => ({ eventsListContainer: { display: "grid", rowGap: theme.spacing(3), [theme.breakpoints.down("sm")]: { //break out of page padding left: "50%", marginLeft: "-50vw", marginRight: "-50vw", position: "relative", right: "50%", width: "100vw", }, marginBlockEnd: theme.spacing(2), }, })); export default function CommunityEventsList({ community, }: CommunityEventsListProps) { const { t } = useTranslation([COMMUNITIES]); const classes = { ...useCommunityPageStyles(), ...useStyles() }; const router = useRouter(); const { data, error, hasNextPage, fetchNextPage, isLoading } = useListCommunityEvents({ communityId: community.communityId, pageSize: 5, type: "all", }); return ( <> <SectionTitle icon={<CalendarIcon />}> {t("communities:events_title")} </SectionTitle> <Button className={classes.createResourceButton} onClick={() => router.push(routeToNewEvent(community.communityId))} > {t("communities:create_an_event")} </Button> {error && <Alert severity="error">{error.message}</Alert>} <div className={classes.eventsListContainer}> {isLoading ? ( <CenteredSpinner /> ) : hasAtLeastOnePage(data, "eventsList") ? ( data.pages .flatMap((page) => page.eventsList) .filter((event) => !event.isCancelled) .map((event) => ( <CommunityLongEventCard event={event} key={event.eventId} /> )) ) : ( !error && <TextBody>{t("communities:events_empty_state")}</TextBody> )} </div> {hasNextPage && ( <Button onClick={() => fetchNextPage()} sx={{ color: theme.palette.common.black, borderColor: theme.palette.grey[300], "&:hover": { borderColor: theme.palette.grey[300], backgroundColor: "#3135390A", }, }} > {t("communities:see_more_events_label")} </Button> )} </> ); } |