diff --git a/src/cmn.js b/src/cmn.js new file mode 100644 index 0000000..d067c32 --- /dev/null +++ b/src/cmn.js @@ -0,0 +1,42 @@ +// Common module for shared constants/functions + +export const levelOfNeedOpts = [ + {"type": 1, "desc": "1 - No intervention necessary"}, + {"type": 2, "desc": "2 - Signpost to other resources"}, + {"type": 3, "desc": "3 - Information, advice and guidance (IAG)"}, + {"type": 4, "desc": "4 - Coaching and skills"}, + {"type": 5, "desc": "5 - Coaching engagement skills"}, + {"type": 6, "desc": "6 - Intensive support needed"}, + ] + +export const rightsStatusOpts = [ + {"type": 1, "desc": "1 - No intervention necessary"}, + {"type": 2, "desc": "2 - No recourse to public funds"}, + ] + +export const housingStatusOpts = [ + {"type": 1, "desc": "1 - No intervention necessary"}, + {"type": 2, "desc": "2 - At risk"}, + {"type": 3, "desc": "3 - Unsuitable temporary accommodation"}, + {"type": 4, "desc": "4 - Rough sleeping"}, + ] + +export const langProficiencyOpts = [ + {"type": 1, "desc": "1 - Good"}, + {"type": 2, "desc": "2 - Bad"}, + {"type": 3, "desc": "3 - Ugly"}, + ] + +export function capitalise(str) { + return str.charAt(0).toUpperCase() + str.slice(1); +} + +export function getLanguagesDisplay(languages) { + var languages_str = ""; + + Object.entries(languages).forEach((entry) => { + languages_str += capitalise(entry[0]) + " (" + entry[1] + "), "; + }) + + return languages_str.slice(0, -2); +} \ No newline at end of file diff --git a/src/components/Add.js b/src/components/Add.js index 5963aa3..50f73c2 100644 --- a/src/components/Add.js +++ b/src/components/Add.js @@ -4,42 +4,13 @@ import { confirmAlert } from 'react-confirm-alert'; import Loader from 'react-loader-spinner'; //import 'react-confirm-alert/src/react-confirm-alert.css'; -const levelOfNeedOpts = [ - {"type": 1, "desc": "1 - No intervention necessary"}, - {"type": 2, "desc": "2 - Signpost to other resources"}, - {"type": 3, "desc": "3 - Information, advice and guidance (IAG)"}, - {"type": 4, "desc": "4 - Coaching and skills"}, - {"type": 5, "desc": "5 - Coaching engagement skills"}, - {"type": 6, "desc": "6 - Intensive support needed"}, -] - -const rightsStatusOpts = [ - {"type": 1, "desc": "1 - No intervention necessary"}, - {"type": 2, "desc": "2 - No recourse to public funds"}, -] - -const housingStatusOpts = [ - {"type": 1, "desc": "1 - No intervention necessary"}, - {"type": 2, "desc": "2 - At risk"}, - {"type": 3, "desc": "3 - Unsuitable temporary accommodation"}, - {"type": 4, "desc": "4 - Rough sleeping"}, -] - -const langProficiencyOpts = [ - {"type": 1, "desc": "1 - Good"}, - {"type": 2, "desc": "2 - Bad"}, - {"type": 3, "desc": "3 - Ugly"}, -] +import * as cmn from "../cmn.js"; const displays = { FORM: "form", LOADING: "loading", } -function capitalise(str) { - return str.charAt(0).toUpperCase() + str.slice(1); -} - export default class Add extends React.Component { constructor(props) { super(props); @@ -120,7 +91,7 @@ function AddLoader(props) { ) } -class AddForm extends React.Component { +export class AddForm extends React.Component { constructor(props) { super(props); this.renderLanguageProficiencies = this.renderLanguageProficiencies.bind(this); @@ -163,7 +134,7 @@ class AddForm extends React.Component {