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

DUCE-10 :: added country code and validation for MOZ and ET #1246

Open
wants to merge 37 commits into
base: d1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a09bf63
added country code and validation for MOZ and ET
hridya-egov Aug 8, 2024
6169016
mobile number dropdown for citizen login working
hridya-egov Aug 8, 2024
f8c13ee
css alignment for mobile field fixed
hridya-egov Aug 8, 2024
3d267fb
Merge branch 'develop' of https://github.com/egovernments/DIGIT-Front…
hridya-egov Aug 8, 2024
805a6e1
location dropwdown fixed, otp and continue button on locationselectio…
hridya-egov Aug 13, 2024
dfe83a6
Merge branch 'develop' of https://github.com/egovernments/DIGIT-Front…
hridya-egov Aug 13, 2024
0f00245
continue button and upload file for the complaint detail screen fixed
hridya-egov Aug 13, 2024
6c3bd3c
to fix css issues,changed the import for components
hridya-egov Aug 19, 2024
50a873e
changed the action to apply
hridya-egov Aug 20, 2024
a00cef5
removed user object and added citizen object
hridya-egov Aug 20, 2024
269a0ee
fixed some css related
jagankumar-egov Aug 22, 2024
8493573
updated to latest css
jagankumar-egov Aug 22, 2024
a493ed7
dropdown for mobile number and pattern validation
hridya-egov Aug 22, 2024
9e0eb39
enabled core ui build (#1316)
jagankumar-egov Aug 22, 2024
103e68f
updated the pattern for country code and changed the pattern validati…
hridya-egov Aug 22, 2024
efd0acc
resolved conflct
hridya-egov Aug 22, 2024
fa88a4f
Merge pull request #1317 from egovernments/hrms
jagankumar-egov Aug 22, 2024
87e1d51
Merge branch 'develop' of https://github.com/egovernments/DIGIT-Front…
hridya-egov Aug 22, 2024
3adcd14
updated the changes
hridya-egov Aug 22, 2024
01cda32
Merge branch 'pgr_updates' of https://github.com/egovernments/DIGIT-F…
hridya-egov Aug 22, 2024
ac9cd07
clean up module compilation
jagankumar-egov Aug 22, 2024
81bc5d2
added dashboard card
jagankumar-egov Aug 22, 2024
f62bf72
"@egovernments/digit-ui-module-utilities":"1.0.1-beta.39",
jagankumar-egov Aug 22, 2024
087e561
fix on utilities
jagankumar-egov Aug 22, 2024
bf54d6c
build fix
jagankumar-egov Aug 23, 2024
a13b44b
updated css versions
jagankumar-egov Aug 23, 2024
210eb0e
added new icons (#1323)
Swathi-eGov Aug 23, 2024
96c798f
SN itegration with tenant in URL (#1322)
nabeelmd-eGov Aug 23, 2024
9a0be96
Merge branch 'develop' of https://github.com/egovernments/DIGIT-Front…
hridya-egov Aug 23, 2024
7e0c537
reverted back the usertype changes and enabled submit button
hridya-egov Aug 23, 2024
ff57cd0
reverted back the usertype changes and enabled submit button
hridya-egov Aug 23, 2024
1a03164
mobile code dropdown for hrms inbox
hridya-egov Aug 23, 2024
a4a03ba
updates in countrycode validation
hridya-egov Aug 23, 2024
7a17f04
hrms changes updated
jagankumar-egov Aug 26, 2024
f66b9be
updated some package versions
jagankumar-egov Aug 26, 2024
a0f315c
updated the pattern for et
hridya-egov Aug 26, 2024
b36dbe3
reverted the core ui changes
jagankumar-egov Aug 26, 2024
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 @@ -14,11 +14,13 @@ export const Complaint = {
uploadedImages,
mobileNumber,
name,
user,
}) => {
const tenantId = Digit.ULBService.getCurrentTenantId();
const defaultData = {
service: {
tenantId: cityCode,
active :true,
serviceCode: complaintType,
description: description,
additionalDetail: {},
Expand All @@ -36,15 +38,18 @@ export const Complaint = {
},
geoLocation: {},
},
user: user,
},
workflow: {
action: "APPLY",
verificationDocuments: uploadedImages,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this we shouldnt comment @hridya-egov

// action: "APPLY",
// verificationDocuments: uploadedImages,
action: "CREATE", assignes: [], hrmsAssignes: [], comments: ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

check here

},
};


if (Digit.SessionStorage.get("user_type") === "employee") {
defaultData.service.citizen = {
defaultData.service.user = {
name: name,
type: "CITIZEN",
mobileNumber: mobileNumber,
Expand All @@ -59,6 +64,7 @@ export const Complaint = {
tenantId: tenantId,
};
}

const response = await Digit.PGRService.create(defaultData, cityCode);
return response;
},
Expand All @@ -79,8 +85,7 @@ export const Complaint = {
: null;

if (!uploadedDocument) complaintDetails.workflow.verificationDocuments = [];

//TODO: get tenant id

const response = await Digit.PGRService.update(complaintDetails, tenantId);
return response;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const PGRConstants = {
INDIA: {
countryCode: '+91',
regex: /^[6-9]\d{9}$/,
},
MOZ: {
countryCode: '+258',
regex: /^[0-9]\d{8}$/,
},
ET: {
countryCode: '+251',
regex: /^[0-9]\d{9}$/,
},


};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useQueryClient } from "react-query";

import { FormComposer } from "../../../components/FormComposer";
import { createComplaint } from "../../../redux/actions/index";

import { PGRConstants } from "../../../constants/PGRConstants";
export const CreateComplaint = ({ parentUrl }) => {
const cities = Digit.Hooks.pgr.useTenants();
const { t } = useTranslation();
Expand All @@ -31,7 +31,7 @@ export const CreateComplaint = ({ parentUrl }) => {

const [localities, setLocalities] = useState(fetchedLocalities);
const [selectedLocality, setSelectedLocality] = useState(null);
const [canSubmit, setSubmitValve] = useState(false);
//const [canSubmit, setSubmitValve] = useState(false);
const [submitted, setSubmitted] = useState(false);

const [pincodeNotValid, setPincodeNotValid] = useState(false);
Expand All @@ -43,14 +43,26 @@ export const CreateComplaint = ({ parentUrl }) => {
const history = useHistory();
const serviceDefinitions = Digit.GetServiceDefinitions;
const client = useQueryClient();
const [selectedCountryCode, setSelectedCountryCode] = useState(PGRConstants.INDIA_COUNTRY_CODE);
const countryOptions = Object.values(PGRConstants).map(({ countryCode }, index) => (
<option key={index} value={countryCode}>
{countryCode}
</option>
));

useEffect(() => {
if (complaintType?.key && subType?.key && selectedCity?.code && selectedLocality?.code) {
setSubmitValve(true);
} else {
setSubmitValve(false);
const getPhonePattern=(selectedCountryCode) =>{
return Object.values(PGRConstants).filter(e=>e.countryCode==selectedCountryCode)?.[0]?.regex;

}
}, [complaintType, subType, selectedCity, selectedLocality]);


// useEffect(() => {
// if (complaintType?.key && subType?.key && selectedCity?.code && selectedLocality?.code) {
// setSubmitValve(true);
// } else {
// setSubmitValve(false);
// }
// }, [complaintType, subType, selectedCity, selectedLocality]);

useEffect(() => {
setLocalities(fetchedLocalities);
Expand Down Expand Up @@ -102,14 +114,54 @@ export const CreateComplaint = ({ parentUrl }) => {
}

const wrapperSubmit = (data) => {
if (!canSubmit) return;
// if (!canSubmit) return;
setSubmitted(true);
!submitted && onSubmit(data);
//!submitted &&
onSubmit(data);
};

//On SUbmit
// const onSubmit = async (data) =>
// {
// // if (!canSubmit) return;
// const cityCode = selectedCity.code;
// const city = selectedCity.city.name;
// const district = selectedCity.city.name;
// const region = selectedCity.city.name;
// const localityCode = selectedLocality.code;
// const localityName = selectedLocality.name;
// const landmark = data.landmark;
// const { key } = subType;
// const complaintType = key;
// const mobileNumber = data.mobileNumber;
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove these commented lines

// const name = data.name;

// const formData = { ...data, cityCode, city, district, region,user, localityCode, localityName, landmark, complaintType, mobileNumber, name };
// await dispatch(createComplaint(formData));
// await client.refetchQueries(["fetchInboxData"]);
// history.push(parentUrl + "/response");
// const user =
// {
// userName: "9846966111", // or use actual data from your context or state
// name: "jdjjdk", // or use actual data from your context or state
// type: "EMPLOYEE",
// mobileNumber: "9846966111",
// roles: [], // or use actual roles if applicable
// tenantId: "mz", // or use actual tenantId from context or state
// uuid: "c9623295-7921-47ca-9994-aa19f47276ee", // or use actual UUID from context or state
// active: true,
// isDeleted: false,
// rowVersion: 1,
// auditDetails: {
// createdBy: "c9623295-7921-47ca-9994-aa19f47276ee",
// createdTime: Date.now(),
// lastModifiedBy: "c9623295-7921-47ca-9994-aa19f47276ee",
// lastModifiedTime: Date.now()
// }
// };
// }
const onSubmit = async (data) => {
if (!canSubmit) return;
//if (!canSubmit) return;
const cityCode = selectedCity.code;
const city = selectedCity.city.name;
const district = selectedCity.city.name;
Expand All @@ -121,12 +173,30 @@ export const CreateComplaint = ({ parentUrl }) => {
const complaintType = key;
const mobileNumber = data.mobileNumber;
const name = data.name;
const formData = { ...data, cityCode, city, district, region, localityCode, localityName, landmark, complaintType, mobileNumber, name };
const user = {
userName: "9846966111",
name: "jdjjdk",
type: "EMPLOYEE",
mobileNumber: "9846966111",
roles: [],
tenantId: "mz",
Copy link
Collaborator

Choose a reason for hiding this comment

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

these information shouldnot be hardcoded

uuid: "c9623295-7921-47ca-9994-aa19f47276ee",
active: true,
isDeleted: false,
rowVersion: 1,
auditDetails: {
createdBy: "c9623295-7921-47ca-9994-aa19f47276ee",
createdTime: Date.now(),
lastModifiedBy: "c9623295-7921-47ca-9994-aa19f47276ee",
lastModifiedTime: Date.now()
}
};
const formData = { ...data, cityCode, city, district, region, localityCode, localityName, landmark, complaintType, mobileNumber, name,user };
await dispatch(createComplaint(formData));
await client.refetchQueries(["fetchInboxData"]);
history.push(parentUrl + "/response");
};

const handlePincode = (event) => {
const { value } = event.target;
setPincode(value);
Expand All @@ -135,7 +205,7 @@ export const CreateComplaint = ({ parentUrl }) => {
}
};

const isPincodeValid = () => !pincodeNotValid;
//const isPincodeValid = () => pincodeNotValid;

const config = [
{
Expand All @@ -149,11 +219,18 @@ export const CreateComplaint = ({ parentUrl }) => {
name: "mobileNumber",
validation: {
required: true,
pattern: /^[6-9]\d{9}$/,
pattern: getPhonePattern(selectedCountryCode),

},
componentInFront: <div className="employee-card-input employee-card-input--front">+91</div>,
componentInFront: <div className="employee-card-input employee-card-input--front">
<select value={selectedCountryCode} onChange={(e) => setSelectedCountryCode(e.target.value)}>
{countryOptions}
</select>
</div>,
error: t("CORE_COMMON_MOBILE_ERROR"),

},

},
{
label: t("ES_CREATECOMPLAINT_COMPLAINT_NAME"),
Expand Down Expand Up @@ -196,7 +273,7 @@ export const CreateComplaint = ({ parentUrl }) => {
type: "text",
populators: {
name: "pincode",
validation: { pattern: /^[1-9][0-9]{5}$/, validate: isPincodeValid },
//validation: { pattern: /^[1-9][0-9]{5}$/, validate: isPincodeValid },
error: t("CORE_COMMON_PINCODE_INVALID"),
onChange: handlePincode,
},
Expand Down Expand Up @@ -224,7 +301,7 @@ export const CreateComplaint = ({ parentUrl }) => {
isMandatory: true,
dependency: selectedCity && localities ? true : false,
populators: (
<Dropdown isMandatory selected={selectedLocality} optionKey="i18nkey" id="locality" option={localities} select={selectLocality} t={t} />
<Dropdown selected={selectedLocality} optionKey="i18nkey" id="locality" option={[{i18nkey:"i18nkey",name:"gggg",code:"code"}]} select={selectLocality} t={t} />
),
},
{
Expand Down Expand Up @@ -254,7 +331,7 @@ export const CreateComplaint = ({ parentUrl }) => {
heading={t("ES_CREATECOMPLAINT_NEW_COMPLAINT")}
config={config}
onSubmit={wrapperSubmit}
isDisabled={!canSubmit && !submitted}
isDisabled={false}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why this change ?'

label={t("CS_ADDCOMPLAINT_ADDITIONAL_DETAILS_SUBMIT_COMPLAINT")}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ const createComplaint = ({
uploadedImages,
mobileNumber,
name,
user
}) => async (dispatch, getState) => {
//func
const response = await Digit.Complaint.create({
cityCode,
user,
complaintType,
description,
landmark,
Expand All @@ -31,6 +34,7 @@ const createComplaint = ({
uploadedImages,
mobileNumber,
name,

});
dispatch({
type: CREATE_COMPLAINT,
Expand Down