more finegrain permissions

This commit is contained in:
Dobromir Popov
2024-09-17 10:31:47 +03:00
parent 1cde34e418
commit 170ee788bb

View File

@ -1,5 +1,5 @@
import Link from "next/link";
import { Publisher } from "@prisma/client"
import { Publisher, UserRole } from "@prisma/client"
// import {IsDateXMonthsAgo} from "../../helpers/const"
import { useEffect, useState } from 'react'
import toast from "react-hot-toast";
@ -97,26 +97,27 @@ export default function PublisherCard({ publisher }) {
</div>
</a>
<div className="absolute bottom-2 right-2">
<button onClick={() => { setIsModalOpen(true) }} aria-label="Изтрий Publisher">
<svg className="w-5 h-6 text-red-500 hover:text-red-700" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path d="M10 11V17" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<path d="M14 11V17" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<path d="M4 7H20" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<path d="M6 7H12H18V18C18 19.6569 16.6569 21 15 21H9C7.34315 21 6 19.6569 6 18V7Z" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<path d="M9 5C9 3.89543 9.89543 3 11 3H13C14.1046 3 15 3.89543 15 5V7H9V5Z" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<ProtectedRoute allowedRoles={[UserRole.ADMIN]} deniedMessage=" ">
<button onClick={() => { setIsModalOpen(true) }} aria-label="Изтрий Publisher">
<svg className="w-5 h-6 text-red-500 hover:text-red-700" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path d="M10 11V17" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<path d="M14 11V17" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<path d="M4 7H20" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<path d="M6 7H12H18V18C18 19.6569 16.6569 21 15 21H9C7.34315 21 6 19.6569 6 18V7Z" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<path d="M9 5C9 3.89543 9.89543 3 11 3H13C14.1046 3 15 3.89543 15 5V7H9V5Z" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
{/* <path d="M8 9a1 1 0 000 2h4a1 1 0 100-2H8z" />
{/* <path d="M8 9a1 1 0 000 2h4a1 1 0 100-2H8z" />
<path fillRule="evenodd" d="M4.293 4.293A1 1 0 015.707 3.707L10 8l4.293-4.293a1 1 0 111.414 1.414L11.414 9l4.293 4.293a1 1 0 01-1.414 1.414L10 10.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 9 4.293 4.707a1 1 0 010-1.414z" clipRule="evenodd" /> */}
</svg>
</button>
<ConfirmationModal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
onConfirm={() => handleDelete(publisher.id)}
message="Сигурни ли сте, че искате да изтриете този профил? Това действие не може да бъде отменено."
/>
<ProtectedRoute>
</svg>
</button>
<ConfirmationModal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
onConfirm={() => handleDelete(publisher.id)}
message="Сигурни ли сте, че искате да изтриете този профил? Това действие не може да бъде отменено."
/>
</ProtectedRoute>
<ProtectedRoute allowedRoles={[UserRole.ADMIN, UserRole.POWERUSER]} deniedMessage=" ">
<button onClick={() => handleLoginAs(publisher.id)}>Login as</button>
</ProtectedRoute>
</div>