pramod_Task-#399 : Added Access Permission For 'Directory User' Role #160
@ -6,7 +6,7 @@ export const ContactSchema = z
|
|||||||
contactCategoryId: z.string().nullable().optional(),
|
contactCategoryId: z.string().nullable().optional(),
|
||||||
address: z.string().optional(),
|
address: z.string().optional(),
|
||||||
description: z.string().min(1, { message: "Description is required" }),
|
description: z.string().min(1, { message: "Description is required" }),
|
||||||
projectIds: z.array(z.string()), // min(1, "Project is required")
|
projectIds: z.array(z.string()).nullable().optional(), // min(1, "Project is required")
|
||||||
contactEmails: z
|
contactEmails: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
@ -39,7 +39,7 @@ export const ContactSchema = z
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.min(1, { message: "At least one tag is required" }),
|
.min(1, { message: "At least one tag is required" }),
|
||||||
bucketIds: z.array(z.string()).min(1,{message:"At least one Label required"}),
|
bucketIds: z.array(z.string()).nonempty({ message: "At least one label is required" })
|
||||||
})
|
})
|
||||||
|
|
||||||
// .refine((data) => {
|
// .refine((data) => {
|
||||||
|
@ -12,8 +12,13 @@ import EmployeeList from "./EmployeeList";
|
|||||||
import { useAllEmployees, useEmployees } from "../../hooks/useEmployees";
|
import { useAllEmployees, useEmployees } from "../../hooks/useEmployees";
|
||||||
import { useSortableData } from "../../hooks/useSortableData";
|
import { useSortableData } from "../../hooks/useSortableData";
|
||||||
import ConfirmModal from "../common/ConfirmModal";
|
import ConfirmModal from "../common/ConfirmModal";
|
||||||
|
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
||||||
|
import {DIRECTORY_ADMIN, DIRECTORY_MANAGER} from "../../utils/constants";
|
||||||
|
import {useProfile} from "../../hooks/useProfile";
|
||||||
|
|
||||||
const ManageBucket = () => {
|
const ManageBucket = () =>
|
||||||
|
{
|
||||||
|
const {profile} =useProfile()
|
||||||
const [bucketList, setBucketList] = useState([]);
|
const [bucketList, setBucketList] = useState([]);
|
||||||
const { employeesList } = useAllEmployees(false);
|
const { employeesList } = useAllEmployees(false);
|
||||||
const [selectedEmployee, setSelectEmployee] = useState([]);
|
const [selectedEmployee, setSelectEmployee] = useState([]);
|
||||||
@ -22,7 +27,9 @@ const ManageBucket = () => {
|
|||||||
const [isSubmitting, setSubmitting] = useState(false);
|
const [isSubmitting, setSubmitting] = useState(false);
|
||||||
const [selected_bucket, select_bucket] = useState(null);
|
const [selected_bucket, select_bucket] = useState(null);
|
||||||
const [deleteBucket, setDeleteBucket] = useState(null);
|
const [deleteBucket, setDeleteBucket] = useState(null);
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [ searchTerm, setSearchTerm ] = useState( "" );
|
||||||
|
const DirManager = useHasUserPermission( DIRECTORY_MANAGER )
|
||||||
|
const DirAdmin = useHasUserPermission(DIRECTORY_ADMIN)
|
||||||
const {
|
const {
|
||||||
items: sortedBuckteList,
|
items: sortedBuckteList,
|
||||||
requestSort,
|
requestSort,
|
||||||
@ -336,19 +343,25 @@ const ManageBucket = () => {
|
|||||||
</td>
|
</td>
|
||||||
<td>{bucket.numberOfContacts}</td>
|
<td>{bucket.numberOfContacts}</td>
|
||||||
<td className="justify-content-center">
|
<td className="justify-content-center">
|
||||||
<div className="d-flex justify-content-center align-items-center gap-2">
|
|
||||||
<i
|
{(DirManager ||
|
||||||
className="bx bx-edit bx-sm text-primary cursor-pointer"
|
DirAdmin ||
|
||||||
onClick={() => {
|
bucket?.createdBy?.id ===
|
||||||
select_bucket(bucket);
|
profile?.employeeInfo?.id) && (
|
||||||
setAction_bucket(true);
|
<div className="d-flex justify-content-center align-items-center gap-2">
|
||||||
|
<i
|
||||||
|
className="bx bx-edit bx-sm text-primary cursor-pointer "
|
||||||
|
onClick={() => {
|
||||||
|
select_bucket(bucket);
|
||||||
|
setAction_bucket(true);
|
||||||
}}
|
}}
|
||||||
></i>
|
></i>
|
||||||
<i
|
<i
|
||||||
className="bx bx-trash bx-sm text-danger cursor-pointer"
|
className="bx bx-trash bx-sm text-danger cursor-pointer"
|
||||||
onClick={() => setDeleteBucket(bucket?.id)}
|
onClick={() => setDeleteBucket(bucket?.id)}
|
||||||
></i>
|
></i>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
@ -386,7 +399,7 @@ const ManageBucket = () => {
|
|||||||
<EmployeeList
|
<EmployeeList
|
||||||
employees={employeesList}
|
employees={employeesList}
|
||||||
onChange={(data) => setSelectEmployee(data)}
|
onChange={(data) => setSelectEmployee(data)}
|
||||||
assignedEmployee={selected_bucket?.employeeIds}
|
bucket={selected_bucket}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@ -387,13 +387,10 @@ await submitContact({ ...cleaned, id: existingContact.id });
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-md-12 mt-1 text-start">
|
<div className="col-md-12 mt-1 text-start">
|
||||||
<label className="form-label ">Select Label</label>
|
<label className="form-label ">Select Label</label>
|
||||||
|
|
||||||
<ul
|
<ul className="d-flex flex-wrap px-1 list-unstyled mb-0">
|
||||||
className="d-flex flex-wrap px-1 list-unstyled mb-0"
|
|
||||||
|
|
||||||
>
|
|
||||||
{bucketsLoaging && <p>Loading...</p>}
|
{bucketsLoaging && <p>Loading...</p>}
|
||||||
{buckets?.map((item) => (
|
{buckets?.map((item) => (
|
||||||
<li
|
<li
|
||||||
@ -417,11 +414,12 @@ await submitContact({ ...cleaned, id: existingContact.id });
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
{errors.bucketIds && (
|
||||||
|
<small className="danger-text mt-0">
|
||||||
|
{errors.bucketIds.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{errors.BucketIds && (
|
|
||||||
<small className="text-danger">{errors.BucketIds.message}</small>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user