Skip to content

Commit

Permalink
partially completed following issues LSFLK#175 LSFLK#254 LSFLK#253 LS…
Browse files Browse the repository at this point in the history
  • Loading branch information
YujithIsura committed May 28, 2020
1 parent 60d3420 commit fcc6628
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 90 deletions.
78 changes: 21 additions & 57 deletions frontend/src/guest-view/components/GuestIncidentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,7 @@ const VerticalLinearStepper = (props) => {
let errorMsg = { ...formErrors };
let valid = true;

if (!incidentContact.mobile) {
errorMsg = {
...errorMsg,
incidentContactErrorMsg: f({
id: "request.management.report.incidents.phone.error.message",
defaultMessage: "Contact number is required",
}),
};
valid = false;
}else{
if (incidentContact.mobile) {
if(!(incidentContact.mobile.match("^[0-9]{10}$"))){
errorMsg = {
...errorMsg,
Expand Down Expand Up @@ -401,16 +392,7 @@ const VerticalLinearStepper = (props) => {
};
valid = false;
}
if (!incidentContact.nic) {
errorMsg = {
...errorMsg,
incidentNicErrorMsg: f({
id: "request.management.report.incidents.nic.error.message",
defaultMessage: "NIC Number is required",
}),
};
valid = false;
}else{
if (incidentContact.nic) {
if(!(incidentContact.nic.match("^([0-9]{9}[x|X|v|V]|[0-9]{12})$"))){
errorMsg = {
...errorMsg,
Expand Down Expand Up @@ -463,16 +445,7 @@ const VerticalLinearStepper = (props) => {
valid = false;
}
if (showRecipient === "YES") {
if (!incidentContact.recipientMobile) {
errorMsg = {
...errorMsg,
recipientContactErrorMsg: f({
id: "request.management.report.incidents.phone.error.message",
defaultMessage: "Contact number is required",
}),
};
valid = false;
}else{
if (incidentContact.recipientMobile) {
if(!(incidentContact.recipientMobile.match("^[0-9]{10}$"))){
errorMsg = {
...errorMsg,
Expand Down Expand Up @@ -521,16 +494,7 @@ const VerticalLinearStepper = (props) => {
};
valid = false;
}
if (!incidentContact.recipientNic) {
errorMsg = {
...errorMsg,
recipientNicErrorMsg: f({
id: "request.management.report.incidents.nic.error.message",
defaultMessage: "NIC Number is required",
}),
};
valid = false;
}else{
if (incidentContact.recipientNic) {
if(!(incidentContact.recipientNic.match("^([0-9]{9}[x|X|v|V]|[0-9]{12})$"))){
errorMsg = {
...errorMsg,
Expand Down Expand Up @@ -604,16 +568,16 @@ const VerticalLinearStepper = (props) => {
};
valid = false;
}
if (!language) {
errorMsg = {
...errorMsg,
languageErrorMsg: f({
id: "request.management.report.incidents.recipient.error.message",
defaultMessage: "This is required",
}),
};
valid = false;
}
// if (!language) {
// errorMsg = {
// ...errorMsg,
// languageErrorMsg: f({
// id: "request.management.report.incidents.recipient.error.message",
// defaultMessage: "This is required",
// }),
// };
// valid = false;
// }

setFormErrors({ ...errorMsg });
return valid;
Expand Down Expand Up @@ -1168,24 +1132,27 @@ const VerticalLinearStepper = (props) => {
<div style={{ textAlign: "right" }}>
<Button
variant="outlined"
style={{width:'88px'}}
color="primary"
onClick={() => dispatch(changeLanguage("si"))}
className={classes.button}
>
{" "}
Sinhala{" "}
සිංහල{" "}
</Button>
<Button
variant="outlined"
style={{width:'88px'}}
color="primary"
onClick={() => dispatch(changeLanguage("ta"))}
className={classes.button}
>
{" "}
Tamil{" "}
தமிழ்{" "}
</Button>
<Button
variant="outlined"
style={{width:'88px'}}
color="primary"
onClick={() => dispatch(changeLanguage("en"))}
className={classes.button}
Expand Down Expand Up @@ -1222,18 +1189,15 @@ const VerticalLinearStepper = (props) => {
</Typography></li>
</ul>
</div>
<Grid item xs={12}>
{/* <Grid item xs={12}>
<FormControl className={classes.group} error={formErrors.languageErrorMsg ? true : false} component="fieldset">
<FormLabel component="legend">{f({ id: "request.management.incident.create.location.language", defaultMessage: "Select Language*" })}</FormLabel>
<RadioGroup
aria-label="Gender"
name="language"
id="language"
// ref= {this.props.securityDepositeRpp}
// className={classes.group}
value={language}
onChange={(e) => { setLanguage(e.target.value);formErrors.languageErrorMsg = null;dispatch(changeLanguage(e.target.value=="SINHALA" ? "si" : e.target.value=="TAMIL" ? "ta" : "en")); }}
// onClick={(e) => { }}
row
>
<FormControlLabel
Expand All @@ -1260,7 +1224,7 @@ const VerticalLinearStepper = (props) => {
</RadioGroup>
<FormHelperText>{formErrors.languageErrorMsg ? formErrors.languageErrorMsg : null}</FormHelperText>
</FormControl>
</Grid>
</Grid> */}
<Stepper activeStep={activeStep} orientation="vertical">
{steps.map((label, index) => {
const props = {};
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/guest-view/components/LandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function HomePage(props) {
<div style={{ textAlign: "right" }}>
<Button
variant="outlined"
style={{width:'88px'}}
color="primary"
onClick={() => dispatch(changeLanguage("si"))}
className={classes.button}
Expand All @@ -158,6 +159,7 @@ function HomePage(props) {
</Button>
<Button
variant="outlined"
style={{width:'88px'}}
color="primary"
onClick={() => dispatch(changeLanguage("ta"))}
className={classes.button}
Expand All @@ -167,6 +169,7 @@ function HomePage(props) {
</Button>
<Button
variant="outlined"
style={{width:'88px'}}
color="primary"
onClick={() => dispatch(changeLanguage("en"))}
className={classes.button}
Expand Down
39 changes: 15 additions & 24 deletions frontend/src/incident-filing/components/IncidentFormInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,14 @@ function IncidentFormInternal(props) {
),
incidentType: Yup.mixed().required("Required"),
infoChannel: Yup.mixed().required(f({ id: "request.management.incident.error.channel", defaultMessage: "Mode of receipt is Required" })),
language: Yup.string().required(f({ id: "request.management.incident.error.language", defaultMessage: "Language is Required" })),
// language: Yup.string().required(f({ id: "request.management.incident.error.language", defaultMessage: "Language is Required" })),
reporterName: Yup.string().required(f({ id: "request.management.incident.error.name", defaultMessage: "Name is Required" })),

reporterNic: Yup
.string()
.trim()
.matches(/^([0-9]{9}[x|X|v|V]|[0-9]{12})$/ , f({ id: "request.management.report.incidents.invalidNic.error.message", defaultMessage: "NIC Number is Required" }))
.required(f({ id: "request.management.report.incidents.nic.error.message", defaultMessage: "NIC Number is Required" })),
.matches(/^([0-9]{9}[x|X|v|V]|[0-9]{12})$/ , f({ id: "request.management.report.incidents.invalidNic.error.message", defaultMessage: "NIC Number is Required" })),
// .required(f({ id: "request.management.report.incidents.nic.error.message", defaultMessage: "NIC Number is Required" })),

reporterTitle: Yup.string().required(f({ id: "request.management.incident.error.title", defaultMessage: "Title is Required" })),
reporterAddress: Yup.string().required(f({ id: "request.management.incident.error.address", defaultMessage: "Address is Required" })),
Expand All @@ -595,8 +595,8 @@ function IncidentFormInternal(props) {
reporterMobile: Yup
.string()
.trim()
.matches(/^(?:0|94|\+94)?(?:(11|21|23|24|25|26|27|31|32|33|34|35|36|37|38|41|45|47|51|52|54|55|57|63|65|66|67|81|912)(0|2|3|4|5|7|9)|7(0|1|2|5|6|7|8)\d)\d{6}$/ , f({ id: "request.management.incident.error.invalidMobile", defaultMessage: "This is not a valid phone number" }))
.required(f({ id: "request.management.incident.error.mobile", defaultMessage: "Mobile is Required" })),
.matches(/^(?:0|94|\+94)?(?:(11|21|23|24|25|26|27|31|32|33|34|35|36|37|38|41|45|47|51|52|54|55|57|63|65|66|67|81|912)(0|2|3|4|5|7|9)|7(0|1|2|5|6|7|8)\d)\d{6}$/ , f({ id: "request.management.incident.error.invalidMobile", defaultMessage: "This is not a valid phone number" })),
// .required(f({ id: "request.management.incident.error.mobile", defaultMessage: "Mobile is Required" })),

reporterTelephone: Yup
.string()
Expand Down Expand Up @@ -636,7 +636,8 @@ function IncidentFormInternal(props) {
.trim()
.when("showRecipient", (showRecipient, IncidentSchema) =>
showRecipient == "YES"
? IncidentSchema.required(f({ id: "request.management.report.incidents.nic.error.message", defaultMessage: "NIC Number is Required" }))
? IncidentSchema
// required(f({ id: "request.management.report.incidents.nic.error.message", defaultMessage: "NIC Number is Required" }))
.matches(/^([0-9]{9}[x|X|v|V]|[0-9]{12})$/ , f({ id: "request.management.report.incidents.invalidNic.error.message", defaultMessage: "NIC Number is Required" }))
: IncidentSchema
),
Expand Down Expand Up @@ -666,7 +667,8 @@ function IncidentFormInternal(props) {
.trim()
.when("showRecipient", (showRecipient, IncidentSchema) =>
showRecipient == "YES"
? IncidentSchema.required(f({ id: "request.management.incident.error.mobile", defaultMessage: "Mobile is Required" }))
? IncidentSchema
// .required(f({ id: "request.management.incident.error.mobile", defaultMessage: "Mobile is Required" }))
.matches(/^(?:0|94|\+94)?(?:(11|21|23|24|25|26|27|31|32|33|34|35|36|37|38|41|45|47|51|52|54|55|57|63|65|66|67|81|912)(0|2|3|4|5|7|9)|7(0|1|2|5|6|7|8)\d)\d{6}$/ , f({ id: "request.management.incident.error.invalidMobile", defaultMessage: "This is not a valid phone number" }))
: IncidentSchema
),
Expand Down Expand Up @@ -775,18 +777,15 @@ function IncidentFormInternal(props) {
</ul>
</div>
<br/>
<Grid item xs={12}>
{/* <Grid item xs={12}>
<FormControl className={classes.group} error={touched.language && errors.language} component="fieldset">
<FormLabel component="legend">{f({ id: "request.management.incident.create.location.language", defaultMessage: "Select Language*" })}</FormLabel>
<RadioGroup
aria-label="Gender"
name="language"
id="language"
// ref= {this.props.securityDepositeRpp}
// className={classes.group}
value={values.language}
onChange={handleChange}
// onChange={(e) => { setLanguage(e.target.value);formErrors.languageErrorMsg = null;dispatch(changeLanguage(e.target.value=="SINHALA" ? "si" : e.target.value=="TAMIL" ? "ta" : "en")); }}
onClick={(e) => {dispatch(changeLanguage(e.target.value=="SINHALA" ? "si" : e.target.value=="TAMIL" ? "ta" : "en"))}}
row
>
Expand Down Expand Up @@ -814,7 +813,7 @@ function IncidentFormInternal(props) {
</RadioGroup>
<FormHelperText>{touched.language && errors.language ? errors.language : ""}</FormHelperText>
</FormControl>
</Grid>
</Grid> */}
<Typography variant="h5" gutterBottom>
{f({ id: "request.management.incident.create.basic_information" })}
</Typography>
Expand Down Expand Up @@ -932,6 +931,8 @@ function IncidentFormInternal(props) {
props.match.params.paramIncidentId ? true : false
}
multiline
rows={4}
inputProps={{ maxLength: 3000 }}
value={values.description}
variant="outlined"
onChange={handleChange}
Expand Down Expand Up @@ -1065,24 +1066,14 @@ function IncidentFormInternal(props) {
) : null}
</FormControl>
</Grid> */}
<Grid item xs={12} sm={3}>
{/* <Grid item xs={12} sm={3}>
<TextField
id="occured_date_date"
label={f({ id: "request.management.incident.create.date", defaultMessage: "Request Date" })}
type="date"
value={values.occured_date_date}
InputLabelProps={{ shrink: true }}
onChange={handleChange}
// inputProps={{
// max:
// values.occurrence === "OCCURRED"
// ? moment().format("YYYY-MM-DD")
// : null,
// min:
// values.occurrence === "WILL_OCCUR"
// ? moment().format("YYYY-MM-DD")
// : null
// }}
error={errors.occured_date_date}
helperText={errors.occured_date_date}
/>
Expand All @@ -1096,7 +1087,7 @@ function IncidentFormInternal(props) {
error={errors.occured_date_time}
helperText={errors.occured_date_time}
/>
</Grid>
</Grid> */}
</>
) : null}
{values.incidentType === "COMPLAINT" ? (
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/translation/keys/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
"request.management.report.incidents.section.contact": "Your contact details",
"request.management.report.incidents.section.category": "Select the most suitable category",
"request.management.report.incidents.contact.name": "Name*",
"request.management.report.incidents.contact.nic": "NIC/SLIN Number*",
"request.management.report.incidents.contact.mobile": "Primary Contact / Mobile number*",
"request.management.report.incidents.contact.nic": "NIC/SLIN Number",
"request.management.report.incidents.contact.mobile": "Primary Contact / Mobile number",
"request.management.report.incidents.contact.telephone": "Secondary Contact / Landline",
"request.management.report.incidents.contact.email": "Email",

Expand Down Expand Up @@ -128,7 +128,7 @@
"request.management.incident.create.reporter.name": "Reporter Name*",
"request.management.incident.create.reporter.type": "Individual/Organization*",
"request.management.incident.create.reporter.address": "Address*",
"request.management.incident.create.reporter.mobile": "Mobile*",
"request.management.incident.create.reporter.mobile": "Mobile",
"request.management.incident.create.reporter.telephone": "Landline",
"request.management.incident.create.reporter.email": "Email",
"request.management.incident.create.reporter.onbehalf": "On behalf of someone else",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/translation/keys/si.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
"request.management.report.incidents.section.contact": "ඔබව සම්බන්ධ කරගත හැකි තොරතුරු",
"request.management.report.incidents.section.category": "වඩාත් සුදුසු කාණ්ඩය තෝරන්න",
"request.management.report.incidents.contact.name": "නම*",
"request.management.report.incidents.contact.nic": "ජාතික හැඳුනුම්පත් අංකය*",
"request.management.report.incidents.contact.mobile": "ජංගම දුරකථන අංකය*",
"request.management.report.incidents.contact.nic": "ජාතික හැඳුනුම්පත් අංකය",
"request.management.report.incidents.contact.mobile": "ජංගම දුරකථන අංකය",
"request.management.report.incidents.contact.telephone": "ස්ථාවර දුරකථන අංකය",
"request.management.report.incidents.contact.landline": "ස්ථාවර දුරකථන අංකය",
"request.management.report.incidents.contact.email": "විද්‍යුත් ලිපිනය ( ඊ-මේල් )",
Expand Down Expand Up @@ -129,7 +129,7 @@
"request.management.incident.create.reporter.name": "වාර්තාකරුගේ නම*",
"request.management.incident.create.reporter.type": "තනි පුද්ගල / සංවිධානය*",
"request.management.incident.create.reporter.address": "ලිපිනය*",
"request.management.incident.create.reporter.mobile": "ජංගම දුරකථනය අංකය*",
"request.management.incident.create.reporter.mobile": "ජංගම දුරකථනය අංකය",
"request.management.incident.create.reporter.telephone": "ස්ථාවර දුරකථනය අංකය",
"request.management.incident.create.reporter.email": "විද්‍යුත් ලිපිනය ( ඊ-මේල් )",
"request.management.incident.create.reporter.onbehalf": "වෙනත් කෙනෙකු වෙනුවෙන්",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/translation/keys/ta.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"request.management.report.incidents.section.contact": "உங்களின் தொடர்பு விபரங்கள்",
"request.management.report.incidents.section.category": "மிகவும் பொருத்தமான வகையைத் தேர்ந்தெடுக்கவும்",
"request.management.report.incidents.contact.name": "பெயர்*",
"request.management.report.incidents.contact.nic": "தேசிய அடையாள அட்டை எண்*",
"request.management.report.incidents.contact.mobile": "கைபேசி*",
"request.management.report.incidents.contact.nic": "தேசிய அடையாள அட்டை எண்",
"request.management.report.incidents.contact.mobile": "கைபேசி",
"request.management.report.incidents.contact.telephone": "நிலையான தொலைபேசி",
"request.management.report.incidents.contact.landline": "நிலையான தொலைபேசி",
"request.management.report.incidents.contact.email": "மின்னஞ்சல்",
Expand Down Expand Up @@ -119,7 +119,7 @@
"request.management.incident.create.reporter.name": "நிருபர் பெயர்*",
"request.management.incident.create.reporter.type": "தனிநபர் / அமைப்பு*",
"request.management.incident.create.reporter.address": "முகவரி*",
"request.management.incident.create.reporter.mobile": "கைபேசி*",
"request.management.incident.create.reporter.mobile": "கைபேசி",
"request.management.incident.create.reporter.email": "மின்னஞ்சல்",
"request.management.incident.create.reporter.telephone": "நிலையான தொலைபேசி",
"request.management.incident.create.reporter.onbehalf": "வேறொருவரின் சார்பாக",
Expand Down

0 comments on commit fcc6628

Please sign in to comment.