email editable only for admins

This commit is contained in:
Dobromir Popov
2024-04-30 13:16:44 +03:00
parent ad42fbf639
commit 5135a95db7

View File

@ -1,5 +1,5 @@
// import axios from "axios";
import React, { useEffect, useState } from "react";
import React, { use, useEffect, useState } from "react";
import toast from "react-hot-toast";
import { useRouter } from "next/router";
import Link from "next/link";
@ -15,6 +15,7 @@ import AvailabilityList from "../availability/AvailabilityList";
import ShiftsList from "../publisher/ShiftsList.tsx";
import ConfirmationModal from "../ConfirmationModal";
import { UserRole } from "@prisma/client";
import { getSession } from "next-auth/react";
// import { Tabs, List } from 'tw-elements'
@ -56,15 +57,11 @@ Array.prototype.groupBy = function (prop) {
}
export default function PublisherForm({ item, me }) {
const router = useRouter();
console.log("init PublisherForm: ");
const urls = {
apiUrl: "/api/data/publishers/",
indexUrl: "/cart/publishers"
indexUrl: "/dash"
}
const [helpers, setHelper] = useState(null);
const [isModalOpen, setIsModalOpen] = useState(false);
@ -202,11 +199,14 @@ export default function PublisherForm({ item, me }) {
<div className="mb-4">
<label className="label" htmlFor="desiredShiftsPerMonth">Желани смeни на месец</label>
<input type="number" id="desiredShiftsPerMonth" name="desiredShiftsPerMonth" value={publisher.desiredShiftsPerMonth} onChange={handleChange} className="textbox" placeholder="desiredShiftsPerMonth" autoFocus />
</div>
<div className="mb-4">
</div> <div className="mb-4">
<label className="label" htmlFor="email">Имейл</label>
<ProtectedRoute allowedRoles={[UserRole.ADMIN]} deniedMessage={publisher.email} className="">
<div className="border border-blue-500 border-solid p-2">
<input type="text" id="email" name="email" value={publisher.email} onChange={handleChange} className="textbox" placeholder="Email" autoFocus />
</div>
</ProtectedRoute>
</div>
<div className="mb-4">
<label className="label" htmlFor="phone">Телефон</label>
<input type="text" id="phone" name="phone" value={publisher.phone} onChange={handleChange} className="textbox" placeholder="Phone" autoFocus />
@ -263,10 +263,8 @@ export default function PublisherForm({ item, me }) {
{/* ADMINISTRATORS ONLY */}
<ProtectedRoute allowedRoles={[UserRole.ADMIN]} deniedMessage=" " className="">
<PwaManager />
<div className="border border-blue-500 border-solid p-2">
<PwaManager />
<div className="mb-4">
<label className="label" htmlFor="type">Тип</label>
<select id="type" name="type" value={publisher.type} onChange={handleChange} className="textbox" placeholder="Type" autoFocus >
@ -307,7 +305,6 @@ export default function PublisherForm({ item, me }) {
{/* Add other roles as needed */}
</select>
</div>
</div>
</ProtectedRoute>
{/* ---------------------------- Actions --------------------------------- */}