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 Link from "next/link";
import { Publisher } from "@prisma/client" import { Publisher, UserRole } from "@prisma/client"
// import {IsDateXMonthsAgo} from "../../helpers/const" // import {IsDateXMonthsAgo} from "../../helpers/const"
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import toast from "react-hot-toast"; import toast from "react-hot-toast";
@ -97,6 +97,7 @@ export default function PublisherCard({ publisher }) {
</div> </div>
</a> </a>
<div className="absolute bottom-2 right-2"> <div className="absolute bottom-2 right-2">
<ProtectedRoute allowedRoles={[UserRole.ADMIN]} deniedMessage=" ">
<button onClick={() => { setIsModalOpen(true) }} aria-label="Изтрий Publisher"> <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"> <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="M10 11V17" stroke="#000000" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
@ -115,8 +116,8 @@ export default function PublisherCard({ publisher }) {
onConfirm={() => handleDelete(publisher.id)} onConfirm={() => handleDelete(publisher.id)}
message="Сигурни ли сте, че искате да изтриете този профил? Това действие не може да бъде отменено." message="Сигурни ли сте, че искате да изтриете този профил? Това действие не може да бъде отменено."
/> />
<ProtectedRoute> </ProtectedRoute>
<ProtectedRoute allowedRoles={[UserRole.ADMIN, UserRole.POWERUSER]} deniedMessage=" ">
<button onClick={() => handleLoginAs(publisher.id)}>Login as</button> <button onClick={() => handleLoginAs(publisher.id)}>Login as</button>
</ProtectedRoute> </ProtectedRoute>
</div> </div>