Skip to content

Commit

Permalink
FSM verion update
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmoy-eGov committed Jun 20, 2024
1 parent ee76749 commit bb527a2
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@egovernments/digit-ui-module-bills": "1.7.24",
"@egovernments/digit-ui-module-common": "1.7.24",
"@egovernments/digit-ui-module-engagement": "1.7.24",
"@egovernments/digit-ui-module-fsm": "1.7.26",
"@egovernments/digit-ui-module-fsm": "1.7.27",
"@egovernments/digit-ui-module-mcollect": "1.7.24",
"@egovernments/digit-ui-module-noc": "1.7.24",
"@egovernments/digit-ui-module-obps": "1.7.25",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-module-fsm",
"version": "1.7.26",
"version": "1.7.27",
"license": "MIT",
"main": "dist/index.js",
"description": "Digit FSM Module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import { FormStep, CardLabel, Dropdown, RadioButtons, LabelFieldPair, RadioOrSel
import Timeline from "../components/TLTimelineInFSM";
import { useLocation } from "react-router-dom";

// const Digit = window.Digit;

const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
const allCities = Digit.Hooks.fsm.useTenants();
let tenantId = Digit.ULBService.getCurrentTenantId();

if (userType !== "employee") {
tenantId = Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY")?.code;
}
const location = useLocation();
const isNewVendor = location.pathname.includes("new-vendor");
const isEditVendor = location.pathname.includes("modify-vendor");

const inputs = [
{
active: true,
Expand All @@ -28,6 +31,14 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
},
];

if (formData && formData.address) {
// Check if propertyLocation does not exist in address
if (!formData.address.hasOwnProperty("propertyLocation")) {
// Assign default value to propertyLocation
formData.address.propertyLocation = inputs[0];
}
}

const { pincode, city } = formData?.address || "";
const cities =
userType === "employee"
Expand All @@ -37,9 +48,13 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
: allCities;

const [selectedCity, setSelectedCity] = useState(
() => formData?.address?.city || Digit.SessionStorage.get("fsm.file.address.city") || Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY")
() =>
formData?.address?.city ||
Digit.SessionStorage.get("fsm.file.address.city") ||
Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY")
);
const [newLocality, setNewLocality] = useState();

const { data: fetchedLocalities } = Digit.Hooks.useBoundaryLocalities(
selectedCity?.code,
"revenue",
Expand All @@ -48,17 +63,18 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
},
t
);

const { data: urcConfig } = Digit.Hooks.fsm.useMDMS(tenantId, "FSM", "UrcConfig");
const isUrcEnable = urcConfig && urcConfig.length > 0 && urcConfig[0].URCEnable;
const [selectLocation, setSelectLocation] = useState(() =>
formData?.address?.propertyLocation
? formData?.address?.propertyLocation
: Digit.SessionStorage.get("locationType")
? Digit.SessionStorage.get("locationType")
: inputs[0]
);
const isUrcEnable =
urcConfig && urcConfig.length > 0 && urcConfig[0].URCEnable;

const [selectLocation, setSelectLocation] = useState(() =>
formData?.address?.propertyLocation
? formData?.address?.propertyLocation
: Digit.SessionStorage.get("locationType")
? Digit.SessionStorage.get("locationType")
: inputs[0]
);

const [localities, setLocalities] = useState();
const [selectedLocality, setSelectedLocality] = useState();

Expand All @@ -69,7 +85,7 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
}
}
}, [cities]);

useEffect(() => {
if (selectedCity && selectLocation) {
if (userType === "employee") {
Expand All @@ -80,7 +96,11 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
});
}
}
if ((!isUrcEnable || isNewVendor || isEditVendor) && selectedCity && fetchedLocalities) {
if (
(!isUrcEnable || isNewVendor || isEditVendor) &&
selectedCity &&
fetchedLocalities
) {
let __localityList = fetchedLocalities;
let filteredLocalityList = [];

Expand All @@ -89,18 +109,25 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
}

if (formData?.address?.pincode) {
filteredLocalityList = __localityList.filter((obj) => obj.pincode?.find((item) => item == formData.address.pincode));
filteredLocalityList = __localityList.filter((obj) =>
obj.pincode?.find((item) => item == formData.address.pincode)
);
if (!formData?.address?.locality) setSelectedLocality();
}

if (userType === "employee") {
onSelect(config.key, { ...formData[config.key], city: selectedCity });
}
setLocalities(() => (filteredLocalityList.length > 0 ? filteredLocalityList : __localityList));
setLocalities(() =>
filteredLocalityList.length > 0 ? filteredLocalityList : __localityList
);
if (filteredLocalityList.length === 1) {
setSelectedLocality(filteredLocalityList[0]);
if (userType === "employee") {
onSelect(config.key, { ...formData[config.key], locality: filteredLocalityList[0] });
onSelect(config.key, {
...formData[config.key],
locality: filteredLocalityList[0],
});
}
}
}
Expand Down Expand Up @@ -153,7 +180,9 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
function onSubmit() {
onSelect(config.key, {
city: selectedCity,
propertyLocation: Digit.SessionStorage.get("locationType") ? Digit.SessionStorage.get("locationType") : selectLocation,
propertyLocation: Digit.SessionStorage.get("locationType")
? Digit.SessionStorage.get("locationType")
: selectLocation,
});
}

