Skip to content

Commit

Permalink
update unblockbutton
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaid-maker committed Feb 27, 2024
1 parent 9d5ec7b commit c11b726
Showing 1 changed file with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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 <div>UnblockButton</div>;
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 (
<Button
disabled={isPending}
onClick={onClick}
variant="link"
size="sm"
className="text-blue-500 w-full"
>
Unblcok
</Button>
);
};

0 comments on commit c11b726

Please sign in to comment.