Skip to content

Commit

Permalink
create block server actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaid-maker committed Dec 18, 2023
1 parent 2e5600d commit 5a5634e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions actions/block.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use server";

import { blockUser, unblockUser } from "@/lib/block-service";
import { revalidatePath } from "next/cache";

export const onBlock = async (id: string) => {
const blockedUser = await blockUser(id);

revalidatePath("/");

if (blockedUser) {
revalidatePath(`/${blockedUser.blocked.username}`);
}

return blockedUser;
};

export const onUnblock = async (id: string) => {
const unblockedUser = await unblockUser(id);

revalidatePath("/");

if (unblockedUser) {
revalidatePath(`/${unblockedUser.blocked.username}`);
}

return unblockedUser;
};

0 comments on commit 5a5634e

Please sign in to comment.