Skip to content

Commit

Permalink
Merge pull request #54 from egovernments/ISNE-223
Browse files Browse the repository at this point in the history
Corrected FormComposerV2 Error
  • Loading branch information
vinothrallapalli-eGov authored Sep 18, 2024
2 parents e76e947 + e869c1f commit 565e397
Show file tree
Hide file tree
Showing 13 changed files with 2,276 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { FormComposer, Toast, Header, FormComposerV2 } from "@upyog/digit-ui-react-components";
import { FormComposer, Toast, Header } from "@upyog/digit-ui-react-components";
import { FormComposerV2 } from "../../../../../../../react-components/src";
import { useHistory } from "react-router-dom";
import WorkerConfig from "../../configs/WorkerConfig";
import { useQueryClient } from "react-query";
Expand All @@ -17,7 +18,9 @@ const AddWorker = ({ parentUrl, heading }) => {
const [Config, setConfig] = useState(WorkerConfig({ t }));
const [skillsOption, setSkillsOption] = useState([]);
const [employer, setEmployer] = useState([]);
const { isLoading: isLoading, isError: vendorCreateError, data: updateResponse, error: updateError, mutate } = Digit.Hooks.fsm.useWorkerCreate(tenantId);
const { isLoading: isLoading, isError: vendorCreateError, data: updateResponse, error: updateError, mutate } = Digit.Hooks.fsm.useWorkerCreate(
tenantId
);
const {
isLoading: isVendorUpdateLoading,
isError: isvendorUpdateError,
Expand All @@ -26,9 +29,13 @@ const AddWorker = ({ parentUrl, heading }) => {
mutate: vendorMutate,
} = Digit.Hooks.fsm.useVendorUpdate(tenantId);

const { isLoading: isPlantUserLoading, isError: isPlantUserError, data: plantUserResponse, error: PlantUserError, mutate: PlantUserMutate } = Digit.Hooks.fsm.usePlantUserCreate(
tenantId
);
const {
isLoading: isPlantUserLoading,
isError: isPlantUserError,
data: plantUserResponse,
error: PlantUserError,
mutate: PlantUserMutate,
} = Digit.Hooks.fsm.usePlantUserCreate(tenantId);

const { isLoading: ismdms, data: mdmsOptions } = Digit.Hooks.useCustomMDMS(
stateId,
Expand Down Expand Up @@ -130,7 +137,9 @@ const AddWorker = ({ parentUrl, heading }) => {
restructuredData.push(restructuredItem);
});

const driverLicenses = roleDetails?.filter((entry) => entry.fn_role && entry.fn_role.code === "DRIVER" && entry.licenseNo).map((entry) => entry.licenseNo);
const driverLicenses = roleDetails
?.filter((entry) => entry.fn_role && entry.fn_role.code === "DRIVER" && entry.licenseNo)
.map((entry) => entry.licenseNo);
const roleDetailsArray = [];

roleDetails?.forEach((item, index) => {
Expand Down Expand Up @@ -320,4 +329,4 @@ const AddWorker = ({ parentUrl, heading }) => {
);
};

export default AddWorker;
export default AddWorker;
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Toast, Header, FormComposerV2, Loader } from "@upyog/digit-ui-react-components";
import { Toast, Header, Loader } from "@upyog/digit-ui-react-components";
import { FormComposerV2 } from "../../../../../../../react-components/src";

import { useHistory } from "react-router-dom";
import WorkerConfig from "../../configs/WorkerConfig";
import WorkerConfig from "../../../employee/configs/WorkerConfig";
import { useQueryClient } from "react-query";

// IND-2023-11-24-010875
Expand Down Expand Up @@ -68,8 +70,9 @@ const EditWorker = ({ parentUrl, heading }) => {
setEmployer(tempEmp);
}, [mdmsOptions, ismdms]);


const { isLoading: isLoading, isError: vendorCreateError, data: updateResponse, error: updateError, mutate } = Digit.Hooks.fsm.useWorkerUpdate(tenantId);
const { isLoading: isLoading, isError: vendorCreateError, data: updateResponse, error: updateError, mutate } = Digit.Hooks.fsm.useWorkerUpdate(
tenantId
);

const { data: workerData, isLoading: WorkerLoading } = Digit.Hooks.fsm.useWorkerSearch({
tenantId,
Expand All @@ -89,7 +92,13 @@ const EditWorker = ({ parentUrl, heading }) => {
setConfig(WorkerConfig({ t, disabled: true, skillsOption, defaultSkill: workerDetails?.skills?.filter((i) => i.isDeleted === false), employer }));
}, [skillsOption, employer, workerData]);

const { data: vendorData, isLoading: isVendorLoading, isSuccess: isVendorSuccess, error: vendorError, refetch: refetchVendor } = Digit.Hooks.fsm.useDsoSearch(
const {
data: vendorData,
isLoading: isVendorLoading,
isSuccess: isVendorSuccess,
error: vendorError,
refetch: refetchVendor,
} = Digit.Hooks.fsm.useDsoSearch(
tenantId,
{ sortBy: "name", sortOrder: "ASC", status: "ACTIVE", individualIds: workerData?.Individual?.[0]?.id },
{ enabled: workerData && !WorkerLoading, cacheTime: 0 },
Expand Down Expand Up @@ -162,7 +171,7 @@ const EditWorker = ({ parentUrl, heading }) => {
}

useEffect(() => {
if (workerData && workerData?.Individual && !isVendorLoading && vendorData ) {
if (workerData && workerData?.Individual && !isVendorLoading && vendorData) {
const workerDetails = workerData?.Individual?.[0];
const respSkills = workerDetails?.skills?.filter((i) => i.isDeleted === false);
setWorkerinfo(workerDetails);
Expand Down Expand Up @@ -242,7 +251,10 @@ const EditWorker = ({ parentUrl, heading }) => {
formData?.employementDetails?.vendor &&
(!formData?.AddWorkerRoles || formData?.AddWorkerRoles?.length === 0 || (formData?.AddWorkerRoles?.length > 0 && checkRoleField))
) {
if (errors?.SelectEmployeePhoneNumber?.isMobilePresent && formData?.SelectEmployeePhoneNumber?.mobileNumber !== workerData?.Individual?.[0]?.mobileNumber) {
if (
errors?.SelectEmployeePhoneNumber?.isMobilePresent &&
formData?.SelectEmployeePhoneNumber?.mobileNumber !== workerData?.Individual?.[0]?.mobileNumber
) {
setSubmitValve(false);
} else {
setSubmitValve(true);
Expand Down Expand Up @@ -275,7 +287,9 @@ const EditWorker = ({ parentUrl, heading }) => {
let respSkills = workerinfo?.skills;

// if skills are not there but present in resp then remove
respSkills = respSkills.filter((resp_item) => skills.some((mydata_item) => resp_item.type === mydata_item.type && resp_item.level === mydata_item.level));
respSkills = respSkills.filter((resp_item) =>
skills.some((mydata_item) => resp_item.type === mydata_item.type && resp_item.level === mydata_item.level)
);
// respSkills.forEach((resp_item) => {
// const existsInSelected = skills.some((selected_item) => resp_item.type === selected_item.type && resp_item.level === selected_item.level);
// resp_item.isDeleted = !existsInSelected;
Expand Down Expand Up @@ -306,7 +320,9 @@ const EditWorker = ({ parentUrl, heading }) => {
restructuredData.push(restructuredItem);
});

const driverLicenses = roleDetails?.filter((entry) => entry.fn_role && entry.fn_role.code === "DRIVER" && entry.licenseNo).map((entry) => entry.licenseNo);
const driverLicenses = roleDetails
?.filter((entry) => entry.fn_role && entry.fn_role.code === "DRIVER" && entry.licenseNo)
.map((entry) => entry.licenseNo);
const roleDetailsArray = [];

if (roleDetails) {
Expand Down Expand Up @@ -506,4 +522,4 @@ const EditWorker = ({ parentUrl, heading }) => {
);
};

export default EditWorker;
export default EditWorker;
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from "react";
import PropTypes from "prop-types";

/**
* Button Component
*
* @author jagankumar-egov
*
* Feature :: CORE
*
* @example
* // Primary button
<Button label={t(configs?.label)} onButtonClick={()=>{}} type="button" style={{ marginLeft: "10px" }} />
// Secondary button & Optional with Icon
<Button label={t(configs?.label)} variation="secondary" icon={<AddFilled />} onButtonClick={()=>{}} type="button" style={{ marginLeft: "10px" }} />
// Disabled Button
<Button label={t("Disabled")} onButtonClick={()=>{}} type="button" style={{ marginLeft: "10px" }} isDisabled={true} />
*/

const Button = (props) => {
let className = props?.variation !== "primary" ? `jk-digit-secondary-btn` : `jk-digit-primary-btn`;
return (
<button
className={`${className} ${(props?.className && props?.className) || ""} ${(props?.isDisabled && "jk-digit-disabled-btn") || ""}`}
type={props.type || "button"}
form={props.formId}
onClick={props.onButtonClick}
disabled={props?.isDisabled}
style={props.style ? props.style : null}
onChange={props?.onChange}
>
{props?.icon && props.icon}
<h2 style={{ ...props?.textStyles, ...{ width: "100%" } }}>{props.label}</h2>
{props.children}
</button>
);
};

Button.propTypes = {
/**
* ButtonSelector content
*/
label: PropTypes.string.isRequired,
/**
* button border theme
*/
variation: PropTypes.string,
/**
* button icon if any
*/
icon: PropTypes.element,
/**
* click handler
*/
onButtonClick: PropTypes.func.isRequired,
/**
* Custom classname
*/
className: PropTypes.string,
/**
* Custom styles
*/
style: PropTypes.object,
/**
* Custom label style or h2 style
*/
textStyles: PropTypes.object,
};

Button.defaultProps = {
label: "TEST",
variation: "primary",
onButtonClick: () => {},
};

export default Button;
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { useState } from "react";
import { useTranslation } from "react-i18next";

const HorizontalNav = ({
configNavItems,
activeLink,
setActiveLink,
showNav = false,
children,
customStyle = {},
customClassName = "",
inFormComposer = true,
navClassName = "",
navStyles = {},
}) => {
const { t } = useTranslation();

const setActive = (item) => {
setActiveLink(item.name);
};

const MenuItem = ({ item }) => {
let itemComponent = item.code;

const Item = () => (
<span className="menu-item">
<div className="menu-label">{t(itemComponent)}</div>
</span>
);

return <Item />;
};
return (
<div className={navClassName} style={{ ...navStyles }}>
{showNav && (
<div
className={`horizontal-nav ${customClassName}`}
style={inFormComposer ? { marginLeft: "16px", marginRight: "16px", ...customStyle } : { ...customStyle }}
>
{configNavItems?.map((item, index) => (
<div className={`sidebar-list ${activeLink === item.name ? "active" : ""}`} key={index} onClick={() => setActive(item)}>
<MenuItem item={item} />
</div>
))}
</div>
)}
{children}
</div>
);
};

export default HorizontalNav;
Loading

0 comments on commit 565e397

Please sign in to comment.