All files / app/features/communities/events EventOrganizersDialog.tsx

100% Statements 11/11
100% Branches 1/1
100% Functions 2/2
100% Lines 11/11

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 412x 2x 2x 2x 2x   2x   2x               66x 73x 73x                           2x                
import Button from "components/Button";
import { Dialog, DialogActions, DialogContent, DialogTitle } from "components/Dialog";
import UsersList from "components/UsersList";
import { useTranslation } from "i18n";
import { COMMUNITIES } from "i18n/namespaces";
 
import { useEventOrganizers } from "./hooks";
 
const ORGANIZERS_DIALOG_LABEL_ID = "organizers";
 
interface EventOrganizersDialogProps {
  eventId: number;
  open: boolean;
  onClose(): void;
}
 
export default function EventOrganizersDialog({ eventId, onClose, open }: EventOrganizersDialogProps) {
  const { t } = useTranslation([COMMUNITIES]);
  const { error, fetchNextPage, hasNextPage, isFetchingNextPage, organizerIds } = useEventOrganizers({
    enabled: open,
    eventId,
    type: "all",
  });
 
  return (
    <Dialog aria-labelledby={ORGANIZERS_DIALOG_LABEL_ID} open={open} onClose={onClose}>
      <DialogTitle id={ORGANIZERS_DIALOG_LABEL_ID}>{t("communities:organizers")}</DialogTitle>
      <DialogContent>
        <UsersList error={error} userIds={organizerIds} />
      </DialogContent>
      {hasNextPage && (
        <DialogActions>
          <Button loading={isFetchingNextPage} onClick={() => fetchNextPage()}>
            {t("communities:load_more_organizers")}
          </Button>
        </DialogActions>
      )}
    </Dialog>
  );
}