rallly/components/poll/use-delete-participant-modal.ts
2022-04-20 16:09:38 +01:00

31 lines
805 B
TypeScript

import { useModalContext } from "../modal/modal-provider";
import { usePoll } from "../poll-context";
import { useDeleteParticipantMutation } from "./mutations";
export const useDeleteParticipantModal = () => {
const { render } = useModalContext();
const { mutate: deleteParticipant } = useDeleteParticipantMutation();
const {
poll: { urlId },
} = usePoll();
return (participantId: string) => {
return render({
title: "Delete participant?",
description:
"Are you sure you want to remove this participant from the poll?",
okButtonProps: {
type: "danger",
},
okText: "Delete",
onOk: () => {
deleteParticipant({
pollId: urlId,
participantId,
});
},
cancelText: "Cancel",
});
};
};