Fixed creation of users + better frontend handling of permissions

This commit is contained in:
cdricms
2025-03-06 17:34:52 +01:00
parent 3c6038bce1
commit 7cb633b4c6
46 changed files with 1511 additions and 909 deletions

View File

@@ -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;
}