Expand All @@ -170,7 +199,7 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
isMandatory
selected={cities?.length === 1 ? cities[0] : selectedCity}
disable={cities?.length === 1}
option={cities}
option={cities?.sort((a, b) => a.name.localeCompare(b.name))}
select={selectCity}
optionKey="code"
t={t}
Expand All @@ -180,27 +209,36 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
<div>
<LabelFieldPair>
<CardLabel className="card-label-smaller">
{t("ES_NEW_APPLICATION_LOCATION_MOHALLA")}
{config.isMandatory ? " * " : null}
{`${t("CS_CREATECOMPLAINT_MOHALLA")} *`}
{/* {config.isMandatory ? " * " : null} */}
</CardLabel>
<Dropdown
className="form-field"
isMandatory
selected={selectedLocality}
option={localities}
option={localities?.sort((a, b) =>
a.name.localeCompare(b.name)
)}
select={selectLocality}
optionKey="i18nkey"
t={t}
/>
</LabelFieldPair>
{!isNewVendor && !isEditVendor && !isUrcEnable && formData?.address?.locality?.name === "Other" && (
<LabelFieldPair>
<CardLabel className="card-label-smaller">{`${t("ES_INBOX_PLEASE_SPECIFY_LOCALITY")} *`}</CardLabel>
<div className="field">
<TextInput id="newLocality" key="newLocality" value={newLocality} onChange={(e) => onNewLocality(e.target.value)} />
</div>
</LabelFieldPair>
)}
<LabelFieldPair>
<CardLabel className="card-label-smaller">{`${t(
"ES_INBOX_PLEASE_SPECIFY_LOCALITY"
)} *`}</CardLabel>
<div className="field">
<TextInput
id="newLocality"
key="newLocality"
value={newLocality}
onChange={(e) => onNewLocality(e.target.value)}
/>
</div>
</LabelFieldPair>
)}
</div>
) : (
<LabelFieldPair>
Expand All @@ -226,20 +264,26 @@ const FSMSelectAddress = ({ t, config, onSelect, userType, formData }) => {
<Timeline currentStep={1} flow="APPLY" />
<FormStep config={config} onSelect={onSubmit} t={t} isDisabled={selectLocation ? false : true}>
{isUrcEnable && (
<React.Fragment>
<>
<CardLabel>{`${t("CS_PROPERTY_LOCATION")} *`}</CardLabel>
<RadioOrSelect
isMandatory={config.isMandatory}
options={inputs}
selectedOption={Digit.SessionStorage.get("locationType") ? Digit.SessionStorage.get("locationType") : selectLocation}
selectedOption={Digit.SessionStorage.get("locationType")? Digit.SessionStorage.get("locationType"): selectLocation}
optionKey="i18nKey"
onSelect={selectedValue}
t={t}
/>
</React.Fragment>
</>
)}
<CardLabel>{`${t("MYCITY_CODE_LABEL")} *`}</CardLabel>
<RadioOrSelect options={cities} selectedOption={selectedCity} optionKey="i18nKey" onSelect={selectCity} t={t} />
<RadioOrSelect
options={cities?.sort((a, b) => a.name.localeCompare(b.name))}
selectedOption={cities?.length === 1 ? cities[0] : selectedCity}
optionKey="i18nKey"
onSelect={selectCity}
t={t}
/>
</FormStep>
</React.Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ const ActionModal = ({ t, action, tenantId, state, id, closeModal, submitAction,
subtype: applicationData?.propertyUsage,
pitType: applicationData?.sanitationtype,
pitDetail: applicationData?.pitDetail,
propertyID: applicationData?.additionalDetails?.propertyID
propertyID: applicationData?.additionalDetails?.propertyID,
roadWidth: applicationData?.additionalDetails?.roadWidth,
distancefromroad: applicationData?.additionalDetails?.distancefromroad
});

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/micro-ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@egovernments/digit-ui-module-core": "1.7.24",
"@egovernments/digit-ui-module-engagement": "1.7.24",
"@egovernments/digit-ui-module-dss": "1.7.24",
"@egovernments/digit-ui-module-fsm": "1.7.26",
"@egovernments/digit-ui-module-fsm": "1.7.27",
"@egovernments/digit-ui-module-hrms": "1.7.24",
"@egovernments/digit-ui-module-mcollect": "1.7.24",
"@egovernments/digit-ui-module-commonpt":"1.7.24",
Expand Down

0 comments on commit bb527a2

Please sign in to comment.