Fixed creation of users + better frontend handling of permissions
This commit is contained in:
@@ -11,14 +11,10 @@ import {
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Loader2, Trash2 } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { Trash2 } from "lucide-react";
|
||||
import hasPermissions from "@/lib/hasPermissions";
|
||||
import IUser from "@/interfaces/IUser";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { useRouter } from "next/navigation";
|
||||
import request from "@/lib/request";
|
||||
import { ApiResponse } from "@/types/types";
|
||||
|
||||
interface DeleteArticleButtonProps {
|
||||
id: string;
|
||||
@@ -29,7 +25,9 @@ const DeleteArticleButton: React.FC<DeleteArticleButtonProps> = ({
|
||||
id,
|
||||
user,
|
||||
}) => {
|
||||
if (!user || !hasPermissions(user.roles, { blogs: ["update"] })) {
|
||||
const perms =
|
||||
user && hasPermissions(user.roles, { blogs: ["delete"] } as const);
|
||||
if (!perms?.blogs.delete) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user