Commit 2b72055b authored by janithgamage1.ed's avatar janithgamage1.ed

fix: update

Desc : update project
parent 2ae4f7cc
export interface CurriculumLevelsType {
id: number
code: string
description: string
}
// ==============================|| DATA - CURRICULUM LEVELS ||============================== //
const curriculumLevels: readonly CurriculumLevelsType[] = [
{ id: 1, code: "Level 1", description: "Preliminary" },
{ id: 2, code: "Level 2", description: "Intermediate" },
{ id: 3, code: "Level 3", description: "Advance" },
];
export default curriculumLevels;
...@@ -3,7 +3,7 @@ import { Column } from 'react-table'; ...@@ -3,7 +3,7 @@ import { Column } from 'react-table';
export interface dataProps { export interface dataProps {
_id: number | string | undefined; _id: number | string | undefined;
curriculumCode: String; curriculumCode: String;
curriculumLevel: String; curriculumLevel: number;
curriculumName: String; curriculumName: String;
curriculumImage: String; curriculumImage: String;
tutorials: tutorialItemProps[]; tutorials: tutorialItemProps[];
...@@ -11,7 +11,7 @@ export interface dataProps { ...@@ -11,7 +11,7 @@ export interface dataProps {
createdBy: String; createdBy: String;
updatedBy: String; updatedBy: String;
createdAt: Date; createdAt: Date;
updatedAt: Date; updatedAt: Date;
} }
export interface ReactTableProps { export interface ReactTableProps {
...@@ -23,7 +23,7 @@ export interface ReactTableProps { ...@@ -23,7 +23,7 @@ export interface ReactTableProps {
export interface curriculumProps { export interface curriculumProps {
_id: number | string | undefined; _id: number | string | undefined;
curriculumCode: String; curriculumCode: String;
curriculumLevel: String; curriculumLevel: number;
curriculumTitle: String; curriculumTitle: String;
curriculumDescription: String; curriculumDescription: String;
curriculumImage: String; curriculumImage: String;
...@@ -32,7 +32,7 @@ export interface curriculumProps { ...@@ -32,7 +32,7 @@ export interface curriculumProps {
createdBy: String; createdBy: String;
updatedBy: String; updatedBy: String;
createdAt: Date; createdAt: Date;
updatedAt: Date; updatedAt: Date;
} }
export interface tutorialItemProps { export interface tutorialItemProps {
......
...@@ -2,19 +2,21 @@ import { useState } from 'react'; ...@@ -2,19 +2,21 @@ import { useState } from 'react';
// material-ui // material-ui
import { import {
Autocomplete,
Box, Box,
Button, Button,
DialogActions, DialogActions,
DialogContent, DialogContent,
DialogTitle, DialogTitle,
Divider, Divider,
FormHelperText,
Grid, Grid,
InputLabel, InputLabel,
Stack, Stack,
TextField, TextField,
Tooltip Tooltip
} from '@mui/material'; } from '@mui/material';
// import { useTheme } from '@mui/material/styles'; import { useTheme } from '@mui/material/styles';
import { LocalizationProvider } from '@mui/x-date-pickers'; import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns'; import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
...@@ -30,6 +32,7 @@ import IconButton from 'components/@extended/IconButton'; ...@@ -30,6 +32,7 @@ import IconButton from 'components/@extended/IconButton';
// assets // assets
import { DeleteFilled } from '@ant-design/icons'; import { DeleteFilled } from '@ant-design/icons';
import MainCard from 'components/MainCard'; import MainCard from 'components/MainCard';
import curriculumLevels, { CurriculumLevelsType } from 'data/curriculumLevels';
import AlertCurriculumDelete from './AlertCurriculumDelete'; import AlertCurriculumDelete from './AlertCurriculumDelete';
// types // types
...@@ -40,7 +43,7 @@ const getInitialValues = (curriculum: FormikValues | null) => { ...@@ -40,7 +43,7 @@ const getInitialValues = (curriculum: FormikValues | null) => {
const newCurriculum = { const newCurriculum = {
_id: undefined, _id: undefined,
curriculumCode: "", curriculumCode: "",
curriculumLevel: "", curriculumLevel: undefined,
curriculumTitle: "", curriculumTitle: "",
curriculumDescription: "", curriculumDescription: "",
curriculumImage: "", curriculumImage: "",
...@@ -60,7 +63,7 @@ export interface Props { ...@@ -60,7 +63,7 @@ export interface Props {
curriculum?: { curriculum?: {
_id: number | string | undefined; _id: number | string | undefined;
curriculumCode: String; curriculumCode: String;
curriculumLevel: String; curriculumLevel: number;
curriculumTitle: String; curriculumTitle: String;
curriculumDescription: String; curriculumDescription: String;
curriculumImage: String; curriculumImage: String;
...@@ -75,7 +78,7 @@ export interface Props { ...@@ -75,7 +78,7 @@ export interface Props {
} }
const AddEditCurriculum = ({ curriculum, onCancel }: Props) => { const AddEditCurriculum = ({ curriculum, onCancel }: Props) => {
// const theme = useTheme(); const theme = useTheme();
const isCreating = !curriculum; const isCreating = !curriculum;
...@@ -138,14 +141,30 @@ const AddEditCurriculum = ({ curriculum, onCancel }: Props) => { ...@@ -138,14 +141,30 @@ const AddEditCurriculum = ({ curriculum, onCancel }: Props) => {
<Grid item xs={4}> <Grid item xs={4}>
<Stack spacing={1.25}> <Stack spacing={1.25}>
<InputLabel htmlFor="curriculumLevel">Curriculum Level</InputLabel> <InputLabel htmlFor="curriculumLevel">Curriculum Level</InputLabel>
<TextField <Autocomplete
fullWidth fullWidth
id="curriculumLevel" id="curriculumLevel"
placeholder="Enter Curriculum Level" value={curriculumLevels.find((option) => option.id === formik.values.curriculumLevel) || null}
{...getFieldProps('curriculumLevel')} onChange={(event: any, newValue: CurriculumLevelsType | null) => {
error={Boolean(touched.curriculumLevel && errors.curriculumLevel)} formik.setFieldValue('curriculumLevel', newValue?.id);
helperText={touched.curriculumLevel && errors.curriculumLevel} }}
options={curriculumLevels}
getOptionLabel={(item) => `${item.description}`}
renderInput={(params) => {
return (
<TextField
{...params}
placeholder="Select Curriculum Level"
sx={{ '& .MuiAutocomplete-input.Mui-disabled': { WebkitTextFillColor: theme.palette.text.primary } }}
/>
)
}}
/> />
{formik.touched.curriculumLevel && formik.errors.curriculumLevel && (
<FormHelperText error id="helper-text-curriculumLevel">
{formik.errors.curriculumLevel}
</FormHelperText>
)}
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={4}> <Grid item xs={4}>
...@@ -213,17 +232,33 @@ const AddEditCurriculum = ({ curriculum, onCancel }: Props) => { ...@@ -213,17 +232,33 @@ const AddEditCurriculum = ({ curriculum, onCancel }: Props) => {
values.tutorials.map((item, index) => { values.tutorials.map((item, index) => {
return ( return (
<> <>
<Grid item xs={11}> <Grid item xs={11}>
<Stack spacing={1.25}> <Stack spacing={1.25}>
<InputLabel htmlFor={`tutorials.${index}`}>Tutorial</InputLabel> <InputLabel htmlFor={`tutorials.${index}`}>Tutorial</InputLabel>
<TextField <Autocomplete
fullWidth fullWidth
id={`tutorials.${index}`} id={`tutorials.${index}`}
placeholder="Enter Tutorial" // value={tutorials.find((option) => option.id === formik.values.curriculumLevel) || null}
{...getFieldProps(`tutorials.${index}`)} // onChange={(event: any, newValue: CurriculumLevelsType | null) => {
// error={Boolean(touched.ingredientNutritions![index].nutritionCategory && errors.ingredientNutritions![index].nutritionCategory)} // formik.setFieldValue(`tutorials.${index}`, newValue?.id);
// helperText={touched.ingredientNutritions![index].nutritionCategory && errors.ingredientNutritions![index].nutritionCategory} // }}
options={[]}
// getOptionLabel={(item) => `${item.description}`}
renderInput={(params) => {
return (
<TextField
{...params}
placeholder="Select Tutorial"
sx={{ '& .MuiAutocomplete-input.Mui-disabled': { WebkitTextFillColor: theme.palette.text.primary } }}
/>
)
}}
/> />
{/* {formik.touched.curriculumLevel && formik.errors.curriculumLevel && (
<FormHelperText error id="helper-text-curriculumLevel">
{formik.errors.curriculumLevel}
</FormHelperText>
)} */}
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={1} style={{ marginTop: "4%" }}> <Grid item xs={1} style={{ marginTop: "4%" }}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment