Commit 20cb9f30 authored by janithGamage's avatar janithGamage

feat : update

desc :
> user registration option UI updated
> user registration option API Connected
> user logic on frontend
parent e686976e
...@@ -3,7 +3,7 @@ GENERATE_SOURCEMAP = false ...@@ -3,7 +3,7 @@ GENERATE_SOURCEMAP = false
## Backend API URL ## Backend API URL
REACT_APP_API_URL_MOCK=https://mock-data-api-nextjs.vercel.app/ REACT_APP_API_URL_MOCK=https://mock-data-api-nextjs.vercel.app/
REACT_APP_API_URL=http://13.49.44.192/api/v1/ REACT_APP_API_URL=http://localhost:5000/
## Google Map Key ## Google Map Key
......
...@@ -12,7 +12,8 @@ import authReducer from 'store/reducers/auth'; ...@@ -12,7 +12,8 @@ import authReducer from 'store/reducers/auth';
import Loader from 'components/Loader'; import Loader from 'components/Loader';
import { AuthProps, JWTContextType } from 'types/auth'; import { AuthProps, JWTContextType } from 'types/auth';
import { KeyedObject } from 'types/root'; import { KeyedObject } from 'types/root';
import { axiosServices_Mock as axios } from 'utils/axios'; import { axiosServices_Mock as axios, axiosServices } from 'utils/axios';
const chance = new Chance(); const chance = new Chance();
...@@ -123,20 +124,49 @@ export const JWTProvider = ({ children }: { children: React.ReactElement }) => { ...@@ -123,20 +124,49 @@ export const JWTProvider = ({ children }: { children: React.ReactElement }) => {
window.localStorage.setItem('users', JSON.stringify(users)); window.localStorage.setItem('users', JSON.stringify(users));
}; };
const registerUser = async (email: string, password: string, firstName: string, lastName: string, contactNumber: string, confirmPassword: string) => {
// todo: this flow need to be recode as it not verified
const id = chance.bb_pin();
const response = await axiosServices.post('/rest_node/user/sign-up', {
firstName,
lastName,
email,
contactNumber,
password,
confirmPassword,
type: "member"
});
let users = response.data;
if (window.localStorage.getItem('users') !== undefined && window.localStorage.getItem('users') !== null) {
const localUsers = window.localStorage.getItem('users');
users = [
...JSON.parse(localUsers!),
{
id,
email,
password,
name: `${firstName} ${lastName}`
}
];
}
window.localStorage.setItem('users', JSON.stringify(users));
};
const logout = () => { const logout = () => {
setSession(null); setSession(null);
dispatch({ type: LOGOUT }); dispatch({ type: LOGOUT });
}; };
const resetPassword = async (email: string) => {}; const resetPassword = async (email: string) => { };
const updateProfile = () => {}; const updateProfile = () => { };
if (state.isInitialized !== undefined && !state.isInitialized) { if (state.isInitialized !== undefined && !state.isInitialized) {
return <Loader />; return <Loader />;
} }
return <JWTContext.Provider value={{ ...state, login, logout, register, resetPassword, updateProfile }}>{children}</JWTContext.Provider>; return <JWTContext.Provider value={{ ...state, login, logout, register, registerUser, resetPassword, updateProfile }}>{children}</JWTContext.Provider>;
}; };
export default JWTContext; export default JWTContext;
...@@ -3,6 +3,7 @@ import { FormattedMessage } from 'react-intl'; ...@@ -3,6 +3,7 @@ import { FormattedMessage } from 'react-intl';
// assets // assets
import { import {
BookOutlined,
CarryOutOutlined, CarryOutOutlined,
CreditCardOutlined, CreditCardOutlined,
FileTextOutlined, FileTextOutlined,
...@@ -25,7 +26,8 @@ const icons = { ...@@ -25,7 +26,8 @@ const icons = {
CarryOutOutlined, CarryOutOutlined,
CreditCardOutlined, CreditCardOutlined,
LoginOutlined, LoginOutlined,
RocketOutlined RocketOutlined,
BookOutlined
}; };
// ==============================|| MENU ITEMS - SUPPORT ||============================== // // ==============================|| MENU ITEMS - SUPPORT ||============================== //
...@@ -63,6 +65,44 @@ const application: NavItemType = { ...@@ -63,6 +65,44 @@ const application: NavItemType = {
} }
] ]
}, },
{
id: 'learning-management',
title: <FormattedMessage id="learning-management" />,
type: 'collapse',
icon: icons.BookOutlined,
children: [
// {
// id: 'learning-list',
// title: <FormattedMessage id="learning-list" />,
// type: 'item',
// url: '/learning-management/list',
// },
{
id: 'learning-curriculums',
title: <FormattedMessage id="learning-curriculums" />,
type: 'item',
url: '/learning-management/curriculums',
},
{
id: 'learning-curriculums-subscribed',
title: <FormattedMessage id="learning-curriculums-subscribed" />,
type: 'item',
url: '/learning-management/curriculums-subscribed',
},
{
id: 'learning-lead-board',
title: <FormattedMessage id="learning-lead-board" />,
type: 'item',
url: '/learning-management/lead-board',
},
{
id: 'learning-feedback',
title: <FormattedMessage id="learning-feedback" />,
type: 'item',
url: '/learning-management/feedback',
}
]
},
// { // {
// id: 'authentication', // id: 'authentication',
// title: <FormattedMessage id="authentication" />, // title: <FormattedMessage id="authentication" />,
......
...@@ -6,7 +6,7 @@ import { Grid, Stack, Typography } from '@mui/material'; ...@@ -6,7 +6,7 @@ import { Grid, Stack, Typography } from '@mui/material';
// project import // project import
import useAuth from 'hooks/useAuth'; import useAuth from 'hooks/useAuth';
import AuthWrapper from 'sections/auth/AuthWrapper'; import AuthWrapper from 'sections/auth/AuthWrapper';
import FirebaseRegister from 'sections/auth/auth-forms/AuthRegister'; import AuthRegister from 'sections/auth/auth-forms/AuthRegister';
// ================================|| REGISTER ||================================ // // ================================|| REGISTER ||================================ //
...@@ -31,7 +31,7 @@ const Register = () => { ...@@ -31,7 +31,7 @@ const Register = () => {
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>
<FirebaseRegister /> <AuthRegister />
</Grid> </Grid>
</Grid> </Grid>
</AuthWrapper> </AuthWrapper>
......
// material-ui
// project import
// ==============================|| List ||============================== //
const List = () => (
<>
</>
);
export default List;
...@@ -29,6 +29,9 @@ const Dashboard = Loadable(lazy(() => import('pages/home/dashboard'))); ...@@ -29,6 +29,9 @@ const Dashboard = Loadable(lazy(() => import('pages/home/dashboard')));
// render - user management page // render - user management page
// const UserManagementList = Loadable(lazy(() => import('pages/user-management/list/list'))); // const UserManagementList = Loadable(lazy(() => import('pages/user-management/list/list')));
// render - learning management page
// const LearningManagementList = Loadable(lazy(() => import('pages/learning-management/list/list')));
// render - parameter curriculum management page // render - parameter curriculum management page
const CurriculumManagementList = Loadable(lazy(() => import('pages/parameter/curriculum-management/list/list'))); const CurriculumManagementList = Loadable(lazy(() => import('pages/parameter/curriculum-management/list/list')));
...@@ -75,6 +78,15 @@ const MainRoutes = { ...@@ -75,6 +78,15 @@ const MainRoutes = {
} }
] ]
}, },
{
path: 'learning-management',
children: [
{
path: 'list',
element: <MaintenanceUnderConstruction />
}
]
},
], ],
}, },
{ {
......
...@@ -75,6 +75,7 @@ export type JWTContextType = { ...@@ -75,6 +75,7 @@ export type JWTContextType = {
logout: () => void; logout: () => void;
login: (email: string, password: string) => Promise<void>; login: (email: string, password: string) => Promise<void>;
register: (email: string, password: string, firstName: string, lastName: string) => Promise<void>; register: (email: string, password: string, firstName: string, lastName: string) => Promise<void>;
registerUser: (email: string, password: string, firstName: string, lastName: string, contactNumber: string, confirmPassword: string) => Promise<void>;
resetPassword: (email: string) => Promise<void>; resetPassword: (email: string) => Promise<void>;
updateProfile: VoidFunction; updateProfile: VoidFunction;
}; };
......
...@@ -2,7 +2,7 @@ import axios from 'axios'; ...@@ -2,7 +2,7 @@ import axios from 'axios';
const axiosServices_Mock = axios.create({ baseURL: process.env.REACT_APP_API_URL_MOCK || 'http://localhost:3010/' }); const axiosServices_Mock = axios.create({ baseURL: process.env.REACT_APP_API_URL_MOCK || 'http://localhost:3010/' });
const axiosServices = axios.create({ baseURL: process.env.REACT_APP_API_URL || 'http://localhost:3010/' }); const axiosServices = axios.create({ baseURL: process.env.REACT_APP_API_URL || 'http://localhost:5000/' });
// ==============================|| AXIOS - FOR MOCK SERVICES ||============================== // // ==============================|| AXIOS - FOR MOCK SERVICES ||============================== //
......
...@@ -154,5 +154,11 @@ ...@@ -154,5 +154,11 @@
"nutrition-list": "Nutrition List", "nutrition-list": "Nutrition List",
"parameter": "Parameter", "parameter": "Parameter",
"tutorial-management": "Tutorial Management", "tutorial-management": "Tutorial Management",
"curriculum-management": "Curriculum Management" "curriculum-management": "Curriculum Management",
"learning-management": "Learning Management",
"learning-list": "Learning List",
"learning-curriculums": "Course",
"learning-curriculums-subscribed": "My Courses",
"learning-lead-board": "Lead Board",
"learning-feedback": "Feedback"
} }
\ No newline at end of file
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