|
|
|
@ -1,15 +1,49 @@
|
|
|
|
|
import { Button, Dialog } from '@tih/ui';
|
|
|
|
|
|
|
|
|
|
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
|
|
|
|
|
|
|
|
|
|
import { trpc } from '~/utils/trpc';
|
|
|
|
|
type ResumeCommentDeleteFormProps = Readonly<{
|
|
|
|
|
id: string;
|
|
|
|
|
isDeletingComment: boolean;
|
|
|
|
|
setIsDeletingComment: (value: boolean) => void;
|
|
|
|
|
}>;
|
|
|
|
|
|
|
|
|
|
export default function ResumeCommentDeleteForm({
|
|
|
|
|
id,
|
|
|
|
|
isDeletingComment,
|
|
|
|
|
setIsDeletingComment,
|
|
|
|
|
}: ResumeCommentDeleteFormProps) {
|
|
|
|
|
const onDelete = () => {
|
|
|
|
|
setIsDeletingComment(false);
|
|
|
|
|
const { event: gaEvent } = useGoogleAnalytics();
|
|
|
|
|
|
|
|
|
|
const trpcContext = trpc.useContext();
|
|
|
|
|
const commentDeleteMutation = trpc.useMutation(
|
|
|
|
|
'resumes.comments.user.delete',
|
|
|
|
|
{
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
// Comments updated, invalidate query to trigger refetch
|
|
|
|
|
trpcContext.invalidateQueries(['resumes.comments.list']);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const onDelete = async () => {
|
|
|
|
|
return commentDeleteMutation.mutate(
|
|
|
|
|
{
|
|
|
|
|
id,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
setIsDeletingComment(false);
|
|
|
|
|
|
|
|
|
|
gaEvent({
|
|
|
|
|
action: 'resumes.comment_delete',
|
|
|
|
|
category: 'engagement',
|
|
|
|
|
label: 'Delete comment',
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onCancel = () => {
|
|
|
|
@ -21,7 +55,9 @@ export default function ResumeCommentDeleteForm({
|
|
|
|
|
isShown={isDeletingComment}
|
|
|
|
|
primaryButton={
|
|
|
|
|
<Button
|
|
|
|
|
disabled={commentDeleteMutation.isLoading}
|
|
|
|
|
display="block"
|
|
|
|
|
isLoading={commentDeleteMutation.isLoading}
|
|
|
|
|
label="Delete"
|
|
|
|
|
variant="danger"
|
|
|
|
|
onClick={onDelete}
|
|
|
|
@ -29,6 +65,7 @@ export default function ResumeCommentDeleteForm({
|
|
|
|
|
}
|
|
|
|
|
secondaryButton={
|
|
|
|
|
<Button
|
|
|
|
|
disabled={commentDeleteMutation.isLoading}
|
|
|
|
|
display="block"
|
|
|
|
|
label="Cancel"
|
|
|
|
|
variant="tertiary"
|
|
|
|
@ -37,7 +74,10 @@ export default function ResumeCommentDeleteForm({
|
|
|
|
|
}
|
|
|
|
|
title="Are you sure?"
|
|
|
|
|
onClose={() => setIsDeletingComment(false)}>
|
|
|
|
|
<div>Note that this is irreversible!</div>
|
|
|
|
|
<div>
|
|
|
|
|
Note that deleting this comment will delete all its replies as well.
|
|
|
|
|
This action is also irreversible! Please check before confirming!
|
|
|
|
|
</div>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|