Skip to content

Commit

Permalink
Merge pull request #574 from ECLK/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
MrClemRkz authored Jul 29, 2020
2 parents b6fb479 + 0270c4c commit 907babb
Show file tree
Hide file tree
Showing 8 changed files with 1,040 additions and 366 deletions.
288 changes: 288 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@material-ui/core": "^3.9.2",
"@material-ui/icons": "^3.0.2",
"@material-ui/lab": "^3.0.0-alpha.30",
"@material-ui/styles": "^4.10.0",
"axios": "^0.18.1",
"blueimp-md5": "^2.12.0",
"draft-js": "^0.11.1",
Expand Down
37 changes: 34 additions & 3 deletions frontend/src/incident-filing/components/IncidentFormInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { withStyles } from "@material-ui/core/styles";
import yellow from "@material-ui/core/colors/yellow";
import TitleAutoComplete from "./TitleAutoComplete";
import CircularProgress from '@material-ui/core/CircularProgress';
import CustomAutocompleteCategory from "../../ongoing-incidents/components/AutocompleteCategory"

const styles = (theme) => ({
root: {
Expand All @@ -81,6 +82,10 @@ const styles = (theme) => ({
formControl: {
width: "100%"
},
formControl2: {
width: "100%",
marginTop: 11
},
datetime: {
marginLeft: theme.spacing.unit,
marginRight: theme.spacing.unit,
Expand Down Expand Up @@ -143,6 +148,8 @@ function IncidentFormInternal(props) {
const dispatch = useDispatch();
const [similarIncidents, setSimilarIncidents] = useState([]);
const [selectedInstitution, setSelectedInstitution] = useState("");
const { selectedLanguage } = useSelector((state) => (state.shared));

const {
incident,
reporter,
Expand Down Expand Up @@ -477,6 +484,21 @@ function IncidentFormInternal(props) {
receivedDate: Yup.mixed().when('incidentType', (incidentType, IncidentSchema) => (incidentType == 'INQUIRY' ? IncidentSchema.required("Required") : IncidentSchema)),
letterDate: Yup.mixed().when('incidentType', (incidentType, IncidentSchema) => (incidentType == 'INQUIRY' ? IncidentSchema.required("Required") : IncidentSchema)),
});
var suggestionsComplaint = [];
var suggestionsInquiry = [];

selectedLanguage=="en" ?
suggestionsComplaint = complaintCategories ? complaintCategories.map((o) => ( {label: o.sub_category, value: o.id }) ) : [] :
selectedLanguage=="si" ?
suggestionsComplaint = complaintCategories ? complaintCategories.map((o) => ( {label: o.sn_sub_category, value: o.id }) ) : [] :
suggestionsComplaint = complaintCategories ? complaintCategories.map((o) => ( {label: o.tm_sub_category, value: o.id }) ) : []

selectedLanguage=="en" ?
suggestionsInquiry = inquiryCategories ? inquiryCategories.map((o) => ( {label: o.sub_category, value: o.id }) ) : [] :
selectedLanguage=="si" ?
suggestionsInquiry = inquiryCategories ? inquiryCategories.map((o) => ( {label: o.sn_sub_category, value: o.id }) ) : [] :
suggestionsInquiry = inquiryCategories ? inquiryCategories.map((o) => ( {label: o.tm_sub_category, value: o.id }) ) : []


return (
<div className={classes.root}>
Expand Down Expand Up @@ -651,9 +673,18 @@ function IncidentFormInternal(props) {
</Grid>
<Grid item xs={12} sm={6}>
<FormControl
className={classes.formControl}
className={classes.formControl2}
error={touched.category && errors.category}>
<InputLabel htmlFor="category">Category*</InputLabel>
<CustomAutocompleteCategory
suggestions={values.incidentType === "COMPLAINT" && suggestionsComplaint ? suggestionsComplaint : values.incidentType === "INQUIRY" && suggestionsInquiry ? suggestionsInquiry : []}
selectedLanguage={selectedLanguage}
value={values.category}
handleChange={(event) => handleChange(event)}
error={(errors.category) == 'Category is Required' ? true : false}
categories={values.incidentType === "COMPLAINT" && complaintCategories ? complaintCategories : values.incidentType === "INQUIRY" && inquiryCategories ? inquiryCategories : []}
categoryLable={"Search category by name*"} />

{/* <InputLabel htmlFor="category">Category*</InputLabel>
<Select
value={values.category}
onChange={handleChange}
Expand Down Expand Up @@ -691,7 +722,7 @@ function IncidentFormInternal(props) {
</MenuItem>
))
}
</Select>
</Select> */}
<FormHelperText>
{touched.category && errors.category ? errors.category : ""}
</FormHelperText>
Expand Down
Loading

0 comments on commit 907babb

Please sign in to comment.