From c11b7269f483befb4ba2ca39fa2e6f762cee614c Mon Sep 17 00:00:00 2001 From: DevMirza Date: Tue, 27 Feb 2024 10:05:07 +0000 Subject: [PATCH] update unblockbutton --- .../community/_components/unblock-button.tsx | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/app/(dashboard)/u/[username]/community/_components/unblock-button.tsx b/app/(dashboard)/u/[username]/community/_components/unblock-button.tsx index c9648c4..8d14c31 100644 --- a/app/(dashboard)/u/[username]/community/_components/unblock-button.tsx +++ b/app/(dashboard)/u/[username]/community/_components/unblock-button.tsx @@ -1,5 +1,33 @@ -import React from "react"; +import { onUnblock } from "@/actions/block"; +import { Button } from "@/components/ui/button"; +import { useTransition } from "react"; +import { toast } from "sonner"; -export const UnblockButton = () => { - return
UnblockButton
; +interface UnblockButtonProps { + userId: string; +} + +export const UnblockButton = ({ userId }: UnblockButtonProps) => { + const [isPending, startTransition] = useTransition(); + + const onClick = () => { + startTransition(() => { + onUnblock(userId) + .then((result) => + toast.success(`User ${result.blocked.username} unblocked`) + ) + .catch(() => toast.error("Something went wrong")); + }); + }; + return ( + + ); };