Commit 480f6aa8 authored by janithgamage1.ed's avatar janithgamage1.ed

fix: update

Desc : update project
parent 826cba1c
import { MouseEvent, useMemo, useState } from 'react';
import { MouseEvent, useEffect, useMemo, useState } from 'react';
// material-ui
import {
......@@ -34,9 +34,15 @@ import { DeleteTwoTone, EditTwoTone, EyeTwoTone, PlusOutlined } from '@ant-desig
//types
import { PopupTransition } from 'components/@extended/Transitions';
import status from 'data/status';
import AddEditCurriculum from 'sections/parameters/curriculum-management/AddEditCurriculum';
import AlertCurriculumDelete from 'sections/parameters/curriculum-management/AlertCurriculumDelete';
import { ReactTableProps, curriculumProps, dataProps } from './types/types';
import { useDispatch, useSelector } from 'store';
import { fetchCurriculums, toInitialState } from 'store/reducers/curriculum';
import { openSnackbar } from 'store/reducers/snackbar';
import { Curriculums } from 'types/curriculum';
import { ReactTableProps, curriculumProps } from './types/types';
import curriculumLevels from 'data/curriculumLevels';
// ==============================|| REACT TABLE ||============================== //
......@@ -122,9 +128,14 @@ function ReactTable({ columns, data, handleAddEdit }: ReactTableProps) {
// ==============================|| List ||============================== //
const List = () => {
const theme = useTheme();
const dispatch = useDispatch();
const { curriculums, error, success, isLoading } = useSelector(state => state.curriculum);
// table
const data: dataProps[] = []
// const data: dataProps[] = []
// table
const [data, setData] = useState<Curriculums[]>([])
const columns = useMemo(
() =>
......@@ -150,23 +161,76 @@ const List = () => {
{
Header: 'Curriculum Code',
accessor: 'curriculumCode'
},
},
{
Header: 'Curriculum LVL',
accessor: 'curriculumLevel'
},
accessor: 'curriculumLevel',
Cell: ({ row }: { row: Row }) => {
if (row.values.curriculumLevel === undefined || row.values.curriculumLevel === null || row.values.curriculumLevel === '') {
return <>-</>
}
if (typeof row.values.curriculumLevel === 'string') {
return <>{row.values.curriculumLevel}</>;
}
if (typeof row.values.curriculumLevel === 'number') {
return <>{curriculumLevels.find(curriculumLevel => curriculumLevel.id === row.values.curriculumLevel)?.description || "-"}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
},
{
Header: 'Curriculum Name',
accessor: 'curriculumTitle'
},
accessor: 'curriculumTitle',
Cell: ({ row }: { row: Row }) => {
if (row.values.curriculumTitle === undefined || row.values.curriculumTitle === null || row.values.curriculumTitle === '') {
return <>-</>
}
if (typeof row.values.curriculumTitle === 'string') {
return <>{row.values.curriculumTitle}</>;
}
if (typeof row.values.curriculumTitle === 'number') {
return <>{row.values.curriculumTitle || "-"}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
},
{
Header: 'Status',
accessor: 'status'
},
accessor: 'status',
className: 'cell-center',
Cell: ({ row }: { row: Row }) => {
if (row.values.status === undefined || row.values.status === null || row.values.status === '') {
return <>-</>
}
if (typeof row.values.status === 'string') {
return <>{row.values.status}</>;
}
if (typeof row.values.status === 'number') {
return <>{status.find(status => status.id === row.values.status)?.description || "-"}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
},
{
Header: 'Created By',
accessor: 'createdBy'
},
accessor: 'createdBy',
Cell: ({ row }: { row: Row }) => {
if (row.values.createdBy === undefined || row.values.createdBy === null || row.values.createdBy === '') {
return <>-</>
}
if (typeof row.values.createdBy === 'string') {
return <>{row.values.createdBy}</>;
}
if (typeof row.values.createdBy === 'number') {
return <>{row.values.createdBy}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
},
{
id: "actions",
Header: 'Actions',
......@@ -235,12 +299,65 @@ const List = () => {
//alert model
const [openAlert, setOpenAlert] = useState(false);
const [curriculumId, setCurriculumId] = useState<number | string | undefined>(undefined)
const [curriculumId, setCurriculumId] = useState<number | string | undefined>(undefined)
const handleAlertClose = () => {
setOpenAlert(!openAlert);
};
/**
* API Config
* Tutorial API
*/
useEffect(() => {
dispatch(fetchCurriculums());
}, [dispatch]);
useEffect(() => {
setData(curriculums);
}, [curriculums])
// handel error
useEffect(() => {
if (error != null) {
dispatch(
openSnackbar({
open: true,
//@ts-ignore
message: error ? error.Message : "Something went wrong ...",
variant: 'alert',
alert: {
color: 'error'
},
close: true
})
);
dispatch(toInitialState())
}
}, [error])
// handel success
useEffect(() => {
if (success != null) {
dispatch(
openSnackbar({
open: true,
message: success,
variant: 'alert',
alert: {
color: 'success'
},
close: true
})
);
dispatch(toInitialState())
}
}, [success])
if (isLoading) {
return <div>Loading...</div>;
}
return (
<>
<MainCard content={false}>
......
import { Column } from 'react-table';
import { Curriculums } from 'types/curriculum';
export interface dataProps {
_id: number | string | undefined;
......@@ -17,7 +18,7 @@ export interface dataProps {
export interface ReactTableProps {
columns: Column[]
data: dataProps[]
data: Curriculums[]
handleAddEdit: () => void
}
......
import { MouseEvent, useMemo, useState } from 'react';
import { MouseEvent, useEffect, useMemo, useState } from 'react';
// material-ui
import {
......@@ -34,9 +34,14 @@ import {
import { DeleteTwoTone, EditTwoTone, EyeTwoTone, PlusOutlined } from '@ant-design/icons';
//types
import status from 'data/status';
import AddEditTutorial from 'sections/parameters/tutorial-management/AddEditTutorial';
import AlertTutorialDelete from 'sections/parameters/tutorial-management/AlertTutorialDelete';
import { ReactTableProps, dataProps, tutorialProps } from './types/types';
import { useDispatch, useSelector } from 'store';
import { openSnackbar } from 'store/reducers/snackbar';
import { fetchTutorials, toInitialState } from 'store/reducers/tutorial';
import { Tutorials } from 'types/tutorial';
import { ReactTableProps, tutorialProps } from './types/types';
// ==============================|| REACT TABLE ||============================== //
......@@ -122,145 +127,151 @@ function ReactTable({ columns, data, handleAddEdit }: ReactTableProps) {
// ==============================|| List ||============================== //
const List = () => {
const theme = useTheme();
const dispatch = useDispatch();
const { tutorials, error, success, isLoading } = useSelector(state => state.tutorial);
// table
const data: dataProps[] = [
{
"_id": "",
"tutorialCode": "01",
"tutorialTitle": "Numbers and Counting in Sign Language",
"tutorialDescription": "In this tutorial, you'll discover how to express numbers visually using simple hand gestures. Each number has a unique sign that involves specific finger placements and hand movements. We'll break down each number step by step, providing you with clear instructions, images, and videos to help you learn effectively.",
"tutorialImage": "https://drive.google.com/uc?export=view&id=1YACBlu7X-O7-DKv5DoW3AM9kgfT7Yhdc",
"taskItems": [
{
"_id": "",
"title": "Learn Number One",
"description": "Learn how to sign the number one in sign language.",
"howToDo": "- Extend your index finger straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_one.jpg",
"referenceVideo": "https://example.com/number_one_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Two",
"description": "Learn how to sign the number two in sign language.",
"howToDo": "- Extend your index and middle fingers straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_two.jpg",
"referenceVideo": "https://example.com/number_two_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Three",
"description": "Learn how to sign the number three in sign language.",
"howToDo": "- Extend your index, middle, and ring fingers straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_three.jpg",
"referenceVideo": "https://example.com/number_three_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Four",
"description": "Learn how to sign the number four in sign language.",
"howToDo": "- Extend your thumb, index, middle, and ring fingers straight up.\n- Keep your pinky finger folded.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_four.jpg",
"referenceVideo": "https://example.com/number_four_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Five",
"description": "Learn how to sign the number five in sign language.",
"howToDo": "- Extend all your fingers straight up.\n- Keep your thumb resting on the side of your palm.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_five.jpg",
"referenceVideo": "https://example.com/number_five_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Six",
"description": "Learn how to sign the number six in sign language.",
"howToDo": "- Extend your thumb and pinky finger straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_six.jpg",
"referenceVideo": "https://example.com/number_six_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Seven",
"description": "Learn how to sign the number seven in sign language.",
"howToDo": "- Extend your index, middle, and ring fingers straight up.\n- Keep your thumb, pinky, and pinky finger folded.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_seven.jpg",
"referenceVideo": "https://example.com/number_seven_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Eight",
"description": "Learn how to sign the number eight in sign language.",
"howToDo": "- Extend all your fingers straight up.\n- Cross your index and middle fingers over your ring and pinky fingers.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_eight.jpg",
"referenceVideo": "https://example.com/number_eight_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Nine",
"description": "Learn how to sign the number nine in sign language.",
"howToDo": "- Extend your thumb and all your fingers straight up.\n- Keep your pinky finger folded.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_nine.jpg",
"referenceVideo": "https://example.com/number_nine_video.mp4",
"taskItemMark": 10
},
{
"_id": "",
"title": "Learn Number Ten",
"description": "Learn how to sign the number ten in sign language.",
"howToDo": "- Extend your thumb, index, and middle fingers straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
"referenceImage": "https://example.com/number_ten.jpg",
"referenceVideo": "https://example.com/number_ten_video.mp4",
"taskItemMark": 10
}
],
"status": 1,
"createdAt": new Date("2023-08-30T12:00:00Z"),
"createdBy": "Nuwan Gamage"
},
{
"_id": "",
"tutorialCode": "02",
"tutorialTitle": "Everyday Vocabulary in Sign Language",
"tutorialDescription": "Teach signs for everyday objects and activities, such as eat, drink, sleep, book, pen, etc.\nIntroduce signs for common words used in daily life.\nProvide visual demonstrations and interactive exercises for learners to practice using these signs.",
"tutorialImage": "https://drive.google.com/uc?export=view&id=1YACBlu7X-O7-DKv5DoW3AM9kgfT7Yhdc",
"taskItems": [],
"status": 1,
"createdAt": new Date("2023-08-30T12:00:00Z"),
"createdBy": "Nuwan Gamage"
},
{
"_id": "",
"tutorialCode": "03",
"tutorialTitle": "Family Signs in Sign Language",
"tutorialDescription": "Teach signs for family members, such as mother, father, sister, brother, etc.\nIntroduce signs for common family-related words, such as family, love, and home.\nProvide visual demonstrations and practice exercises for learners to practice these family signs.",
"tutorialImage": "https://drive.google.com/uc?export=view&id=1YACBlu7X-O7-DKv5DoW3AM9kgfT7Yhdc",
"taskItems": [],
"status": 1,
"createdAt": new Date("2023-08-30T12:00:00Z"),
"createdBy": "Nuwan Gamage"
},
{
"_id": "",
"tutorialCode": "04",
"tutorialTitle": "Basic Conversational Phrases in Sign Language",
"tutorialDescription": "Teach simple conversational phrases, such as \"What is your name?\" or \"How are you?\"\nIntroduce signs for common question words and phrases.\nProvide visual demonstrations and practice exercises for learners to practice these conversational phrases.",
"tutorialImage": "https://drive.google.com/uc?export=view&id=1YACBlu7X-O7-DKv5DoW3AM9kgfT7Yhdc",
"taskItems": [],
"status": 1,
"createdAt": new Date("2023-08-30T12:00:00Z"),
"createdBy": "Nuwan Gamage"
}
]
// const data: dataProps[] = [
// {
// "_id": "",
// "tutorialCode": "01",
// "tutorialTitle": "Numbers and Counting in Sign Language",
// "tutorialDescription": "In this tutorial, you'll discover how to express numbers visually using simple hand gestures. Each number has a unique sign that involves specific finger placements and hand movements. We'll break down each number step by step, providing you with clear instructions, images, and videos to help you learn effectively.",
// "tutorialImage": "https://drive.google.com/uc?export=view&id=1YACBlu7X-O7-DKv5DoW3AM9kgfT7Yhdc",
// "taskItems": [
// {
// "_id": "",
// "title": "Learn Number One",
// "description": "Learn how to sign the number one in sign language.",
// "howToDo": "- Extend your index finger straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_one.jpg",
// "referenceVideo": "https://example.com/number_one_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Two",
// "description": "Learn how to sign the number two in sign language.",
// "howToDo": "- Extend your index and middle fingers straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_two.jpg",
// "referenceVideo": "https://example.com/number_two_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Three",
// "description": "Learn how to sign the number three in sign language.",
// "howToDo": "- Extend your index, middle, and ring fingers straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_three.jpg",
// "referenceVideo": "https://example.com/number_three_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Four",
// "description": "Learn how to sign the number four in sign language.",
// "howToDo": "- Extend your thumb, index, middle, and ring fingers straight up.\n- Keep your pinky finger folded.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_four.jpg",
// "referenceVideo": "https://example.com/number_four_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Five",
// "description": "Learn how to sign the number five in sign language.",
// "howToDo": "- Extend all your fingers straight up.\n- Keep your thumb resting on the side of your palm.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_five.jpg",
// "referenceVideo": "https://example.com/number_five_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Six",
// "description": "Learn how to sign the number six in sign language.",
// "howToDo": "- Extend your thumb and pinky finger straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_six.jpg",
// "referenceVideo": "https://example.com/number_six_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Seven",
// "description": "Learn how to sign the number seven in sign language.",
// "howToDo": "- Extend your index, middle, and ring fingers straight up.\n- Keep your thumb, pinky, and pinky finger folded.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_seven.jpg",
// "referenceVideo": "https://example.com/number_seven_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Eight",
// "description": "Learn how to sign the number eight in sign language.",
// "howToDo": "- Extend all your fingers straight up.\n- Cross your index and middle fingers over your ring and pinky fingers.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_eight.jpg",
// "referenceVideo": "https://example.com/number_eight_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Nine",
// "description": "Learn how to sign the number nine in sign language.",
// "howToDo": "- Extend your thumb and all your fingers straight up.\n- Keep your pinky finger folded.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_nine.jpg",
// "referenceVideo": "https://example.com/number_nine_video.mp4",
// "taskItemMark": 10
// },
// {
// "_id": "",
// "title": "Learn Number Ten",
// "description": "Learn how to sign the number ten in sign language.",
// "howToDo": "- Extend your thumb, index, and middle fingers straight up.\n- Keep the rest of your fingers closed.\n- Hold your hand in front of your chest.",
// "referenceImage": "https://example.com/number_ten.jpg",
// "referenceVideo": "https://example.com/number_ten_video.mp4",
// "taskItemMark": 10
// }
// ],
// "status": 1,
// "createdAt": new Date("2023-08-30T12:00:00Z"),
// "createdBy": "Nuwan Gamage"
// },
// {
// "_id": "",
// "tutorialCode": "02",
// "tutorialTitle": "Everyday Vocabulary in Sign Language",
// "tutorialDescription": "Teach signs for everyday objects and activities, such as eat, drink, sleep, book, pen, etc.\nIntroduce signs for common words used in daily life.\nProvide visual demonstrations and interactive exercises for learners to practice using these signs.",
// "tutorialImage": "https://drive.google.com/uc?export=view&id=1YACBlu7X-O7-DKv5DoW3AM9kgfT7Yhdc",
// "taskItems": [],
// "status": 1,
// "createdAt": new Date("2023-08-30T12:00:00Z"),
// "createdBy": "Nuwan Gamage"
// },
// {
// "_id": "",
// "tutorialCode": "03",
// "tutorialTitle": "Family Signs in Sign Language",
// "tutorialDescription": "Teach signs for family members, such as mother, father, sister, brother, etc.\nIntroduce signs for common family-related words, such as family, love, and home.\nProvide visual demonstrations and practice exercises for learners to practice these family signs.",
// "tutorialImage": "https://drive.google.com/uc?export=view&id=1YACBlu7X-O7-DKv5DoW3AM9kgfT7Yhdc",
// "taskItems": [],
// "status": 1,
// "createdAt": new Date("2023-08-30T12:00:00Z"),
// "createdBy": "Nuwan Gamage"
// },
// {
// "_id": "",
// "tutorialCode": "04",
// "tutorialTitle": "Basic Conversational Phrases in Sign Language",
// "tutorialDescription": "Teach simple conversational phrases, such as \"What is your name?\" or \"How are you?\"\nIntroduce signs for common question words and phrases.\nProvide visual demonstrations and practice exercises for learners to practice these conversational phrases.",
// "tutorialImage": "https://drive.google.com/uc?export=view&id=1YACBlu7X-O7-DKv5DoW3AM9kgfT7Yhdc",
// "taskItems": [],
// "status": 1,
// "createdAt": new Date("2023-08-30T12:00:00Z"),
// "createdBy": "Nuwan Gamage"
// }
// ]
// table
const [data, setData] = useState<Tutorials[]>([])
const columns = useMemo(
() =>
......@@ -293,11 +304,38 @@ const List = () => {
},
{
Header: 'Status',
accessor: 'status'
accessor: 'status',
className: 'cell-center',
Cell: ({ row }: { row: Row }) => {
if (row.values.status === undefined || row.values.status === null || row.values.status === '') {
return <>-</>
}
if (typeof row.values.status === 'string') {
return <>{row.values.status}</>;
}
if (typeof row.values.status === 'number') {
return <>{status.find(status => status.id === row.values.status)?.description || "-"}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
},
{
Header: 'Created By',
accessor: 'createdBy'
accessor: 'createdBy',
Cell: ({ row }: { row: Row }) => {
if (row.values.createdBy === undefined || row.values.createdBy === null || row.values.createdBy === '') {
return <>-</>
}
if (typeof row.values.createdBy === 'string') {
return <>{row.values.createdBy}</>;
}
if (typeof row.values.createdBy === 'number') {
return <>{row.values.createdBy}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
},
{
id: "actions",
......@@ -373,6 +411,59 @@ const List = () => {
setOpenAlert(!openAlert);
};
/**
* API Config
* Tutorial API
*/
useEffect(() => {
dispatch(fetchTutorials());
}, [dispatch]);
useEffect(() => {
setData(tutorials);
}, [tutorials])
// handel error
useEffect(() => {
if (error != null) {
dispatch(
openSnackbar({
open: true,
//@ts-ignore
message: error ? error.Message : "Something went wrong ...",
variant: 'alert',
alert: {
color: 'error'
},
close: true
})
);
dispatch(toInitialState())
}
}, [error])
// handel success
useEffect(() => {
if (success != null) {
dispatch(
openSnackbar({
open: true,
message: success,
variant: 'alert',
alert: {
color: 'success'
},
close: true
})
);
dispatch(toInitialState())
}
}, [success])
if (isLoading) {
return <div>Loading...</div>;
}
return (
<>
<MainCard content={false}>
......
import { Column } from 'react-table';
import { Tutorials } from 'types/tutorial';
export interface dataProps {
_id: number | string | undefined;
......@@ -16,7 +17,7 @@ export interface dataProps {
export interface ReactTableProps {
columns: Column[]
data: dataProps[]
data: Tutorials[]
handleAddEdit: () => void
}
......
......@@ -7,6 +7,7 @@ import storage from 'redux-persist/lib/storage';
import calendar from './calendar';
import cartReducer from './cart';
import chat from './chat';
import curriculum from './curriculum';
import ingredient from './ingredient';
import invoice from './invoice';
import kanban from './kanban';
......@@ -16,6 +17,8 @@ import nutrition from './nutrition';
import productReducer from './product';
import snackbar from './snackbar';
import subscription from './subscription';
import tutorial from './tutorial';
// ==============================|| COMBINE REDUCERS ||============================== //
......@@ -39,7 +42,9 @@ const reducers = combineReducers({
nutrition,
ingredient,
subscription,
marksCalculator
marksCalculator,
tutorial,
curriculum
});
export default reducers;
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