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

Pfm 4943 employee UI #113

Open
wants to merge 2 commits into
base: UAT
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions frontend/micro-ui/web/micro-ui-internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"packages/react-components",
"packages/modules/Estimate",
"packages/modules/Expenditure",
"packages/Mukta"
"packages/Mukta"
],
"author": "JaganKumar <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"react-google-recaptcha": "^3.1.0",
"lodash": "4.17.21",
"lodash": "^4.17.21",
"microbundle-crl": "0.13.11",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import ReCAPTCHA from "react-google-recaptcha";

const Captcha = (props) => {


//use this key if running locally 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
const key = globalConfigs?.getConfig("RECAPTCHA_SITE_KEY");

const onChange = (value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "^1.5.0",
"lodash": "^4.17.21",
"react": "17.0.2",
"react-date-range": "^1.4.0",
"react-dom": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import _ from "lodash";
import { createWorkOrderUtils } from "../../../../utils/createWorkOrderUtils";
import { useHistory } from "react-router-dom";
import getWOModalConfig from "../../../configs/getWOModalConfig";
import debounce from 'lodash/debounce';

const navConfig = [
{
Expand Down Expand Up @@ -180,15 +181,20 @@ const CreateWorkOrderForm = ({createWorkOrderConfig, sessionFormData, setSession
updateAction : isModify ? "EDIT" : "",
}

const onModalSubmit = async (modalData) => {
const debouncedOnModalSubmit = debounce(async (modalData) => {
modalData = Digit.Utils.trimStringsInObject(modalData)
const payload = createWorkOrderUtils({tenantId, estimate, project, inputFormdata, selectedApprover, modalData, createWorkOrderConfig, modifyParams, docConfigData});
if(isModify) {
handleResponseForUpdate(payload);
}else {
handleResponseForCreateWO(payload);
}
}
},500);

const handleSubmit = (_data) => {
// Call the debounced version of onModalSubmit
debouncedOnModalSubmit(_data);
};

const sendDataToResponsePage = (contractNumber, isSuccess, message, showID) => {
history.push({
Expand All @@ -207,7 +213,7 @@ const CreateWorkOrderForm = ({createWorkOrderConfig, sessionFormData, setSession
showModal &&
<WorkflowModal
closeModal={() => setShowModal(false)}
onSubmit={onModalSubmit}
onSubmit={handleSubmit}
config={createWOModalConfig}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createEstimateConfig } from './createEstimateConfig'
import { createEstimatePayload } from './createEstimatePayload'
import { useHistory,useLocation } from "react-router-dom";
import { editEstimateUtil } from './editEstimateUtil'
import debounce from 'lodash/debounce';


const configNavItems = [
Expand Down Expand Up @@ -254,93 +255,99 @@ const CreateEstimate = () => {

setShowModal(true);
};
const onModalSubmit = async (_data) => {
_data = Digit.Utils.trimStringsInObject(_data)
const debouncedOnModalSubmit = debounce(async (_data) => {
_data = Digit.Utils.trimStringsInObject(_data);
const completeFormData = {
..._data,
...inputFormData,
selectedApprover,
// selectedDept,
// selectedDesignation
..._data,
...inputFormData,
selectedApprover,
// selectedDept,
// selectedDesignation
}

const payload = createEstimatePayload(completeFormData, projectData,isEdit,estimate)


const payload = createEstimatePayload(completeFormData, projectData,isEdit,estimate);
setShowModal(false);

//make a util for updateEstimatePayload since there are some deviations

if(isEdit && estimateNumber){

await EstimateUpdateMutation(payload, {
await EstimateUpdateMutation(payload, {
onError: async (error, variables) => {
setShowToast({ warning: true, label: error?.response?.data?.Errors?.[0].message ? error?.response?.data?.Errors?.[0].message : error });
setTimeout(() => {
setShowToast(false);
}, 5000);

setShowToast({ warning: true, label: error?.response?.data?.Errors?.[0].message ? error?.response?.data?.Errors?.[0].message : error });
setTimeout(() => {
setShowToast(false);
}, 5000);
},
onSuccess: async (responseData, variables) => {
clearSessionFormData();
const state = {
header: t("WORKS_ESTIMATE_RESPONSE_UPDATED_HEADER"),
id: responseData?.estimates[0]?.estimateNumber,
info: t("ESTIMATE_ESTIMATE_NO"),
// message: t("WORKS_ESTIMATE_RESPONSE_MESSAGE_CREATE", { department: t(`ES_COMMON_${responseData?.estimates[0]?.executingDepartment}`) }),
links: [
{
name: t("WORKS_GOTO_ESTIMATE_INBOX"),
redirectUrl: `/${window.contextPath}/employee/estimate/inbox`,
code: "",
svg: "GotoInboxIcon",
isVisible: true,
type: "inbox",
}
],
}
history.push(`/${window?.contextPath}/employee/estimate/response`, state);

clearSessionFormData();
const state = {
header: t("WORKS_ESTIMATE_RESPONSE_UPDATED_HEADER"),
id: responseData?.estimates[0]?.estimateNumber,
info: t("ESTIMATE_ESTIMATE_NO"),
// message: t("WORKS_ESTIMATE_RESPONSE_MESSAGE_CREATE", { department: t(`ES_COMMON_${responseData?.estimates[0]?.executingDepartment}`) }),
links: [
{
name: t("WORKS_GOTO_ESTIMATE_INBOX"),
redirectUrl: `/${window.contextPath}/employee/estimate/inbox`,
code: "",
svg: "GotoInboxIcon",
isVisible: true,
type: "inbox",
}
],
};

history.push(`/${window?.contextPath}/employee/estimate/response`, state);

},
});
});
}


else{
await EstimateMutation(payload, {
await EstimateMutation(payload, {
onError: async (error, variables) => {
setShowToast({ warning: true, label: error?.response?.data?.Errors?.[0].message ? error?.response?.data?.Errors?.[0].message : error });
setTimeout(() => {
setShowToast(false);
}, 5000);
setShowToast({ warning: true, label: error?.response?.data?.Errors?.[0].message ? error?.response?.data?.Errors?.[0].message : error });
setTimeout(() => {
setShowToast(false);
}, 5000);
},
onSuccess: async (responseData, variables) => {
clearSessionFormData();
const state = {
header: t("WORKS_ESTIMATE_RESPONSE_CREATED_HEADER"),
id: responseData?.estimates[0]?.estimateNumber,
info: t("ESTIMATE_ESTIMATE_NO"),
// message: t("WORKS_ESTIMATE_RESPONSE_MESSAGE_CREATE", { department: t(`ES_COMMON_${responseData?.estimates[0]?.executingDepartment}`) }),
links: [
{
name: t("WORKS_GOTO_ESTIMATE_INBOX"),
redirectUrl: `/${window.contextPath}/employee/estimate/inbox`,
code: "",
svg: "GotoInboxIcon",
isVisible: true,
type: "inbox",
}
],
}
history.push(`/${window?.contextPath}/employee/estimate/response`, state);
clearSessionFormData();
const state = {
header: t("WORKS_ESTIMATE_RESPONSE_CREATED_HEADER"),
id: responseData?.estimates[0]?.estimateNumber,
info: t("ESTIMATE_ESTIMATE_NO"),
// message: t("WORKS_ESTIMATE_RESPONSE_MESSAGE_CREATE", { department: t(`ES_COMMON_${responseData?.estimates[0]?.executingDepartment}`) }),
links: [
{
name: t("WORKS_GOTO_ESTIMATE_INBOX"),
redirectUrl: `/${window.contextPath}/employee/estimate/inbox`,
code: "",
svg: "GotoInboxIcon",
isVisible: true,
type: "inbox",
}
],
};

history.push(`/${window?.contextPath}/employee/estimate/response`, state);

},
});
});
}
}
}, 500); // Adjust the debounce delay (in milliseconds) as needed


const handleSubmit = (_data) => {
// Call the debounced version of onModalSubmit
debouncedOnModalSubmit(_data);
};

// const { isLoading: mdmsLoading, data: mdmsData, isSuccess: mdmsSuccess } = Digit.Hooks.useCustomMDMS(
// Digit.ULBService.getCurrentTenantId(),
Expand Down Expand Up @@ -407,7 +414,7 @@ const CreateEstimate = () => {
<Fragment>
{showModal && <WorkflowModal
closeModal={() => setShowModal(false)}
onSubmit={onModalSubmit}
onSubmit={handleSubmit}
config={config}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "^1.5.0",
"lodash": "^4.17.21",
"react": "17.0.2",
"react-date-range": "^1.4.0",
"react-dom": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useHistory } from "react-router-dom";
import { createBillPayload } from "../../../utils/createBillUtils";
import { updateBillPayload } from "../../../utils/updateBillPayload";
import getModalConfig from "./config";
import debounce from 'lodash/debounce';

const navConfig = [
{
Expand Down Expand Up @@ -146,7 +147,7 @@ const CreatePurchaseBillForm = ({
}, [approvers])


const onModalSubmit = async (_data) => {
const debouncedOnModalSubmit = debounce(async (_data) => {
_data = Digit.Utils.trimStringsInObject(_data)
//here make complete data in combination with _data and inputFormData and create payload accordingly
//also test edit flow with this change
Expand Down Expand Up @@ -185,7 +186,7 @@ const CreatePurchaseBillForm = ({
},
});
}
}
},500);

const onFormSubmit = async(data) => {
data = Digit.Utils.trimStringsInObject(data)
Expand Down Expand Up @@ -218,11 +219,16 @@ const CreatePurchaseBillForm = ({
};
});

const handleSubmit = (_data) => {
// Call the debounced version of onModalSubmit
debouncedOnModalSubmit(_data);
};

return (
<React.Fragment>
{showModal && <WorkflowModal
closeModal={() => setShowModal(false)}
onSubmit={onModalSubmit}
onSubmit={handleSubmit}
config={config}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "^1.5.0",
"lodash": "^4.17.21",
"react": "17.0.2",
"react-date-range": "^1.4.0",
"react-dom": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
import { useHistory } from 'react-router-dom';
import { FormComposer, Loader, Toast } from '@egovernments/digit-ui-react-components';
import { getTomorrowsDate, getBankAccountUpdatePayload, getOrgPayload } from '../../../../utils';
import debounce from 'lodash/debounce';

const navConfig = [
{
Expand Down Expand Up @@ -40,7 +41,6 @@ const CreateOrganizationForm = ({ createOrganizationConfig, sessionFormData, set

const { mutate: CreateBankAccountMutation } = Digit.Hooks.bankAccount.useCreateBankAccount();
const { mutate: UpdateBankAccountMutation } = Digit.Hooks.bankAccount.useUpdateBankAccount();

//location data
const ULB = Digit.Utils.locale.getCityLocale(tenantId);
const ORG_VALIDTO_DATE = '2099-03-31';
Expand Down Expand Up @@ -276,7 +276,7 @@ const CreateOrganizationForm = ({ createOrganizationConfig, sessionFormData, set



const onSubmit = async (data) => {
const debouncedOnModalSubmit = debounce(async (data) => {
data = Digit.Utils.trimStringsInObject(data)
//here call org search with mobile number and see if number is already there with some other org , do an early return

Expand Down Expand Up @@ -329,15 +329,20 @@ const CreateOrganizationForm = ({ createOrganizationConfig, sessionFormData, set
handleResponseForCreate(orgPayload, data);
}
}
}
},500);

const handleSubmit = (_data) => {
// Call the debounced version of onModalSubmit
debouncedOnModalSubmit(_data);
};

if(locationDataFetching || orgDataFetching) return <Loader/>
return (
<React.Fragment>
<FormComposer
label={isModify ? "CORE_COMMON_SAVE" : t("MASTERS_CREATE_ORGANISATION")}
config={config?.form}
onSubmit={onSubmit}
onSubmit={handleSubmit}
submitInForm={false}
fieldStyle={{ marginRight: 0 }}
inline={false}
Expand Down
Loading