protect some common pages
This commit is contained in:
@ -3,7 +3,7 @@ import Layout from "../components/layout";
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { url } from 'inspector';
|
||||
import ProtectedRoute, { serverSideAuth } from "/components/protectedRoute";
|
||||
import ProtectedRoute from "../components/protectedRoute";
|
||||
import axiosInstance from '../src/axiosSecure';
|
||||
import { UserRole } from "@prisma/client";
|
||||
|
||||
@ -48,56 +48,59 @@ const PDFViewerPage = ({ pdfFiles }) => {
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<h1 className="text-3xl font-bold p-4 pt-8">Разрешителни</h1>
|
||||
<ProtectedRoute allowedRoles={[UserRole.ADMIN]} deniedMessage="">
|
||||
<div className="border border-blue-500 p-4 rounded shadow-md">
|
||||
<div className="mb-6">
|
||||
<p className="text-lg mb-2">За да качите файл кликнете на бутона по-долу и изберете файл от вашия компютър.</p>
|
||||
<input type="file" onChange={handleFileUpload} className="block w-full text-sm text-gray-600
|
||||
<ProtectedRoute>
|
||||
<h1 className="text-3xl font-bold p-4 pt-8">Разрешителни</h1>
|
||||
<ProtectedRoute allowedRoles={[UserRole.ADMIN]} deniedMessage="">
|
||||
<div className="border border-blue-500 p-4 rounded shadow-md">
|
||||
<div className="mb-6">
|
||||
<p className="text-lg mb-2">За да качите файл кликнете на бутона по-долу и изберете файл от вашия компютър.</p>
|
||||
<input type="file" onChange={handleFileUpload} className="block w-full text-sm text-gray-600
|
||||
file:mr-4 file:py-2 file:px-4
|
||||
file:border-0
|
||||
file:text-sm file:font-semibold
|
||||
file:bg-blue-500 file:text-white
|
||||
hover:file:bg-blue-600"/>
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-2">Съществуващи файлове:</h3>
|
||||
{files.length > 0 ? (
|
||||
files.map((file, index) => (
|
||||
<div key={index} className="flex items-center justify-between mb-2 p-2 hover:bg-blue-50 rounded">
|
||||
<a href={file.url} className="text-blue-600 hover:text-blue-800 visited:text-purple-600 underline" target="_blank" rel="noopener noreferrer">
|
||||
{file.name}
|
||||
</a>
|
||||
<button onClick={() => handleFileDelete(file.name)} className="ml-4 bg-red-500 hover:bg-red-700 text-white font-bold py-1 px-2 rounded focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-opacity-50">
|
||||
изтрий
|
||||
</button>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<p className="text-gray-500">Няма качени файлове.</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ProtectedRoute>
|
||||
|
||||
<div style={{ width: '100%', height: 'calc(100vh - 100px)' }}> {/* Adjust the 100px based on your header/footer size */}
|
||||
{pdfFiles.map((file, index) => (
|
||||
<> <p className="pt-2">
|
||||
<a href={file.url} className="text-blue-600 hover:text-blue-800 visited:text-purple-600 underline" target='_blank'>
|
||||
Свали: {file.name}
|
||||
</a>
|
||||
</p>
|
||||
<div style={{ width: 'calc(100% - 1rem)', height: '100%' }} className='py-2'>
|
||||
< object data={file.url} type="application/pdf" style={{ width: '100%', height: '100%' }}>
|
||||
<p>Вашият браузър не поддържа PDFs файлове. Моля свалете файла за да го разгледате: <a href={file.url}>Свали {file.name}</a>.</p>
|
||||
<p>Your browser does not support PDFs. Please download the PDF to view it: <a href={file.url}> {file.name}</a>.</p>
|
||||
</object>
|
||||
</div>
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="text-lg font-semibold mb-2">Съществуващи файлове:</h3>
|
||||
{files.length > 0 ? (
|
||||
files.map((file, index) => (
|
||||
<div key={index} className="flex items-center justify-between mb-2 p-2 hover:bg-blue-50 rounded">
|
||||
<a href={file.url} className="text-blue-600 hover:text-blue-800 visited:text-purple-600 underline" target="_blank" rel="noopener noreferrer">
|
||||
{file.name}
|
||||
</a>
|
||||
<button onClick={() => handleFileDelete(file.name)} className="ml-4 bg-red-500 hover:bg-red-700 text-white font-bold py-1 px-2 rounded focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-opacity-50">
|
||||
изтрий
|
||||
</button>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<p className="text-gray-500">Няма качени файлове.</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ProtectedRoute>
|
||||
|
||||
<div style={{ width: '100%', height: 'calc(100vh - 100px)' }}> {/* Adjust the 100px based on your header/footer size */}
|
||||
{pdfFiles.map((file, index) => (
|
||||
<> <p className="pt-2">
|
||||
<a href={file.url} className="text-blue-600 hover:text-blue-800 visited:text-purple-600 underline" target='_blank'>
|
||||
Свали: {file.name}
|
||||
</a>
|
||||
</p>
|
||||
<div style={{ width: 'calc(100% - 1rem)', height: '100%' }} className='py-2'>
|
||||
< object data={file.url} type="application/pdf" style={{ width: '100%', height: '100%' }}>
|
||||
<p>Вашият браузър не поддържа PDFs файлове. Моля свалете файла за да го разгледате: <a href={file.url}>Свали {file.name}</a>.</p>
|
||||
<p>Your browser does not support PDFs. Please download the PDF to view it: <a href={file.url}> {file.name}</a>.</p>
|
||||
</object>
|
||||
</div>
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
</ProtectedRoute>
|
||||
</Layout >
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user