Improvements to mobile UI (#119)

This commit is contained in:
Luke Vella 2022-04-20 16:09:38 +01:00 committed by GitHub
parent f206d31083
commit dde0fe8ea1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 971 additions and 317 deletions

View file

@ -1,25 +1,31 @@
import { useModal } from "../modal";
import { useModalContext } from "../modal/modal-provider";
import { usePoll } from "../poll-context";
import { useDeleteParticipantMutation } from "./mutations";
export const useDeleteParticipantModal = (
pollId: string,
participantId: string,
) => {
const { mutate: deleteParticipant } = useDeleteParticipantMutation(pollId);
return useModal({
title: "Delete participant?",
description:
"Are you sure you want to remove this participant from the poll?",
okButtonProps: {
type: "danger",
},
okText: "Remove",
onOk: () => {
deleteParticipant({
pollId: pollId,
participantId,
});
},
cancelText: "Cancel",
});
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",
});
};
};