Skip to content

Commit

Permalink
Merge pull request #10 from Saudigitus/EMIS-CONFIG-15
Browse files Browse the repository at this point in the history
Emis config 15
  • Loading branch information
EdsonNhancale authored Sep 20, 2024
2 parents df95cd1 + 251c0d1 commit 118302b
Show file tree
Hide file tree
Showing 57 changed files with 2,755 additions and 308 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_DATA_STORE_NAME="semis"
REACT_APP_DATA_STORE_APP_NAME="apps"
REACT_APP_DATA_STORE_SEMIS_CONFIG_KEY="config"
REACT_APP_DATA_STORE_SEMIS_VALUES_KEY="values"
REACT_APP_DATA_STORE_NAME="ibrahim"
REACT_APP_DATA_STORE_APP_NAME="ibrahimapps"
REACT_APP_DATA_STORE_SEMIS_CONFIG_KEY="ibrahimconfig"
REACT_APP_DATA_STORE_SEMIS_VALUES_KEY="ibrahimvalues"
9 changes: 8 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/object-curly-spacing": "off",
"@typescript-eslint/semi": "off"
"@typescript-eslint/semi": "off",
"@typescript-eslint/strict-boolean-expressions":"off",
"@typescript-eslint/comma-dangle": "off",
"@typescript-eslint/restrict-template-expressions":"off",
"@typescript-eslint/no-floating-promises":"off",
"@typescript-eslint/no-confusing-void-expression":"off",
"@typescript-eslint/no-misused-promises":"off",
"@typescript-eslint/prefer-nullish-coalescing":"off"
}
}
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 4,
"bracketSpacing": true,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 120
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-dnd": "14.0.3",
"react-dnd-html5-backend": "14.0.1",
"react-final-form": "^6.5.9",
"react-form-stepper": "^2.0.3",
"react-icons": "^4.12.0",
"react-router-dom": "^6.14.1",
"react-select": "1.3.0",
Expand Down
130 changes: 71 additions & 59 deletions src/components/genericFields/fields/SingleSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,71 +1,83 @@
import { TextField } from "@material-ui/core";
import { Autocomplete } from "@material-ui/lab";
import React from "react";
import { useField, type FieldRenderProps } from "react-final-form";
import { type CustomAttributeProps } from "../../../types/table/AttributeColumns";
import { TextField } from '@material-ui/core'
import { Autocomplete } from '@material-ui/lab'
import React from 'react'
import { useField, type FieldRenderProps } from 'react-final-form'
import { type CustomAttributeProps } from '../../../types/table/AttributeColumns'

interface AutoCompleteProps {
disabled?: boolean
options?: CustomAttributeProps["options"]
name: string
label?: string
multiple?: boolean
onChange?: any
disabled?: boolean
options?: CustomAttributeProps['options']
name: string
label?: string
defaultValue?: any
multiple?: boolean
onChange?: any
}

