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

bug bash issue #659

Merged
merged 5 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -17,7 +17,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />

<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].41-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].42-campaign/dist/index.css" />
<!-- added below css for hcm-workbench module inclusion-->

<!-- <link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" /> -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-css",
"version": "1.0.41-campaign",
"version": "1.0.42-campaign",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,9 @@ input[type="date"]::-webkit-calendar-picker-indicator {
}
.hover{
cursor: pointer;
}
.digit-dropdown-employee-select-wrap{
.digit-dropdown-employee-select-wrap--elipses{
font-size: 1rem !important;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useState, useEffect } from "react";
import { AddIcon, Button, Card, CardText, Dropdown, Header, TextInput } from "@egovernments/digit-ui-react-components";
import { AddIcon, Button, Card, CardText, Header, TextInput } from "@egovernments/digit-ui-react-components";
import { useTranslation } from "react-i18next";
import { LabelFieldPair } from "@egovernments/digit-ui-react-components";
import { DustbinIcon } from "./icons/DustbinIcon";
// import { productType } from "../configs/productType";
import { PRIMARY_COLOR } from "../utils";
import { Dropdown } from "@egovernments/digit-ui-components";

const AddProductField = ({ onSelect }) => {
const { t } = useTranslation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ const CampaignSummary = () => {
};
return (
<>
<div style={{display: "flex", justifyContent: "space-between"}}>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<Header>{t("ES_TQM_SUMMARY_HEADING")}</Header>
{data?.userGenerationSuccess?.length > 0 && (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const UploadData = ({ formData, onSelect, ...props }) => {
const [fileName, setFileName] = useState(null);
const [downloadError, setDownloadError] = useState(false);
const [resourceId, setResourceId] = useState(null);
const searchParams = new URLSearchParams(location.search);
const id = searchParams.get("id");
const { isLoading, data: Schemas } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [
{ name: "facilitySchema" },
{ name: "userSchema" },
Expand Down Expand Up @@ -425,7 +427,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
if (!validateMultipleTargets(workbook)) {
return;
}
} else if(type !== "boundary"){
} else if (type !== "boundary") {
for (const header of expectedHeaders) {
if (!headersToValidate.includes(header)) {
const errorMessage = t("HCM_MISSING_HEADERS");
Expand Down Expand Up @@ -543,13 +545,13 @@ const UploadData = ({ formData, onSelect, ...props }) => {
};
useEffect(() => {
const fetchData = async () => {
if (!errorsType[type]) {
if (!errorsType[type] && uploadedFile?.length > 0) {
setShowToast({ key: "info", label: t("HCM_VALIDATION_IN_PROGRESS") });
setIsValidation(true);
setIsError(true);

try {
const temp = await Digit.Hooks.campaign.useResourceData(uploadedFile, params?.hierarchyType, type, tenantId);
const temp = await Digit.Hooks.campaign.useResourceData(uploadedFile, params?.hierarchyType, type, tenantId, id);
Comment on lines +548 to +554
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure error handling is robust. The error message transformation might cause issues if temp.error is undefined or not a string.

- const errorMessage = temp?.error.replaceAll(":", "-");
+ const errorMessage = temp?.error ? temp.error.replaceAll(":", "-") : "Unknown error";

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.

Suggested change
if (!errorsType[type] && uploadedFile?.length > 0) {
setShowToast({ key: "info", label: t("HCM_VALIDATION_IN_PROGRESS") });
setIsValidation(true);
setIsError(true);
try {
const temp = await Digit.Hooks.campaign.useResourceData(uploadedFile, params?.hierarchyType, type, tenantId);
const temp = await Digit.Hooks.campaign.useResourceData(uploadedFile, params?.hierarchyType, type, tenantId, id);
if (!errorsType[type] && uploadedFile?.length > 0) {
setShowToast({ key: "info", label: t("HCM_VALIDATION_IN_PROGRESS") });
setIsValidation(true);
setIsError(true);
try {
const temp = await Digit.Hooks.campaign.useResourceData(uploadedFile, params?.hierarchyType, type, tenantId, id);
const errorMessage = temp?.error ? temp.error.replaceAll(":", "-") : "Unknown error";

if (temp?.isError) {
const errorMessage = temp?.error.replaceAll(":", "-");
setShowToast({ key: "error", label: errorMessage, transitionTime: 5000000 });
Expand Down Expand Up @@ -679,7 +681,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") });
return;
}
if(!params?.boundaryId || !params?.facilityId || !params?.userId){
if (!params?.boundaryId || !params?.facilityId || !params?.userId) {
setDownloadError(true);
setShowToast({ key: "info", label: t("HCM_PLEASE_WAIT_TRY_IN_SOME_TIME") });
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const useResourceData = async (data, hierarchyType, type, tenantId) => {
export const useResourceData = async (data, hierarchyType, type, tenantId, id) => {
let Type;
let Error = {
isError: false,
error: {}
error: {},
};
let response;
if (type === "facilityWithBoundary") {
Expand All @@ -22,7 +22,9 @@ export const useResourceData = async (data, hierarchyType, type, tenantId) => {
tenantId: Digit.ULBService.getCurrentTenantId(),
fileStoreId: data?.[0]?.filestoreId,
action: "validate",
additionalDetails: {},
additionalDetails: {
campaignId: id,
},
},
},
});
Expand All @@ -37,7 +39,7 @@ export const useResourceData = async (data, hierarchyType, type, tenantId) => {
return Error;
} else {
Error = errorMessage;
Error.isError = true ;
Error.isError = true;
return Error;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure consistent error handling. Here, Error is assigned a string directly, which might not be intended as Error.isError is set next line.

- Error = errorMessage;
+ Error.error = errorMessage;

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.

Suggested change
Error.isError = true;
Error.error = errorMessage;
Error.isError = true;

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ const SetupCampaign = () => {
setParams({ ...restructureFormData });
}, [params, draftData, isLoading, projectType]);


useEffect(() => {
setTimeout(() => {
setEnabled(fetchUpload || (fetchBoundary && currentKey > 6));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AddIcon, Button, CardText, Dropdown, Label, LabelFieldPair } from "@egovernments/digit-ui-react-components";
import { AddIcon, Button, CardText, Label, LabelFieldPair } from "@egovernments/digit-ui-react-components";
import React, { Fragment, useContext, useEffect, useState } from "react";
import PlusMinusInput from "../../../components/PlusMinusInput";
import { useTranslation } from "react-i18next";
import { TextInput, Toast } from "@egovernments/digit-ui-components";
import { Dropdown, TextInput, Toast } from "@egovernments/digit-ui-components";
import { Link } from "react-router-dom";
import { CycleContext } from ".";
import { PRIMARY_COLOR } from "../../../utils";
Expand Down Expand Up @@ -177,7 +177,7 @@ function AddProducts({ stref, selectedDelivery, showToast, closeToast }) {

const incrementC = (data, value) => {
if (value?.target?.value.trim() === "") return;
if (value?.target?.value.trim() === 0 || value?.target?.value.trim() > 10 ) return;
if (value?.target?.value.trim() === 0 || value?.target?.value.trim() > 10) return;
if (value === 0) return;
if (value > 10) return;
setProducts((prevState) => {
Expand Down
2 changes: 1 addition & 1 deletion micro-ui/web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<!-- added below css for hcm-workbench module inclusion-->
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].41-campaign/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].42-campaign/dist/index.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#00bcd1" />
<title>DIGIT</title>
Expand Down
Loading