Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MyMicroplan search change and user-access roles changes #1680

Merged
merged 6 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ export const UICustomizations = {
data.body.PlanConfigurationSearchCriteria.userUuid = Digit.UserService.getUser().info.uuid;
// delete data.body.PlanConfigurationSearchCriteria.pagination
data.body.PlanConfigurationSearchCriteria.status = status?.status;
data.body.PlanConfigurationSearchCriteria.name=data?.state?.searchForm?.microplanName;
cleanObject(data.body.PlanConfigurationSearchCriteria);

const dic = {
Expand All @@ -940,6 +941,11 @@ export const UICustomizations = {
return data;
},
additionalCustomizations: (row, key, column, value, t, searchResult) => {
const rolesCodes=Digit.Hooks.useSessionStorage("User", {})[0]?.info?.roles;
const roles=rolesCodes.map((item)=> item.code);
const hasRequiredRole = roles.some(
(role) => role === "ROOT_POPULATION_DATA_APPROVER" || role === "ROOT_POPULATION_APPROVER"
);
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
switch (key) {
case "ACTIONS":
const onActionSelect = (key, row) => {
Expand Down Expand Up @@ -974,31 +980,32 @@ export const UICustomizations = {
}
};
return row.status === "EXECUTION_TO_BE_DONE" ? (
<Button
<ButtonNew
label={t("START")}
variation="secondary"
icon={<ArrowForward styles={{ height: "1.25rem", width: "2.5rem" }} />}
icon={"ArrowForward"}
type="button"
disabled={!hasRequiredRole}
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => onActionSelect("START", row)}
onClick={(e) => onActionSelect("START", row)}
/>
) : row.status === "RESOURCE_ESTIMATIONS_APPROVED" ? (
<Button
<ButtonNew
label={t("WBH_DOWNLOAD")}
variation="secondary"
icon={<DownloadIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
icon={"FileDownload"}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => onActionSelect("DOWNLOAD", row)}
onClick={(e) => onActionSelect("DOWNLOAD", row)}
/>
) : (
<Button
<ButtonNew
label={t("WBH_EDIT")}
variation="secondary"
icon={<EditIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
icon={"EditIcon"}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => onActionSelect("EDIT", row)}
onClick={(e) => onActionSelect("EDIT", row)}
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
/>
);
case "NAME_OF_MICROPLAN":
Expand All @@ -1012,19 +1019,83 @@ export const UICustomizations = {
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{value}</p>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>{t("ES_COMMON_NA")}</p>
</div>
);
}
case "CAMPAIGN_DISEASE":
if (value && value !== "NA") {
return (
<div
style={{
maxWidth: "15rem", // Set the desired maximum width
wordWrap: "break-word", // Allows breaking within words
whiteSpace: "normal", // Ensures text wraps normally
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>NA</p>
<p>{t("ES_COMMON_NA")}</p>
</div>
);
}
case "CAMPAIGN_TYPE":
if (value && value !== "NA") {
return (
<div
style={{
maxWidth: "15rem", // Set the desired maximum width
wordWrap: "break-word", // Allows breaking within words
whiteSpace: "normal", // Ensures text wraps normally
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>{t("ES_COMMON_NA")}</p>
</div>
);
}
case "DISTIRBUTION_STRATEGY":
if (value && value !== "NA") {
return (
<div
style={{
maxWidth: "15rem", // Set the desired maximum width
wordWrap: "break-word", // Allows breaking within words
whiteSpace: "normal", // Ensures text wraps normally
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>{t("ES_COMMON_NA")}</p>
</div>
);
}
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
nipunarora-eGov marked this conversation as resolved.
Show resolved Hide resolved
default:
return t("ES_COMMON_NA");
}

},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function RoleTableComposer({ nationalRoles }) {
selected={rowData?.find((item) => item?.rowIndex === row?.rowIndex)?.selectedHierarchy || null}
disabled={nationalRoles?.includes(category) ? true : false}
isMandatory={true}
option={state?.boundaryHierarchy.filter((item) => !(item.boundaryType === "Village"))}
option={state?.boundaryHierarchy.filter((item) => !(item.boundaryType === "Village" || item.boundaryType==="Country"))}
select={(value) => {
row.selectedHeirarchy = value;
handleHierarchyChange(value, row);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const UICustomizations = {
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{value}</p>
<p>{t(value)}</p>
</div>
);
} else {
Expand Down Expand Up @@ -202,6 +202,7 @@ export const UICustomizations = {
data.body.PlanConfigurationSearchCriteria.userUuid = Digit.UserService.getUser().info.uuid;
// delete data.body.PlanConfigurationSearchCriteria.pagination
data.body.PlanConfigurationSearchCriteria.status = status?.status;
data.body.PlanConfigurationSearchCriteria.name=data?.state?.searchForm?.microplanName;
cleanObject(data.body.PlanConfigurationSearchCriteria);

const dic = {
Expand All @@ -223,6 +224,11 @@ export const UICustomizations = {
return data;
},
additionalCustomizations: (row, key, column, value, t, searchResult) => {
const rolesCodes=Digit.Hooks.useSessionStorage("User", {})[0]?.info?.roles;
const roles=rolesCodes.map((item)=> item.code);
const hasRequiredRole = roles.some(
(role) => role === "ROOT_POPULATION_DATA_APPROVER" || role === "ROOT_POPULATION_APPROVER"
);
switch (key) {
case "ACTIONS":
const onActionSelect = (key, row) => {
Expand Down Expand Up @@ -257,31 +263,32 @@ export const UICustomizations = {
}
};
return row.status === "EXECUTION_TO_BE_DONE" ? (
<Button
<ButtonNew
label={t("START")}
variation="secondary"
icon={<ArrowForward styles={{ height: "1.25rem", width: "2.5rem" }} />}
icon={"ArrowForward"}
type="button"
disabled={!hasRequiredRole}
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => onActionSelect("START", row)}
onClick={(e) => onActionSelect("START", row)}
/>
) : row.status === "RESOURCE_ESTIMATIONS_APPROVED" ? (
<Button
<ButtonNew
label={t("WBH_DOWNLOAD")}
variation="secondary"
icon={<DownloadIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
icon={"FileDownload"}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => onActionSelect("DOWNLOAD", row)}
onClick={(e) => onActionSelect("DOWNLOAD", row)}
/>
) : (
<Button
<ButtonNew
label={t("WBH_EDIT")}
variation="secondary"
icon={<EditIcon styles={{ height: "1.25rem", width: "2.5rem" }} />}
icon={"EditIcon"}
type="button"
className="dm-workbench-download-template-btn dm-hover"
onButtonClick={(e) => onActionSelect("EDIT", row)}
onClick={(e) => onActionSelect("EDIT", row)}
/>
);
case "NAME_OF_MICROPLAN":
Expand All @@ -295,16 +302,79 @@ export const UICustomizations = {
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{value}</p>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>{t("ES_COMMON_NA")}</p>
</div>
);
}
case "CAMPAIGN_DISEASE":
if (value && value !== "NA") {
return (
<div
style={{
maxWidth: "15rem", // Set the desired maximum width
wordWrap: "break-word", // Allows breaking within words
whiteSpace: "normal", // Ensures text wraps normally
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>NA</p>
<p>{t("ES_COMMON_NA")}</p>
</div>
);
}
case "CAMPAIGN_TYPE":
if (value && value !== "NA") {
return (
<div
style={{
maxWidth: "15rem", // Set the desired maximum width
wordWrap: "break-word", // Allows breaking within words
whiteSpace: "normal", // Ensures text wraps normally
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>{t("ES_COMMON_NA")}</p>
</div>
);
}
case "DISTIRBUTION_STRATEGY":
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
if (value && value !== "NA") {
return (
<div
style={{
maxWidth: "15rem", // Set the desired maximum width
wordWrap: "break-word", // Allows breaking within words
whiteSpace: "normal", // Ensures text wraps normally
overflowWrap: "break-word", // Break long words at the edge
}}
>
<p>{t(value)}</p>
</div>
);
} else {
return (
<div>
<p>{t("ES_COMMON_NA")}</p>
</div>
);
}
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
default:
return t("ES_COMMON_NA");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const SearchSavedPlansWithCampaign = async (body) => {
body: {
PlanEmployeeAssignmentSearchCriteria: {
tenantId: tenantId,
employeeId: [uuid],
// employeeId: [uuid],
filterUniqueByPlanConfig: true
},
},
Expand All @@ -58,6 +58,7 @@ const SearchSavedPlansWithCampaign = async (body) => {
status: body?.PlanConfigurationSearchCriteria?.status,
limit: body?.PlanConfigurationSearchCriteria?.limit,
offset: body?.PlanConfigurationSearchCriteria?.offset,
name:body.PlanConfigurationSearchCriteria.name,
nabeelmd-eGov marked this conversation as resolved.
Show resolved Hide resolved
ids: listOfPlans,
},
},
Expand Down