⬆️ v3.0.0 (#704)

This commit is contained in:
Luke Vella 2023-06-19 17:17:00 +01:00 committed by GitHub
parent 735056f25f
commit c22b3abc4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
385 changed files with 19912 additions and 5250 deletions

View file

@ -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>
);
};