mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-09 14:11:51 +02:00
⬆️ v3.0.0 (#704)
This commit is contained in:
parent
735056f25f
commit
c22b3abc4d
385 changed files with 19912 additions and 5250 deletions
|
@ -0,0 +1,66 @@
|
|||
import { trpc } from "@rallly/backend";
|
||||
import { Button } from "@rallly/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@rallly/ui/dialog";
|
||||
import { useRouter } from "next/router";
|
||||
import * as React from "react";
|
||||
|
||||
import { Trans } from "@/components/trans";
|
||||
import { usePostHog } from "@/utils/posthog";
|
||||
|
||||
export const DeletePollDialog: React.FunctionComponent<{
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
urlId: string;
|
||||
}> = ({ open, onOpenChange, urlId }) => {
|
||||
const posthog = usePostHog();
|
||||
const queryClient = trpc.useContext();
|
||||
const router = useRouter();
|
||||
const deletePoll = trpc.polls.delete.useMutation({
|
||||
onSuccess: () => {
|
||||
queryClient.polls.invalidate();
|
||||
posthog?.capture("deleted poll");
|
||||
onOpenChange(false);
|
||||
router.replace("/polls");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
<Trans i18nKey="deletePoll" />
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
<Trans i18nKey="deletePollDescription" />
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
onClick={() => {
|
||||
onOpenChange(false);
|
||||
}}
|
||||
>
|
||||
<Trans i18nKey="cancel" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
onClick={() => {
|
||||
deletePoll.mutate({ urlId });
|
||||
}}
|
||||
loading={deletePoll.isLoading}
|
||||
>
|
||||
<Trans i18nKey="delete" />
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue