Refactor_Expenses #321
@ -51,14 +51,14 @@ const AboutProject = () => {
|
|||||||
<>
|
<>
|
||||||
<div className="card mb-6">
|
<div className="card mb-6">
|
||||||
<div className="card-header text-start">
|
<div className="card-header text-start">
|
||||||
<h6 className="card-action-title mb-0">
|
<h6 className="card-action-title mb-0 ps-1">
|
||||||
{" "}
|
{" "}
|
||||||
<i className="fa fa-building rounded-circle text-primary"></i>
|
<i className="fa fa-building rounded-circle text-primary"></i>
|
||||||
<span className="ms-2">Project Profile</span>
|
<span className="ms-2">Project Profile</span>
|
||||||
</h6>
|
</h6>
|
||||||
</div>
|
</div>
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
<ul className="list-unstyled my-3 ps-2">
|
<ul className="list-unstyled my-3 ps-0">
|
||||||
<li className="d-flex mb-3">
|
<li className="d-flex mb-3">
|
||||||
<div className="d-flex align-items-center" style={{ width: '120px' }}> {/* Adjust width as needed for alignment */}
|
<div className="d-flex align-items-center" style={{ width: '120px' }}> {/* Adjust width as needed for alignment */}
|
||||||
<i className="bx bx-cog"></i>
|
<i className="bx bx-cog"></i>
|
||||||
|
|||||||
@ -141,83 +141,92 @@ const CreateRole = ({ modalType, onClose }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 col-md-12 border">
|
<div
|
||||||
|
className="border rounded px-3"
|
||||||
|
style={{
|
||||||
|
maxHeight: "350px",
|
||||||
|
overflowY: "auto",
|
||||||
|
overflowX: "hidden", // Prevent bottom scrollbar
|
||||||
|
}}
|
||||||
|
>
|
||||||
{masterFeatures.map((feature, featureIndex) => (
|
{masterFeatures.map((feature, featureIndex) => (
|
||||||
<React.Fragment key={feature.id}>
|
<React.Fragment key={feature.id}>
|
||||||
<div
|
<div className="row my-1">
|
||||||
className="row my-1"
|
{/* Feature Title */}
|
||||||
key={feature.id}
|
<div className="col-12 text-start fw-semibold mb-2">
|
||||||
style={{ marginLeft: "0px" }}
|
{feature.name}
|
||||||
>
|
|
||||||
<div
|
|
||||||
className="col-12 col-md-3 d-flex text-start align-items-start"
|
|
||||||
style={{ wordWrap: "break-word" }}
|
|
||||||
>
|
|
||||||
<span className="fs">{feature.name}</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 col-md-1"></div>
|
{/* Permissions Grid */}
|
||||||
|
<div className="col-12">
|
||||||
<div className="col-12 col-md-8 d-flex justify-content-start align-items-center flex-wrap">
|
<div className="row">
|
||||||
{feature.featurePermissions.map((perm, permIndex) => {
|
{feature.featurePermissions.map((perm, permIndex) => {
|
||||||
const refIndex = featureIndex * 10 + permIndex;
|
const refIndex = featureIndex * 100 + permIndex;
|
||||||
return (
|
return (
|
||||||
<div className="d-flex me-3 mb-2" key={perm.id}>
|
<div
|
||||||
<label className="form-check-label" htmlFor={perm.id}>
|
className="col-12 col-sm-6 col-md-4 mb-3"
|
||||||
<input
|
key={perm.id}
|
||||||
type="checkbox"
|
>
|
||||||
className="form-check-input mx-2"
|
<div className="d-flex align-items-start">
|
||||||
id={perm.id}
|
<label
|
||||||
value={perm.id}
|
className="form-check-label d-flex align-items-center"
|
||||||
{...register("selectedPermissions")}
|
htmlFor={perm.id}
|
||||||
/>
|
|
||||||
{perm.name}
|
|
||||||
</label>
|
|
||||||
<div style={{ display: "flex", alignItems: "center" }}>
|
|
||||||
<div
|
|
||||||
key={refIndex}
|
|
||||||
ref={(el) => (popoverRefs.current[refIndex] = el)}
|
|
||||||
tabIndex="0"
|
|
||||||
className="d-flex align-items-center avatar-group justify-content-center"
|
|
||||||
data-bs-toggle="popover"
|
|
||||||
refIndex
|
|
||||||
data-bs-trigger="focus"
|
|
||||||
data-bs-placement="right"
|
|
||||||
data-bs-html="true"
|
|
||||||
data-bs-content={`
|
|
||||||
<div class="border border-secondary rounded custom-popover p-2 px-3">
|
|
||||||
${perm.description}
|
|
||||||
</div>
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
|
|
||||||
<svg
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="13"
|
|
||||||
height="13"
|
|
||||||
fill="currentColor"
|
|
||||||
className="bi bi-info-circle"
|
|
||||||
viewBox="0 0 16 16"
|
|
||||||
>
|
>
|
||||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
|
<input
|
||||||
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.547 1.11l1.91-2.011c.241-.256.384-.592.287-.984-.172-.439-.58-.827-1.13-.967a.664.664 0 0 1-.58-.309l-.15-.241-.002-.002zM8 4c-.535 0-.943.372-.943.836 0 .464.408.836.943.836.535 0 .943-.372.943-.836 0-.464-.408-.836-.943-.836z" />
|
type="checkbox"
|
||||||
</svg>
|
className="form-check-input me-2"
|
||||||
|
id={perm.id}
|
||||||
|
value={perm.id}
|
||||||
|
{...register("selectedPermissions")}
|
||||||
|
/>
|
||||||
|
{perm.name}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
{/* Info icon */}
|
||||||
|
<div className="ms-1 d-flex align-items-center">
|
||||||
|
<div
|
||||||
|
ref={(el) => (popoverRefs.current[refIndex] = el)}
|
||||||
|
tabIndex="0"
|
||||||
|
className="d-flex align-items-center justify-content-center"
|
||||||
|
data-bs-toggle="popover"
|
||||||
|
data-bs-trigger="focus"
|
||||||
|
data-bs-placement="right"
|
||||||
|
data-bs-html="true"
|
||||||
|
data-bs-content={`<div class="border border-secondary rounded custom-popover p-2 px-3">${perm.description}</div>`}
|
||||||
|
>
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="13"
|
||||||
|
height="13"
|
||||||
|
fill="currentColor"
|
||||||
|
className="bi bi-info-circle"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
>
|
||||||
|
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
|
||||||
|
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.547 1.11l1.91-2.011c.241-.256.384-.592.287-.984-.172-.439-.58-.827-1.13-.967a.664.664 0 0 1-.58-.309l-.15-.241-.002-.002zM8 4c-.535 0-.943.372-.943.836 0 .464.408.836.943.836.535 0 .943-.372.943-.836 0-.464-.408-.836-.943-.836z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
);
|
})}
|
||||||
})}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr className="hr my-1 py-1" />
|
|
||||||
|
<hr className="my-2" />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{errors.selectedPermissions && (
|
{errors.selectedPermissions && (
|
||||||
<p className="text-danger">{errors.selectedPermissions.message}</p>
|
<p className="text-danger">{errors.selectedPermissions.message}</p>
|
||||||
)}
|
)}
|
||||||
{!masterFeatures && <p>Loading...</p>}
|
{!masterFeatures && <p>Loading...</p>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{masterFeatures && (
|
{masterFeatures && (
|
||||||
<div className="col-12 text-center">
|
<div className="col-12 text-center">
|
||||||
<button type="submit" className="btn btn-sm btn-primary me-3">
|
<button type="submit" className="btn btn-sm btn-primary me-3">
|
||||||
|
|||||||
@ -7,14 +7,7 @@ import { useFeatures } from "../../hooks/useMasterRole";
|
|||||||
import { MasterRespository } from "../../repositories/MastersRepository";
|
import { MasterRespository } from "../../repositories/MastersRepository";
|
||||||
import { cacheData, getCachedData } from "../../slices/apiDataManager";
|
import { cacheData, getCachedData } from "../../slices/apiDataManager";
|
||||||
import showToast from "../../services/toastService";
|
import showToast from "../../services/toastService";
|
||||||
import {useUpdateApplicationRole} from "../../hooks/masterHook/useMaster";
|
import { useUpdateApplicationRole } from "../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const updateSchema = z.object({
|
const updateSchema = z.object({
|
||||||
role: z.string().min(1, { message: "Role is required" }),
|
role: z.string().min(1, { message: "Role is required" }),
|
||||||
@ -25,147 +18,145 @@ const updateSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const EditMaster = ({ master, onClose }) => {
|
const EditMaster = ({ master, onClose }) => {
|
||||||
const maxDescriptionLength = 255;
|
const maxDescriptionLength = 255;
|
||||||
const popoverRefs = useRef([]);
|
const popoverRefs = useRef([]);
|
||||||
const { masterFeatures } = useFeatures();
|
const { masterFeatures } = useFeatures();
|
||||||
const { mutate: updateApplicationRole, isPending: isLoading } = useUpdateApplicationRole(() => onClose?.());
|
const { mutate: updateApplicationRole, isPending: isLoading } = useUpdateApplicationRole(() => onClose?.());
|
||||||
|
|
||||||
const buildDefaultPermissions = () => {
|
const buildDefaultPermissions = () => {
|
||||||
const defaults = {};
|
const defaults = {};
|
||||||
masterFeatures.forEach((feature) => {
|
masterFeatures.forEach((feature) => {
|
||||||
feature.featurePermissions.forEach((perm) => {
|
feature.featurePermissions.forEach((perm) => {
|
||||||
const existing = master?.item?.featurePermission?.find(p => p.id === perm.id);
|
const existing = master?.item?.featurePermission?.find(p => p.id === perm.id);
|
||||||
defaults[perm.id] = existing?.isEnabled || false;
|
defaults[perm.id] = existing?.isEnabled || false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
return defaults;
|
||||||
return defaults;
|
|
||||||
};
|
|
||||||
|
|
||||||
const initialPermissions = buildDefaultPermissions();
|
|
||||||
|
|
||||||
const {
|
|
||||||
register,
|
|
||||||
handleSubmit,
|
|
||||||
formState: { errors, dirtyFields },
|
|
||||||
setError,
|
|
||||||
reset,
|
|
||||||
} = useForm({
|
|
||||||
resolver: zodResolver(updateSchema),
|
|
||||||
defaultValues: {
|
|
||||||
role: master?.item?.role || "",
|
|
||||||
description: master?.item?.description || "",
|
|
||||||
permissions: initialPermissions,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const [descriptionLength, setDescriptionLength] = useState(master?.item?.description?.length || 0);
|
|
||||||
|
|
||||||
const onSubmit = (data) => {
|
|
||||||
const existingIds = new Set(master?.item?.featurePermission?.map(p => p.id));
|
|
||||||
|
|
||||||
const updatedPermissions = Object.entries(data.permissions)
|
|
||||||
.filter(([id, value]) => {
|
|
||||||
return existingIds.has(id) || value === true || (dirtyFields.permissions?.[id]);
|
|
||||||
})
|
|
||||||
.map(([id, value]) => ({ id, isEnabled: value }));
|
|
||||||
|
|
||||||
if (updatedPermissions.length === 0) {
|
|
||||||
setError("permissions", {
|
|
||||||
type: "manual",
|
|
||||||
message: "At least one permission must be selected.",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
id: master?.item?.id,
|
|
||||||
role: data.role,
|
|
||||||
description: data.description,
|
|
||||||
featuresPermission: updatedPermissions,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
updateApplicationRole({ id: payload.id, payload });
|
const initialPermissions = buildDefaultPermissions();
|
||||||
};
|
|
||||||
// const onSubmit = (data) => {
|
|
||||||
// setIsLoading(true)
|
|
||||||
// const existingIds = new Set(
|
|
||||||
// master?.item?.featurePermission?.map((p) => p.id)
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
const {
|
||||||
// const updatedPermissions = Object.entries(data.permissions)
|
register,
|
||||||
// .filter(([id, value]) => {
|
handleSubmit,
|
||||||
// if (existingIds.has(id)) return true;
|
formState: { errors, dirtyFields },
|
||||||
|
setError,
|
||||||
// return (
|
reset,
|
||||||
// value === true ||
|
} = useForm({
|
||||||
// (dirtyFields.permissions && dirtyFields.permissions[id])
|
resolver: zodResolver(updateSchema),
|
||||||
// );
|
defaultValues: {
|
||||||
// })
|
role: master?.item?.role || "",
|
||||||
// .map(([id, value]) => ({ id, isEnabled: value }));
|
description: master?.item?.description || "",
|
||||||
|
permissions: initialPermissions,
|
||||||
|
},
|
||||||
// if (updatedPermissions.length === 0) {
|
|
||||||
// setError("permissions", {
|
|
||||||
// type: "manual",
|
|
||||||
// message: "At least one permission must be selected.",
|
|
||||||
// });
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const updatedRole = {
|
|
||||||
// id: master?.item?.id,
|
|
||||||
// role: data.role,
|
|
||||||
// description: data.description,
|
|
||||||
// featuresPermission: updatedPermissions,
|
|
||||||
// };
|
|
||||||
// MasterRespository.updateRoles(master?.item?.id, updatedRole).then((resp) => {
|
|
||||||
// setIsLoading(false)
|
|
||||||
|
|
||||||
|
|
||||||
// const cachedData = getCachedData("Application Role");
|
|
||||||
|
|
||||||
// if (cachedData) {
|
|
||||||
|
|
||||||
// const updatedData = cachedData.map((role) =>
|
|
||||||
// role.id === resp.data?.id ? { ...role, ...resp.data } : role
|
|
||||||
// );
|
|
||||||
|
|
||||||
// cacheData("Application Role", updatedData);
|
|
||||||
// }
|
|
||||||
// showToast("Application Role Updated successfully.", "success");
|
|
||||||
// setIsLoading(false)
|
|
||||||
// onClose()
|
|
||||||
// }).catch((Err) => {
|
|
||||||
// showToast(Err.message, "error");
|
|
||||||
// setIsLoading(false)
|
|
||||||
// })
|
|
||||||
|
|
||||||
// };
|
|
||||||
useEffect(() => {
|
|
||||||
reset({
|
|
||||||
role: master?.item?.role || "",
|
|
||||||
description: master?.item?.description || "",
|
|
||||||
permissions: buildDefaultPermissions(),
|
|
||||||
});
|
});
|
||||||
setDescriptionLength(master?.item?.description?.length || 0);
|
|
||||||
}, [master, reset]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const [descriptionLength, setDescriptionLength] = useState(master?.item?.description?.length || 0);
|
||||||
popoverRefs.current.forEach((el) => {
|
|
||||||
if (el) {
|
const onSubmit = (data) => {
|
||||||
new bootstrap.Popover(el, {
|
const existingIds = new Set(master?.item?.featurePermission?.map(p => p.id));
|
||||||
trigger: "focus",
|
|
||||||
placement: "right",
|
const updatedPermissions = Object.entries(data.permissions)
|
||||||
html: true,
|
.filter(([id, value]) => {
|
||||||
content: el.getAttribute("data-bs-content"),
|
return existingIds.has(id) || value === true || (dirtyFields.permissions?.[id]);
|
||||||
|
})
|
||||||
|
.map(([id, value]) => ({ id, isEnabled: value }));
|
||||||
|
|
||||||
|
if (updatedPermissions.length === 0) {
|
||||||
|
setError("permissions", {
|
||||||
|
type: "manual",
|
||||||
|
message: "At least one permission must be selected.",
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}, [masterFeatures]);
|
const payload = {
|
||||||
|
id: master?.item?.id,
|
||||||
|
role: data.role,
|
||||||
|
description: data.description,
|
||||||
|
featuresPermission: updatedPermissions,
|
||||||
|
};
|
||||||
|
|
||||||
|
updateApplicationRole({ id: payload.id, payload });
|
||||||
|
};
|
||||||
|
// const onSubmit = (data) => {
|
||||||
|
// setIsLoading(true)
|
||||||
|
// const existingIds = new Set(
|
||||||
|
// master?.item?.featurePermission?.map((p) => p.id)
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
// const updatedPermissions = Object.entries(data.permissions)
|
||||||
|
// .filter(([id, value]) => {
|
||||||
|
// if (existingIds.has(id)) return true;
|
||||||
|
|
||||||
|
// return (
|
||||||
|
// value === true ||
|
||||||
|
// (dirtyFields.permissions && dirtyFields.permissions[id])
|
||||||
|
// );
|
||||||
|
// })
|
||||||
|
// .map(([id, value]) => ({ id, isEnabled: value }));
|
||||||
|
|
||||||
|
|
||||||
|
// if (updatedPermissions.length === 0) {
|
||||||
|
// setError("permissions", {
|
||||||
|
// type: "manual",
|
||||||
|
// message: "At least one permission must be selected.",
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const updatedRole = {
|
||||||
|
// id: master?.item?.id,
|
||||||
|
// role: data.role,
|
||||||
|
// description: data.description,
|
||||||
|
// featuresPermission: updatedPermissions,
|
||||||
|
// };
|
||||||
|
// MasterRespository.updateRoles(master?.item?.id, updatedRole).then((resp) => {
|
||||||
|
// setIsLoading(false)
|
||||||
|
|
||||||
|
|
||||||
|
// const cachedData = getCachedData("Application Role");
|
||||||
|
|
||||||
|
// if (cachedData) {
|
||||||
|
|
||||||
|
// const updatedData = cachedData.map((role) =>
|
||||||
|
// role.id === resp.data?.id ? { ...role, ...resp.data } : role
|
||||||
|
// );
|
||||||
|
|
||||||
|
// cacheData("Application Role", updatedData);
|
||||||
|
// }
|
||||||
|
// showToast("Application Role Updated successfully.", "success");
|
||||||
|
// setIsLoading(false)
|
||||||
|
// onClose()
|
||||||
|
// }).catch((Err) => {
|
||||||
|
// showToast(Err.message, "error");
|
||||||
|
// setIsLoading(false)
|
||||||
|
// })
|
||||||
|
|
||||||
|
// };
|
||||||
|
useEffect(() => {
|
||||||
|
reset({
|
||||||
|
role: master?.item?.role || "",
|
||||||
|
description: master?.item?.description || "",
|
||||||
|
permissions: buildDefaultPermissions(),
|
||||||
|
});
|
||||||
|
setDescriptionLength(master?.item?.description?.length || 0);
|
||||||
|
}, [master, reset]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
popoverRefs.current.forEach((el) => {
|
||||||
|
if (el) {
|
||||||
|
new bootstrap.Popover(el, {
|
||||||
|
trigger: "focus",
|
||||||
|
placement: "right",
|
||||||
|
html: true,
|
||||||
|
content: el.getAttribute("data-bs-content"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [masterFeatures]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -199,76 +190,90 @@ useEffect(() => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 col-md-12 mx-2s" >
|
<div className="col-12 text-start">
|
||||||
|
{/* Scrollable Container with Border */}
|
||||||
|
<div
|
||||||
|
className="border rounded p-3"
|
||||||
|
style={{
|
||||||
|
maxHeight: "350px",
|
||||||
|
overflowY: "auto",
|
||||||
|
overflowX: "hidden", // Prevent horizontal scrollbar
|
||||||
|
paddingRight: "10px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{masterFeatures.map((feature, featureIndex) => (
|
||||||
|
<div key={feature.id} className="mb-3">
|
||||||
|
{/* Feature Group Title */}
|
||||||
|
<div className="fw-semibold mb-2">{feature.name}</div>
|
||||||
|
|
||||||
{masterFeatures.map((feature, featureIndex) => (
|
{/* Permissions Grid */}
|
||||||
<div className="row my-1" key={feature.id} style={{ marginLeft: "0px" }}>
|
<div className="row">
|
||||||
|
{feature.featurePermissions.map((perm, permIndex) => {
|
||||||
|
const refIndex = featureIndex * 10 + permIndex;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={perm.id}
|
||||||
|
className="col-12 col-sm-6 col-md-4 mb-3 d-flex align-items-start"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
className="form-check-label d-flex align-items-center"
|
||||||
|
htmlFor={perm.id}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="form-check-input me-2"
|
||||||
|
id={perm.id}
|
||||||
|
{...register(`permissions.${perm.id}`, {
|
||||||
|
value: initialPermissions[perm.id] || false,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
{perm.name}
|
||||||
|
</label>
|
||||||
|
|
||||||
<div className="col-12 col-md-3 d-flex text-start align-items-center" style={{ wordWrap: 'break-word' }}>
|
{/* Info Icon */}
|
||||||
<span className="fs">{feature.name}</span>
|
<div style={{ display: "flex", alignItems: "center" }}>
|
||||||
</div>
|
<div
|
||||||
<div className="col-12 col-md-1">
|
ref={(el) => (popoverRefs.current[refIndex] = el)}
|
||||||
|
tabIndex="0"
|
||||||
</div>
|
className="d-flex align-items-center justify-content-center"
|
||||||
<div className="col-12 col-md-8 d-flex justify-content-start align-items-center flex-wrap ">
|
data-bs-toggle="popover"
|
||||||
{feature.featurePermissions.map((perm, permIndex) => {
|
data-bs-trigger="focus"
|
||||||
const refIndex = (featureIndex * 10) + permIndex;
|
data-bs-placement="right"
|
||||||
return (
|
data-bs-html="true"
|
||||||
|
data-bs-content={`<div class="border border-secondary rounded custom-popover p-2 px-3">${perm.description}</div>`}
|
||||||
<div className="d-flex me-3 mb-2" key={perm.id}>
|
>
|
||||||
|
|
||||||
<label className="form-check-label" htmlFor={perm.id}>
|
<svg
|
||||||
<input
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
type="checkbox"
|
width="13"
|
||||||
className="form-check-input mx-2"
|
height="13"
|
||||||
id={perm.id}
|
fill="currentColor"
|
||||||
{...register(`permissions.${perm.id}`, {
|
className="bi bi-info-circle"
|
||||||
value: initialPermissions[perm.id] || false
|
viewBox="0 0 16 16"
|
||||||
})}
|
>
|
||||||
/>
|
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
|
||||||
|
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.547 1.11l1.91-2.011c.241-.256.384-.592.287-.984-.172-.439-.58-.827-1.13-.967a.664.664 0 0 1-.58-.309l-.15-.241-.002-.002zM8 4c-.535 0-.943.372-.943.836 0 .464.408.836.943.836.535 0 .943-.372.943-.836 0-.464-.408-.836-.943-.836z" />
|
||||||
{perm.name}
|
</svg>
|
||||||
</label>
|
|
||||||
|
|
||||||
|
|
||||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
||||||
<div
|
|
||||||
key={refIndex}
|
|
||||||
ref={(el) =>
|
|
||||||
(popoverRefs.current[refIndex] = el)
|
|
||||||
}
|
|
||||||
tabIndex="0"
|
|
||||||
className="d-flex align-items-center avatar-group justify-content-center"
|
|
||||||
data-bs-toggle="popover" refIndex
|
|
||||||
data-bs-trigger="focus"
|
|
||||||
data-bs-placement="right"
|
|
||||||
data-bs-html="true"
|
|
||||||
data-bs-content={`
|
|
||||||
<div class="border border-secondary rounded custom-popover p-2 px-3">
|
|
||||||
${perm.description}
|
|
||||||
</div>
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" className="bi bi-info-circle" viewBox="0 0 16 16">
|
|
||||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
|
|
||||||
<path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.547 1.11l1.91-2.011c.241-.256.384-.592.287-.984-.172-.439-.58-.827-1.13-.967a.664.664 0 0 1-.58-.309l-.15-.241-.002-.002zM8 4c-.535 0-.943.372-.943.836 0 .464.408.836.943.836.535 0 .943-.372.943-.836 0-.464-.408-.836-.943-.836z" />
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
</div>
|
||||||
})}
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr className="my-2" />
|
||||||
</div>
|
|
||||||
<hr className="hr my-1 py-1" />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
{errors.permissions && (
|
|
||||||
<p className="text-danger">{errors.permissions.message}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Error Display */}
|
||||||
|
{errors.permissions && (
|
||||||
|
<p className="text-danger">{errors.permissions.message}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className="col-12 text-center">
|
<div className="col-12 text-center">
|
||||||
<button type="submit" className="btn btn-sm btn-primary me-3"> {isLoading ? "Please Wait..." : "Submit"}</button>
|
<button type="submit" className="btn btn-sm btn-primary me-3"> {isLoading ? "Please Wait..." : "Submit"}</button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user