Skip to content

Commit

Permalink
Vertical Stepper Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish-egov committed Oct 7, 2024
1 parent bcce31b commit b720036
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const UploadDataCustom = React.memo(({ formData, onSelect, ...props }) => {
const [fileName, setFileName] = useState(null);
const [downloadError, setDownloadError] = useState(false);
const [resourceId, setResourceId] = useState(null);
const id = searchParams.get("campaignId") || "4bd96853-05f9-4c5d-b321-1f10d63502bd";
const id = searchParams.get("campaignId") || null;

const { data: Schemas, isLoading: isThisLoading } = Digit.Hooks.useCustomMDMS(
tenantId,
Expand All @@ -50,8 +50,6 @@ const UploadDataCustom = React.memo(({ formData, onSelect, ...props }) => {
{ schemaCode: "HCM-ADMIN-CONSOLE.adminSchema" }
);

console.log(Schemas, " ssssssssssssssssssssssssssssss")

const { data: readMe } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "ReadMeConfig" }]);
const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "baseTimeout" }]);
const [sheetHeaders, setSheetHeaders] = useState({});
Expand All @@ -67,8 +65,7 @@ const UploadDataCustom = React.memo(({ formData, onSelect, ...props }) => {
const campaignType = totalData?.CAMPAIGN_DETAILS?.campaignDetails?.campaignType?.code
const [convertedSchema, setConvertedSchema] = useState({});
const [loader, setLoader] = useState(false);
// const [currentStep , setCurrentStep] = useState(1);
const baseKey = 4;
const baseKey = 6;

useEffect(() => {
const searchParams = new URLSearchParams(location.search);
Expand Down Expand Up @@ -116,7 +113,6 @@ const UploadDataCustom = React.memo(({ formData, onSelect, ...props }) => {
key = `${"HCM_ADMIN_CONSOLE_FACILITY_CAPACITY_MICROPLAN"}_${campaignType}`
schema.properties[key] = temp;
}
console.log(key, ' kkkkkk')
const translatedKey = t(key);
const translatedProperty = { ...schema.properties[key], name: t(schema.properties[key].name) };
newProp[translatedKey] = translatedProperty;
Expand Down Expand Up @@ -173,8 +169,6 @@ const UploadDataCustom = React.memo(({ formData, onSelect, ...props }) => {
// Update data with new properties and required fields
data.properties = properties;
data.required = required;
// delete data.campaignType;
// data.columns = sortedPropertyNames;
}

function convertIntoSchema(data) {
Expand Down Expand Up @@ -610,7 +604,6 @@ const UploadDataCustom = React.memo(({ formData, onSelect, ...props }) => {
const expectedHeaders = sheetHeaders[type];

const SheetNames = sheetTypeMap[type];
console.log(SheetNames, " shhhhhhhhhhhhhhh")

const sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[SheetNames], { blankrows: true });
var jsonData = sheetData.map((row, index) => {
Expand Down Expand Up @@ -777,7 +770,6 @@ const UploadDataCustom = React.memo(({ formData, onSelect, ...props }) => {
id,
baseTimeOut?.["HCM-ADMIN-CONSOLE"]
);
console.log(temp, " tttttttttttttttttttttt")
if (temp?.isError) {
setLoader(false);
setIsValidation(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,53 +91,54 @@ export const MicroplanConfig = (totalFormData, dataParams, isSubmitting, summary
},
],
},

{
stepCount: "4",
key: "4",
name: "UPLOADDATA",
name: "ASSUMPTIONS_FORM",
body: [
{
isMandatory: true,
key: "uploadData",
isMandatory: false,
key: "assumptionsForm",
type: "component",
skipAPICall: false,
component: "UploadDataCustom",
component: "AssumptionsForm",
withoutLabel: true,
disable: false,
withoutLabelFieldPair: true,
customProps: {
module: "HCM",
type: "boundary",
sessionData: totalFormData,
isSubmitting: isSubmitting,

},
populators: {
name: "hypothesis",
name: "assumptionsForm",
required: true,
},
},
],
},

{
stepCount: "4",
key: "5",
name: "UPLOADDATA",
name: "HYPOTHESIS",
body: [
{
isMandatory: true,
key: "uploadData",
key: "Assumptions",
type: "component",
skipAPICall: false,
component: "UploadDataCustom",
component: "HypothesisWrapper",
withoutLabel: true,
disable: false,
withoutLabelFieldPair: true,
customProps: {
module: "HCM",
type: "facilityWithBoundary",
sessionData: totalFormData,
isSubmitting: isSubmitting,

},
populators: {
name: "hypothesis",
Expand All @@ -149,97 +150,60 @@ export const MicroplanConfig = (totalFormData, dataParams, isSubmitting, summary
{
stepCount: "5",
key: "6",
name: "MP_MICROPLAN_DETAILS",
name: "UPLOADDATA",
body: [
{
isMandatory: false,
key: "microplanDetails",
type: "component",
skipAPICall: false,
resourceToUpdate: "PLAN",
component: "MicroplanDetails",
withoutLabel: true,
disable: false,
stepCount: "4",
key: "4",
name: "ASSUMPTIONS_FORM",
body: [
{
isMandatory: false,
key: "assumptionsForm",
type: "component",
skipAPICall: false,
component: "AssumptionsForm",
withoutLabel: true,
disable: false,
withoutLabelFieldPair: true,
customProps: {
module: "HCM",
sessionData: totalFormData,
isSubmitting: isSubmitting,
},
populators: {
name: "projectType",

},
populators: {
name: "assumptionsForm",
required: true,
},
},
],
}]
},
{
stepCount: "6",
key: "7",
name: "HYPOTHESIS",
body: [
{
isMandatory: true,
key: "hypothesis",
key: "uploadData",
type: "component",
skipAPICall: false,
component: "HypothesisWrapper",
component: "UploadDataCustom",
withoutLabel: true,
disable: false,
withoutLabelFieldPair: true,
customProps: {
module: "HCM",
type: "boundary",
sessionData: totalFormData,
isSubmitting: isSubmitting,
}
}
]
isSubmitting: isSubmitting


},
populators: {
name: "uploadData"
},
},
],
},
{
stepCount: "7",
key: "8",
name: "MP_MICROPLAN_DETAILS",
stepCount: "5",
key: "7",
name: "UPLOADDATA",
body: [
{
isMandatory: false,
key: "microplanDetails",
key: "uploadData",
type: "component",
skipAPICall: false,
resourceToUpdate: "PLAN",
component: "MicroplanDetails",
component: "UploadDataCustom",
withoutLabel: true,
disable: false,
withoutLabelFieldPair: true,
customProps: {
module: "HCM",
type: "facilityWithBoundary",
sessionData: totalFormData,
isSubmitting: isSubmitting,
isSubmitting: isSubmitting
},
populators: {
name: "projectType",
name: "uploadData"
},
},
],
},
{
stepCount: "8",
key: "9",
stepCount: "6",
key: "8",
name: "SUMMARY_SCREEN",
body: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const requestBodyGenerator = () => {};
const requestBodyGenerator = () => { };

//checking for duplicates
const isValidResourceName = async (name) => {
Expand Down Expand Up @@ -51,7 +51,7 @@ const isValidResourceName = async (name) => {
//generating campaign and microplan
//this will only be called on first time create so it doesn't have to be generic
const CreateResource = async (req) => {

//creating a microplan and campaign instance here
const { totalFormData, state, setShowToast, setCurrentKey, setCurrentStep, config, campaignObject, planObject } = req;
try {
Expand Down Expand Up @@ -94,7 +94,7 @@ const CreateResource = async (req) => {
},
},
});

if (campaignRes?.CampaignDetails?.id && planRes?.PlanConfiguration?.[0]?.id) {
Digit.Utils.microplanv1.updateUrlParams({
microplanId: planRes?.PlanConfiguration?.[0]?.id,
Expand Down Expand Up @@ -157,7 +157,7 @@ const createUpdatePlanProject = async (req) => {
setShowToast({ key: "error", label: "ERROR_MICROPLAN_NAME_ALREADY_EXISTS" });
return;
}

const isResourceCreated = await CreateResource(req);
if (!isResourceCreated) {
setShowToast({ key: "error", label: "ERROR_CREATING_MICROPLAN" });
Expand All @@ -176,7 +176,7 @@ const createUpdatePlanProject = async (req) => {
const updatedCampaignObject = {
...campaignObject,
boundaries: totalFormData?.BOUNDARY?.boundarySelection?.selectedData,
startDate:Math.floor(new Date(new Date().setDate(new Date().getDate() + 100)).getTime())
startDate: Math.floor(new Date(new Date().setDate(new Date().getDate() + 100)).getTime())
//hardcoding this rn to update campaign. Check with admin console team
};
const planRes = await updatePlan(updatedCampaignObject);
Expand All @@ -197,16 +197,23 @@ const createUpdatePlanProject = async (req) => {
triggeredFrom,
};

case "UPLOADDATA":
setCurrentKey((prev) => prev + 1);
setCurrentStep((prev) => prev + 1);
return {
triggeredFrom,
};

case "HYPOTHESIS":
setCurrentKey((prev) => prev + 1);
setCurrentStep((prev) => prev + 1);
window.dispatchEvent(new Event("isLastStep"))
return {
triggeredFrom,
};
setCurrentKey((prev) => prev + 1);
setCurrentStep((prev) => prev + 1);
window.dispatchEvent(new Event("isLastStep"))
return {
triggeredFrom,
};


default:
default:
setShowToast({ key: "error", label: "ERROR_UNHANDLED_NEXT_OPERATION" });
return {
triggeredFrom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => {
};

const onSubmit = (formData) => {

// setIsSubmittting to true -> to run inline validations within the components

setIsSubmitting(true);


Expand Down Expand Up @@ -248,6 +246,14 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => {
return <Loader />;
}

var aa = filteredConfig?.[0]?.form.map((config) => {
return {
...config,
body: config?.body.filter((a) => !a.hideInEmployee),
};
});


return (
<React.Fragment>
<Stepper
Expand All @@ -256,7 +262,7 @@ const SetupMicroplan = ({ hierarchyType, hierarchyData }) => {
"MICROPLAN_DETAILS",
"MP_BOUNDARY_SELECTION",
"MICROPLAN_ASSUMPTIONS",
"MP_USER_CREATION",
"MP_MANAGING_DATA",
"FORMULA_CONFIGURATION",
"SUMMARY",
]}
Expand Down

0 comments on commit b720036

Please sign in to comment.