const OptionSetAutocomplete = (props: AutoCompleteProps) => {
const { input, meta }: FieldRenderProps<any, HTMLElement> = useField(props.name);
const { input, meta }: FieldRenderProps<any, HTMLElement> = useField(props.name)

const options = (props?.options?.optionSet?.options != null)
? props?.options.optionSet?.options.map((option: { value: string, label: string }) => ({
value: option?.value,
label: option?.label
}))
: [];
const options =
props?.options?.optionSet?.options != null
? props?.options.optionSet?.options.map((option: { value: string, label: string }) => ({
value: option?.value,
label: option?.label
}))
: []

return (
<Autocomplete
{...props}
multiple={props.multiple !== undefined ? props.multiple : false}
options={options}
closeIcon={null}
disabled={props.disabled}
getOptionLabel={(option: any) => option.label}
value={
props.multiple !== undefined && Boolean(props.multiple)
? input.value?.length > 0 ? input.value.map((val: any) => options.find((element: { value: string }) => element.value === val)) : []
: options.find((element: { value: string }) => element.value === input.value)
}
renderInput={(params: any) => (
<TextField
{...params}
variant="outlined"
error={(meta.touched === true) && meta.error}
helperText={(meta.touched === true) && meta.error}
size="small"
label={props.label !== undefined ? props.label : ''}
InputProps={{
...params.InputProps,
style: {
backgroundColor: "#fff"
}
return (
<Autocomplete
{...props}
multiple={props.multiple !== undefined ? props.multiple : false}
options={options}
closeIcon={null}
disabled={props.disabled}
getOptionLabel={(option: any) => option.label}
value={
props.multiple !== undefined && Boolean(props.multiple)
? input.value?.length > 0
? input.value.map((val: any) =>
options.find((element: { value: string }) => element.value === val)
)
: []
: options.find((element: { value: string }) => element.value === input.value)
}
renderInput={(params: any) => (
<TextField
{...params}
variant="outlined"
error={meta.touched === true && meta.error}
helperText={meta.touched === true && meta.error}
size="small"
label={props.label !== undefined ? props.label : ''}
InputProps={{
...params.InputProps,
style: {
backgroundColor: '#fff'
}
}}
/>
)}
onChange={(_, value: any) => {
input.onChange(
props.multiple !== undefined && props.multiple !== null && Boolean(props.multiple)
? value?.length > 0
? value.map((v: { value: string }) => v.value)
: []
: value?.value
)
Boolean(props.onChange) && props.onChange(value)
}}
/>
)}
onChange={(_, value: any) => {
input.onChange(props.multiple !== undefined && props.multiple !== null && Boolean(props.multiple) ? value?.length > 0 ? value.map((v: { value: string }) => v.value) : [] : value?.value);
(Boolean(props.onChange)) && props.onChange(value)
}}
/>
);
};
/>
)
}

function SingleSelectField(props: AutoCompleteProps) {
return (
<div>
<OptionSetAutocomplete {...props} name={props.name} />
</div>
);
return (
<div>
<OptionSetAutocomplete {...props} name={props.name} />
</div>
)
}

export default SingleSelectField;
export default SingleSelectField
45 changes: 28 additions & 17 deletions src/components/routes/RouteList.tsx
Original file line number Diff line number Diff line change
@@ -1,91 +1,102 @@
import { Navigate } from "react-router-dom";
import React from "react";
import { SideBarLayout, SimpleLayout } from "../../layout"
import { AppsConfiguration, AppsInstallation, GenericForm, StaffAttendance, StaffEnrollment, StaffProgram, StudentsAttendance, StudentsEnrollment, StudentsPerformance, StudentsProgram, StudentsSocioEconomics } from "../../pages";
import { AppsConfiguration, AppsInstallation, GenericForm, StaffAttendance, StaffEnrollment, StaffProgram, StudentWizard, StudentsAttendance, StudentsEnrollment, StudentsPerformance, StudentsProgram, StudentsSocioEconomics } from "../../pages";
import StudentsFinalResults from "../../pages/students/Student_FinalResultConfig";
import StudentsTransfer from "../../pages/students/Student_TransferConfig";
import StaffTransfer from "../../pages/staff/Staff_TransferConfig";
import DefaultSettings from "../../pages/appsOverview/DefaultSettings";
import { StaffWizard } from "../../pages/staff";

export default function RouteList() {
return [
{
path: "/",
path: '/',
layout: SimpleLayout,
component: () => <Navigate to="/students/program" replace />
},
{
path: "/students/program",
path: '/students/wizard',
layout: SideBarLayout,
component: () => <StudentWizard />
},
{
path: '/students/program',
layout: SideBarLayout,
component: () => <StudentsProgram />
},
{
path: "/students/enrollment",
path: '/students/enrollment',
layout: SideBarLayout,
component: () => <StudentsEnrollment />
},
{
path: "/students/socio-economics",
path: '/students/socio-economics',
layout: SideBarLayout,
component: () => <StudentsSocioEconomics />
},
{
path: "/students/attendance",
path: '/students/attendance',
layout: SideBarLayout,
component: () => <StudentsAttendance />
},
{
path: "/students/performance",
path: '/students/performance',
layout: SideBarLayout,
component: () => <StudentsPerformance />
},
{
path: "/students/final-result",
path: '/students/final-result',
layout: SideBarLayout,
component: () => <StudentsFinalResults />
},
{
path: "/students/transfer",
path: '/students/transfer',
layout: SideBarLayout,
component: () => <StudentsTransfer />
},
{
path: "/apps/default-settings",
path: '/apps/default-settings',
layout: SideBarLayout,
component: () => <DefaultSettings />
},
{
path: "/staffs/program",
path: '/staffs/wizard',
layout: SideBarLayout,
component: () => <StaffWizard />
},
{
path: '/staffs/program',
layout: SideBarLayout,
component: () => <StaffProgram />
},
{
path: "/staffs/enrollment",
path: '/staffs/enrollment',
layout: SideBarLayout,
component: () => <StaffEnrollment />
},
{
path: "/staffs/attendance",
path: '/staffs/attendance',
layout: SideBarLayout,
component: () => <StaffAttendance />
},
{
path: "/staffs/transfer",
path: '/staffs/transfer',
layout: SideBarLayout,
component: () => <StaffTransfer />
},
{
path: "/apps/installation",
path: '/apps/installation',
layout: SideBarLayout,
component: () => <AppsInstallation />
},
{
path: "/apps/configuration",
path: '/apps/configuration',
layout: SideBarLayout,
component: () => <AppsConfiguration />
},
{
path: "/form",
path: '/form',
layout: SideBarLayout,
component: GenericForm
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/staffs/AttendanceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export default function AttendanceForm(): React.JSX.Element {
setNoProgramErrorMessage(null)
const programId = getDataStoreElement({ dataStores: data.dataStoreValues, elementKey: "program", key: "staff" })
const programStageId = getDataStoreElement({ dataStores: data?.dataStoreValues, elementKey: "attendance", key: "staff" })?.programStage
const studentProgramFilterConfig = getDataStoreElement({ dataStores: data?.dataStoreConfigs, elementKey: "attendance", key: "staff" })?.programStage?.filter
const staffProgramFilterConfig = getDataStoreElement({ dataStores: data?.dataStoreConfigs, elementKey: "attendance", key: "staff" })?.programStage?.filter

if (programId === undefined) {
setNoProgramErrorMessage("No programs have been configured. Please configure it before continuing !")
}
if (programId !== null && programId !== undefined) {
getProgramStages(programId, studentProgramFilterConfig)
getProgramStages(programId, staffProgramFilterConfig)
}
if (programStageId !== null && programStageId !== undefined) {
getDataElements(programStageId)
Expand Down
4 changes: 2 additions & 2 deletions src/components/staffs/EnrollmentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export default function EnrollmentForm(): React.JSX.Element {
setNoProgramErrorMessage(null)
const programId = getDataStoreElement({ dataStores: data.dataStoreValues, elementKey: "program", key: "staff" })
const programStageId = getDataStoreElement({ dataStores: data?.dataStoreValues, elementKey: "registration", key: "staff" })?.programStage
const studentProgramFilterConfig = getDataStoreElement({ dataStores: data?.dataStoreConfigs, elementKey: "registration", key: "staff" })?.programStage?.filter
const staffProgramFilterConfig = getDataStoreElement({ dataStores: data?.dataStoreConfigs, elementKey: "registration", key: "staff" })?.programStage?.filter

if (programId === undefined) {
setNoProgramErrorMessage("No programs have been configured. Please configure it before continuing !")
}

if (programId !== null && programId !== undefined) {
getProgramStages(programId,studentProgramFilterConfig)
getProgramStages(programId,staffProgramFilterConfig)
}
if (programStageId !== null && programStageId !== undefined) {
getDataElements(programStageId)
Expand Down
Loading

0 comments on commit 118302b

Please sign in to comment.