Commit a6b843b5 authored by janithgamage1.ed's avatar janithgamage1.ed

fix: update

Desc : update project
parent 480f6aa8
import { useState } from 'react';
// material-ui // material-ui
import { Grid } from '@mui/material'; import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons';
import { Card, CardContent, CardHeader, Collapse, Grid, IconButton, Typography } from '@mui/material';
// third-party // third-party
...@@ -15,11 +17,67 @@ import WelcomeBanner from 'sections/learning-management/WelcomeBanner'; ...@@ -15,11 +17,67 @@ import WelcomeBanner from 'sections/learning-management/WelcomeBanner';
// ==============================|| Dashboard ||============================== // // ==============================|| Dashboard ||============================== //
const Dashboard = () => { const Dashboard = () => {
const [expanded, setExpanded] = useState(false);
const handleExpandClick = () => {
setExpanded(!expanded);
};
return ( return (
<Grid container rowSpacing={4.5} columnSpacing={3}> <Grid container rowSpacing={2} columnSpacing={3}>
<Grid item xs={12}> <Grid item xs={12}>
<WelcomeBanner /> <WelcomeBanner />
</Grid> </Grid>
<Grid md={12} item>
<Card>
<CardHeader
title="Learn Sign Language Curriculums"
subheader="Building a Solid Foundation, Enhancing Skills, and Mastering Sign Language"
action={
<IconButton
aria-expanded={expanded}
aria-label="show more"
onClick={handleExpandClick}
>
{expanded ? <ArrowUpOutlined /> : <ArrowDownOutlined />}
</IconButton>
}
/>
<Collapse in={expanded} timeout="auto" unmountOnExit>
<CardContent>
<Typography variant="body1">
Explore the world of sign language with our comprehensive Curriculum offerings. We provide three levels of sign language Curriculums designed to cater to learners of varying proficiency levels.
</Typography>
<Typography variant="subtitle1" sx={{ mt: 3 }}>
1. Base Level - Learn Sign Language:
</Typography>
<Typography variant="body2" sx={{ mt: 3 }}>
Start your sign language journey with our Base Level Curriculum. Perfect for beginners, this Curriculum offers essential sign language skills, including basic vocabulary, grammar, and sentence structures. Through interactive lessons and hands-on practice, you'll learn to express yourself through gestures and facial expressions, enabling effective communication with the deaf and hard of hearing community. Join us today and begin breaking down communication barriers.
</Typography>
<Typography variant="subtitle1" sx={{ mt: 3 }}>
2. Medium Level - Enhancing Sign Language Skills:
</Typography>
<Typography variant="body2" sx={{ mt: 3 }}>
Take your sign language skills to the next level with our Medium Level Curriculum. Designed for learners with some basic knowledge of sign language, this Curriculum focuses on expanding vocabulary, improving grammar usage, and honing expressive abilities. Engage in challenging yet rewarding lessons, interactive exercises, role-playing scenarios, and conversations to strengthen fluency. By delving deeper into sign language communication, including idiomatic expressions and storytelling techniques, you'll be able to connect with the deaf community on a deeper level.
</Typography>
<Typography variant="subtitle1" sx={{ mt: 3 }}>
3. Advanced Level - Mastering Sign Language:
</Typography>
<Typography variant="body2" sx={{ mt: 3 }}>
Become a proficient sign language user with our Advanced Level Curriculum. This comprehensive Curriculum is designed for experienced sign language learners seeking mastery. Dive into advanced topics such as complex grammar structures, specialized vocabulary, and cultural nuances. Through immersive activities, real-life simulations, and in-depth discussions, you'll refine your receptive and expressive skills. Explore various sign language modalities and gain a deep understanding of different signing systems. With personalized feedback and guidance from expert instructors, our Advanced Level Curriculum equips you to engage confidently in diverse sign language contexts.
</Typography>
<Typography variant="subtitle2" sx={{ mt: 3 }}>
Whether you're starting from scratch or aiming to enhance your existing sign language skills, our Curriculums offer a supportive learning environment and the opportunity to build connections with the deaf community. Join us today and embark on your sign language journey!
</Typography>
</CardContent>
</Collapse>
</Card>
</Grid>
</Grid> </Grid>
) )
} }
......
import { MouseEvent, useMemo } from 'react'; import { MouseEvent, useEffect, useMemo, useState } from 'react';
// material-ui // material-ui
import { import {
...@@ -31,7 +31,12 @@ import { ...@@ -31,7 +31,12 @@ import {
import { DeleteTwoTone, EditTwoTone } from '@ant-design/icons'; import { DeleteTwoTone, EditTwoTone } from '@ant-design/icons';
//types //types
import { ReactTableProps, dataProps } from './types/types'; import status from 'data/status';
import { useDispatch, useSelector } from 'store';
import { openSnackbar } from 'store/reducers/snackbar';
import { fetchUsers, toInitialState } from 'store/reducers/user';
import { Users } from 'types/user';
import { ReactTableProps } from './types/types';
// ==============================|| REACT TABLE ||============================== // // ==============================|| REACT TABLE ||============================== //
...@@ -101,10 +106,10 @@ function ReactTable({ columns, data }: ReactTableProps) { ...@@ -101,10 +106,10 @@ function ReactTable({ columns, data }: ReactTableProps) {
); );
}) })
) : ( ) : (
<EmptyTable msg="No Data" colSpan={5} /> <EmptyTable msg="No Data" colSpan={12} />
)} )}
<TableRow> <TableRow>
<TableCell sx={{ p: 2 }} colSpan={5}> <TableCell sx={{ p: 2 }} colSpan={12}>
<TablePagination gotoPage={gotoPage} rows={rows} setPageSize={setPageSize} pageIndex={pageIndex} pageSize={pageSize} /> <TablePagination gotoPage={gotoPage} rows={rows} setPageSize={setPageSize} pageIndex={pageIndex} pageSize={pageSize} />
</TableCell> </TableCell>
</TableRow> </TableRow>
...@@ -119,18 +124,22 @@ function ReactTable({ columns, data }: ReactTableProps) { ...@@ -119,18 +124,22 @@ function ReactTable({ columns, data }: ReactTableProps) {
const List = () => { const List = () => {
const theme = useTheme(); const theme = useTheme();
const dispatch = useDispatch();
const { users, error, success, isLoading } = useSelector(state => state.user);
// table // table
const data: dataProps[] = [ // const data: dataProps[] = [
{ // {
id: 1, // id: 1,
userName: "Nuwan Gamage", // userName: "Nuwan Gamage",
userContactNumber: "0768523456", // userContactNumber: "0768523456",
userEmailAddress: "nuwangamage@gmail.com", // userEmailAddress: "nuwangamage@gmail.com",
userType: "Member", // userType: "Member",
userStatus: "Active" // userStatus: "Active"
} // }
] // ]
const [data, setData] = useState<Users[]>([])
const columns = useMemo( const columns = useMemo(
() => () =>
...@@ -155,33 +164,69 @@ const List = () => { ...@@ -155,33 +164,69 @@ const List = () => {
}, },
{ {
Header: 'User Name', Header: 'User Name',
accessor: 'userName', accessor: 'firstName',
className: 'cell-center', Cell: ({ row }: { row: Row }) => {
if (row.values.firstName === undefined || row.values.firstName === null || row.values.firstName === '') {
return <>-</>
}
if (typeof row.values.firstName === 'string') {
//@ts-ignore
return <>{row.values.firstName + " " + row.original.lastName}</>;
}
if (typeof row.values.firstName === 'number') {
return <>{row.values.firstName}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
}, },
{ {
Header: 'User Email', Header: 'User Email',
accessor: 'userEmailAddress', accessor: 'email',
className: 'cell-center',
}, },
{ {
Header: 'User Contact Number', Header: 'User Contact Number',
accessor: 'userContactNumber', accessor: 'contactNumber',
className: 'cell-center',
}, },
{ {
Header: 'User Type', Header: 'User Type',
accessor: 'userType', accessor: 'type',
className: 'cell-center', Cell: ({ row }: { row: Row }) => {
if (row.values.type === undefined || row.values.type === null || row.values.type === '') {
return <>-</>
}
if (typeof row.values.type === 'string') {
return <>{row.values.type.toUpperCase()}</>;
}
if (typeof row.values.type === 'number') {
return <>{row.values.type}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
}, },
{ {
Header: 'User Status', Header: 'User Status',
accessor: 'userStatus', accessor: 'states',
className: 'cell-center', className: 'cell-center',
Cell: ({ row }: { row: Row }) => {
if (row.values.states === undefined || row.values.states === null || row.values.states === '') {
return <>-</>
}
if (typeof row.values.states === 'string') {
return <>{status.find(status => status.id === parseInt(row.values.states))?.description || "-"}</>;
}
if (typeof row.values.states === 'number') {
return <>{status.find(status => status.id === row.values.states)?.description || "-"}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
}, },
{ {
id: "actions", id: "actions",
Header: 'Actions', Header: 'Actions',
accessor: 'actions', accessor: 'actions',
Cell: ({ row }: { row: Row }) => { Cell: ({ row }: { row: Row }) => {
return ( return (
<> <>
...@@ -225,6 +270,59 @@ const List = () => { ...@@ -225,6 +270,59 @@ const List = () => {
[] []
); );
/**
* API Config
* User API
*/
useEffect(() => {
dispatch(fetchUsers('member'));
}, [dispatch]);
useEffect(() => {
setData(users);
}, [users])
// 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 ( return (
<> <>
<MainCard content={false}> <MainCard content={false}>
......
import { Column } from 'react-table'; import { Column } from 'react-table';
import { Users } from 'types/user';
export interface dataProps { export interface dataProps {
id: number | string | undefined id: number | string | undefined
...@@ -11,7 +12,7 @@ export interface dataProps { ...@@ -11,7 +12,7 @@ export interface dataProps {
export interface ReactTableProps { export interface ReactTableProps {
columns: Column[] columns: Column[]
data: dataProps[] data: Users[]
} }
export interface userProps { export interface userProps {
......
import { MouseEvent, useMemo, useState } from 'react'; import { MouseEvent, useEffect, useMemo, useState } from 'react';
// material-ui // material-ui
import { import {
...@@ -32,11 +32,16 @@ import { ...@@ -32,11 +32,16 @@ import {
import { DeleteTwoTone, EditTwoTone, PlusOutlined } from '@ant-design/icons'; import { DeleteTwoTone, EditTwoTone, PlusOutlined } from '@ant-design/icons';
//types //types
import { ReactTableProps, dataProps, userProps } from './types/types'; import status from 'data/status';
import { useDispatch, useSelector } from 'store';
import { openSnackbar } from 'store/reducers/snackbar';
import { fetchUsersByType, toInitialState } from 'store/reducers/user';
import { Users } from 'types/user';
import { ReactTableProps, userProps } from './types/types';
// ==============================|| REACT TABLE ||============================== // // ==============================|| REACT TABLE ||============================== //
function ReactTable({ columns, data , handleAddEdit}: ReactTableProps) { function ReactTable({ columns, data, handleAddEdit }: ReactTableProps) {
const filterTypes = useMemo(() => renderFilterTypes, []); const filterTypes = useMemo(() => renderFilterTypes, []);
const defaultColumn = useMemo(() => ({ Filter: DefaultColumnFilter }), []); const defaultColumn = useMemo(() => ({ Filter: DefaultColumnFilter }), []);
...@@ -102,10 +107,10 @@ function ReactTable({ columns, data , handleAddEdit}: ReactTableProps) { ...@@ -102,10 +107,10 @@ function ReactTable({ columns, data , handleAddEdit}: ReactTableProps) {
); );
}) })
) : ( ) : (
<EmptyTable msg="No Data" colSpan={5} /> <EmptyTable msg="No Data" colSpan={12} />
)} )}
<TableRow> <TableRow>
<TableCell sx={{ p: 2 }} colSpan={5}> <TableCell sx={{ p: 2 }} colSpan={12}>
<TablePagination gotoPage={gotoPage} rows={rows} setPageSize={setPageSize} pageIndex={pageIndex} pageSize={pageSize} /> <TablePagination gotoPage={gotoPage} rows={rows} setPageSize={setPageSize} pageIndex={pageIndex} pageSize={pageSize} />
</TableCell> </TableCell>
</TableRow> </TableRow>
...@@ -120,26 +125,33 @@ function ReactTable({ columns, data , handleAddEdit}: ReactTableProps) { ...@@ -120,26 +125,33 @@ function ReactTable({ columns, data , handleAddEdit}: ReactTableProps) {
const List = () => { const List = () => {
const theme = useTheme(); const theme = useTheme();
const dispatch = useDispatch();
const { users, error, success, isLoading } = useSelector(state => state.user);
// table // table
const data: dataProps[] = [ // const data: dataProps[] = [
{ // {
id: 1, // id: 1,
userName: "Janith Gamage", // userName: "Janith Gamage",
userContactNumber: "0768523525", // userContactNumber: "0768523525",
userEmailAddress: "janithgamage1.ed@gmail.com", // userEmailAddress: "janithgamage1.ed@gmail.com",
userType: "Admin", // userType: "Admin",
userStatus: "Active" // userStatus: "Active"
}, // },
{ // {
id: 1, // id: 1,
userName: "Nuwan Gamage", // userName: "Nuwan Gamage",
userContactNumber: "0768523456", // userContactNumber: "0768523456",
userEmailAddress: "nuwangamage@gmail.com", // userEmailAddress: "nuwangamage@gmail.com",
userType: "Member", // userType: "Member",
userStatus: "Active" // userStatus: "Active"
} // }
] // ]
// table
const [data, setData] = useState<Users[]>([])
//dialog model //dialog model
const [addEdit, setAddEdit] = useState<boolean>(false); const [addEdit, setAddEdit] = useState<boolean>(false);
...@@ -173,28 +185,64 @@ const List = () => { ...@@ -173,28 +185,64 @@ const List = () => {
}, },
{ {
Header: 'User Name', Header: 'User Name',
accessor: 'userName', accessor: 'firstName',
className: 'cell-center', Cell: ({ row }: { row: Row }) => {
if (row.values.firstName === undefined || row.values.firstName === null || row.values.firstName === '') {
return <>-</>
}
if (typeof row.values.firstName === 'string') {
//@ts-ignore
return <>{row.values.firstName + " " + row.original.lastName}</>;
}
if (typeof row.values.firstName === 'number') {
return <>{row.values.firstName}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
}, },
{ {
Header: 'User Email', Header: 'User Email',
accessor: 'userEmailAddress', accessor: 'email',
className: 'cell-center',
}, },
{ {
Header: 'User Contact Number', Header: 'User Contact Number',
accessor: 'userContactNumber', accessor: 'contactNumber',
className: 'cell-center',
}, },
{ {
Header: 'User Type', Header: 'User Type',
accessor: 'userType', accessor: 'type',
className: 'cell-center', Cell: ({ row }: { row: Row }) => {
if (row.values.type === undefined || row.values.type === null || row.values.type === '') {
return <>-</>
}
if (typeof row.values.type === 'string') {
return <>{row.values.type.toUpperCase()}</>;
}
if (typeof row.values.type === 'number') {
return <>{row.values.type}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
}, },
{ {
Header: 'User Status', Header: 'User Status',
accessor: 'userStatus', accessor: 'states',
className: 'cell-center', className: 'cell-center',
Cell: ({ row }: { row: Row }) => {
if (row.values.states === undefined || row.values.states === null || row.values.states === '') {
return <>-</>
}
if (typeof row.values.states === 'string') {
return <>{status.find(status => status.id === parseInt(row.values.states))?.description || "-"}</>;
}
if (typeof row.values.states === 'number') {
return <>{status.find(status => status.id === row.values.states)?.description || "-"}</>;
}
// Handle any other data types if necessary
return <>-</>;
}
}, },
{ {
id: "actions", id: "actions",
...@@ -243,6 +291,59 @@ const List = () => { ...@@ -243,6 +291,59 @@ const List = () => {
[] []
); );
/**
* API Config
* User API
*/
useEffect(() => {
dispatch(fetchUsersByType());
}, [dispatch]);
useEffect(() => {
setData(users);
}, [users])
// 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 ( return (
<> <>
<MainCard content={false}> <MainCard content={false}>
......
import { Column } from 'react-table'; import { Column } from 'react-table';
import { Users } from 'types/user';
export interface dataProps { export interface dataProps {
id: number | string | undefined id: number | string | undefined
...@@ -11,7 +12,7 @@ export interface dataProps { ...@@ -11,7 +12,7 @@ export interface dataProps {
export interface ReactTableProps { export interface ReactTableProps {
columns: Column[] columns: Column[]
data: dataProps[] data: Users[]
handleAddEdit: () => void handleAddEdit: () => void
} }
......
...@@ -18,8 +18,7 @@ import productReducer from './product'; ...@@ -18,8 +18,7 @@ import productReducer from './product';
import snackbar from './snackbar'; import snackbar from './snackbar';
import subscription from './subscription'; import subscription from './subscription';
import tutorial from './tutorial'; import tutorial from './tutorial';
import user from './user';
// ==============================|| COMBINE REDUCERS ||============================== // // ==============================|| COMBINE REDUCERS ||============================== //
...@@ -44,7 +43,8 @@ const reducers = combineReducers({ ...@@ -44,7 +43,8 @@ const reducers = combineReducers({
subscription, subscription,
marksCalculator, marksCalculator,
tutorial, tutorial,
curriculum curriculum,
user
}); });
export default reducers; export default reducers;
...@@ -103,7 +103,7 @@ export function addUser(newUser: User) { ...@@ -103,7 +103,7 @@ export function addUser(newUser: User) {
dispatch(slice.actions.startLoading()); dispatch(slice.actions.startLoading());
try { try {
const response = await axiosServices.post('/user/sign-up', newUser); const response = await axiosServices.post('/rest_node/user/sign-up', newUser);
dispatch(slice.actions.addUserSuccess(response.data)); dispatch(slice.actions.addUserSuccess(response.data));
} catch (error) { } catch (error) {
dispatch(slice.actions.hasError(error)); dispatch(slice.actions.hasError(error));
...@@ -123,7 +123,7 @@ export function fetchUser(id: number) { ...@@ -123,7 +123,7 @@ export function fetchUser(id: number) {
dispatch(slice.actions.startLoading()); dispatch(slice.actions.startLoading());
try { try {
const response = await axiosServices.get(`/user/${id}`); const response = await axiosServices.get(`/rest_node/user/${id}`);
dispatch(slice.actions.fetchUserSuccess(response.data)); dispatch(slice.actions.fetchUserSuccess(response.data));
} catch (error) { } catch (error) {
dispatch(slice.actions.hasError(error)); dispatch(slice.actions.hasError(error));
...@@ -143,7 +143,7 @@ export function fetchUsers(userType: string) { ...@@ -143,7 +143,7 @@ export function fetchUsers(userType: string) {
dispatch(slice.actions.startLoading()); dispatch(slice.actions.startLoading());
try { try {
const response = await axiosServices.get(`/user/all/type/${userType}`); const response = await axiosServices.get(`/rest_node/user/all/type/${userType}`);
dispatch(slice.actions.fetchUsersSuccess(response.data)); dispatch(slice.actions.fetchUsersSuccess(response.data));
} catch (error) { } catch (error) {
dispatch(slice.actions.hasError(error)); dispatch(slice.actions.hasError(error));
...@@ -162,7 +162,7 @@ export function fetchUsersByType() { ...@@ -162,7 +162,7 @@ export function fetchUsersByType() {
dispatch(slice.actions.startLoading()); dispatch(slice.actions.startLoading());
try { try {
const response = await axiosServices.get('/user/all'); const response = await axiosServices.get('/rest_node/user/all');
dispatch(slice.actions.fetchUsersSuccess(response.data)); dispatch(slice.actions.fetchUsersSuccess(response.data));
} catch (error) { } catch (error) {
dispatch(slice.actions.hasError(error)); dispatch(slice.actions.hasError(error));
...@@ -182,7 +182,7 @@ export function updateUser(updatedUser: User) { ...@@ -182,7 +182,7 @@ export function updateUser(updatedUser: User) {
dispatch(slice.actions.startLoading()); dispatch(slice.actions.startLoading());
try { try {
const response = await axiosServices.put(`/user/${updatedUser._id}`, updateUser); const response = await axiosServices.put(`/rest_node/user/${updatedUser._id}`, updateUser);
dispatch(slice.actions.updateUserSuccess(response.data)); dispatch(slice.actions.updateUserSuccess(response.data));
} catch (error) { } catch (error) {
dispatch(slice.actions.hasError(error)); dispatch(slice.actions.hasError(error));
...@@ -202,7 +202,7 @@ export function deleteNutrition(userId: number) { ...@@ -202,7 +202,7 @@ export function deleteNutrition(userId: number) {
dispatch(slice.actions.startLoading()); dispatch(slice.actions.startLoading());
try { try {
await axiosServices.delete(`/user/${userId}`); await axiosServices.delete(`/rest_node/user/${userId}`);
dispatch(slice.actions.deleteUserSuccess(userId)); dispatch(slice.actions.deleteUserSuccess(userId));
} catch (error) { } catch (error) {
dispatch(slice.actions.hasError(error)); dispatch(slice.actions.hasError(error));
......
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