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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { DialogProps } from "@mui/material"; import Alert from "components/Alert"; import Button from "components/Button"; import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, } from "components/Dialog"; import { eventKey } from "features/queryKeys"; import { Empty } from "google-protobuf/google/protobuf/empty_pb"; import { RpcError } from "grpc-web"; import { useTranslation } from "i18n"; import { COMMUNITIES, GLOBAL } from "i18n/namespaces"; import React from "react"; import { useMutation, useQueryClient } from "react-query"; import { service } from "service"; export default function CancelEventDialog({ eventId, ...props }: DialogProps & { eventId: number }) { const { t } = useTranslation([GLOBAL, COMMUNITIES]); const queryClient = useQueryClient(); const cancelEventMutation = useMutation<Empty, RpcError, void>( () => service.events.cancelEvent(eventId), { onSuccess: () => { queryClient.invalidateQueries(eventKey(eventId)); Iif (props.onClose) props.onClose({}, "escapeKeyDown"); }, } ); const handleCancelEvent = () => cancelEventMutation.mutate(); return ( <Dialog {...props} aria-labelledby="cancel-event-dialog-title"> <DialogTitle id="cancel-event-dialog-title"> {t("communities:cancel_event_dialog.title")} </DialogTitle> <DialogContent> {cancelEventMutation.error && ( <Alert severity="error">{cancelEventMutation.error?.message}</Alert> )} <DialogContentText> {t("communities:cancel_event_dialog.message")} </DialogContentText> </DialogContent> <DialogActions> <Button onClick={handleCancelEvent} loading={cancelEventMutation.isLoading} > {t("global:yes")} </Button> <Button onClick={() => props.onClose ? props.onClose({}, "escapeKeyDown") : null } loading={cancelEventMutation.isLoading} > {t("global:no")} </Button> </DialogActions> </Dialog> ); } |