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

Table changes #1913

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -380,7 +380,7 @@ const FormulaConfiguration = ({ onSelect, category, customProps, formulas: initi
className="custom-assumption-checkbox"
//key={field.key}
mainClassName={"checkboxOptionVariant"}
label={t("Show on Estimation Dashboard")}
label={t("SHOW_ON_ESTIMATION_DASHBOARD")}
checked={formula.showOnEstimationDashboard ? true : false}
onChange={(event) =>
handleFormulaChange(formula.output, "showOnEstimationDashboard", { code: !formula.showOnEstimationDashboard }, category)
nipunarora-eGov marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function UserAccess({ category, setData, nationalRoles }) {
} = Digit.Hooks.microplanv1.usePlanSearchEmployeeWithTagging({
tenantId: tenantId,
limit: rowsPerPage,
offset: (currentPage - 1) * 5,
offset: (currentPage - 1) * rowsPerPage,
nipunarora-eGov marked this conversation as resolved.
Show resolved Hide resolved
names: searchQuery,
body: {
PlanEmployeeAssignmentSearchCriteria: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const UserAccessMgmtTableWrapper = ({ role, internalKey, setupCompleted }) => {
const { t } = useTranslation();
const tenantId = Digit.ULBService.getCurrentTenantId();
const [currentPage, setCurrentPage] = useState(1);
const [rowsPerPage] = useState(5);
const [rowsPerPage,setRowsPerPage] = useState(5);
const [totalRows, setTotalRows] = useState(0);
const [showPopUp, setShowPopUp] = useState(false);
const [chipPopUpRowId, setChipPopUpRowId] = useState(null);
Expand All @@ -48,15 +48,17 @@ const UserAccessMgmtTableWrapper = ({ role, internalKey, setupCompleted }) => {

const { isLoading, data: planAssignmentData, refetch: refetchPlanSearch } = Digit.Hooks.microplanv1.usePlanSearchEmployeeWithTagging({
tenantId: tenantId,
limit: rowsPerPage,
offset: (currentPage - 1) * rowsPerPage,
body: {
"PlanEmployeeAssignmentSearchCriteria": {
tenantId: tenantId,
planConfigurationId: microplanId, //Eg. "653441d7-a2ec-4196-b978-e2619d9e0848"
role: [role]
role: [role],
config:{queryKey:`${microplanId} ${role} ${currentPage}`}
},
},
limit: rowsPerPage,
offset: (currentPage - 1) * 5,

config: {
select: (data) => {
return {
Expand Down Expand Up @@ -171,6 +173,13 @@ const UserAccessMgmtTableWrapper = ({ role, internalKey, setupCompleted }) => {

const handlePaginationChange = (page) => {
setCurrentPage(page);

};

const handleRowsPerPageChange = (newPerPage, page) => {
setRowsPerPage(newPerPage); // Update the rows per page state
setCurrentPage(page); // Optionally reset the current page or maintain it

};

if (isLoading) return <Loader />;
Expand Down Expand Up @@ -218,6 +227,7 @@ const UserAccessMgmtTableWrapper = ({ role, internalKey, setupCompleted }) => {
onChangePage={handlePaginationChange}
paginationPerPage={rowsPerPage}
paginationRowsPerPageOptions={[5, 10, 15, 20]}
onChangeRowsPerPage={handleRowsPerPageChange}
/>
{/* </Card> */}
</Card>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
const searchPlanEmployeeWithTaggingConfig = async ({ tenantId, body, limit, offset, sortOrder = "ASC", names }) => {
try {
const {PlanEmployeeAssignmentSearchCriteria}= body;
nipunarora-eGov marked this conversation as resolved.
Show resolved Hide resolved
const response = await Digit.CustomService.getResponse({
url: "/plan-service/employee/_search",
useCache: false,
method: "POST",
userService: false,
params: {
tenantId: tenantId,
limit: limit,
offset: offset,
sortOrder: sortOrder,

// sortOrder: sortOrder,
},
body: body,
body:{
PlanEmployeeAssignmentSearchCriteria:{...body.PlanEmployeeAssignmentSearchCriteria,limit,offset,tenantId}
}
Comment on lines +12 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add safety checks and validation for request body

The current implementation needs additional safety measures:

  1. Add null checks before accessing nested properties
  2. Validate pagination parameters

Apply this diff to improve safety:

 body: {
-  PlanEmployeeAssignmentSearchCriteria:{...body.PlanEmployeeAssignmentSearchCriteria,limit,offset,tenantId}
+  PlanEmployeeAssignmentSearchCriteria: {
+    ...(body?.PlanEmployeeAssignmentSearchCriteria || {}),
+    limit: Math.max(1, limit || 10),  // Ensure positive limit with default
+    offset: Math.max(0, offset || 0),  // Ensure non-negative offset
+    tenantId
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
body:{
PlanEmployeeAssignmentSearchCriteria:{...body.PlanEmployeeAssignmentSearchCriteria,limit,offset,tenantId}
}
body:{
PlanEmployeeAssignmentSearchCriteria: {
...(body?.PlanEmployeeAssignmentSearchCriteria || {}),
limit: Math.max(1, limit || 10), // Ensure positive limit with default
offset: Math.max(0, offset || 0), // Ensure non-negative offset
tenantId
}
}

});
if (!response) {
throw new Error("Employee not found with the given role");
nipunarora-eGov marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -27,8 +28,6 @@ const searchPlanEmployeeWithTaggingConfig = async ({ tenantId, body, limit, offs
userService: false,
params: {
tenantId: tenantId,
limit: limit,
offset: offset,
sortOrder: sortOrder,
userServiceUuids: uuids.join(","),
names: names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const SummaryScreen = ({ props: customProps }) => {
sections: [
{
type: "DATA",
cardHeader: { value: t("CAMPAIGN_DETAILS"), inlineStyles: { marginTop: 0, fontSize: "1.5rem" } },
cardHeader: { value: t("CAMPAIGN_DETAILS"), inlineStyles: { marginTop: 0, fontSize: "2rem" } },
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
values: [
{
key: t("CAMPAIGN_TYPE"),
Expand Down