add project structure

This commit is contained in:
veselovnk committed 2024-04-04 13:54:22 +03:00
1 parent 07fc6c0b6c
commit 6eaf18285a
28 files changed
+1309 -648

No files matched your search

+3 -2
View File
@@ -1,7 +1,8 @@
import { PropsWithChildren } from 'react'
import useRole from '../../hooks/useRole.tsx'
import { PermissionKeys } from '../../types/roles.type.ts'
import { useRole } from '@hooks/useRole.tsx'
import { PermissionKeys } from '@type/roles.type.ts'
const AdminPermission = ({ children }: PropsWithChildren) => {
const { hasPermission } = useRole()
+6 -3
View File
@@ -1,9 +1,12 @@
import { ConfigProvider } from 'antd'
import { useState } from 'react'
import { lightTheme } from '../constants/theme.ts'
import { Context } from '../store'
import Routers from './Routers'
import { lightTheme } from '@constants/theme.ts'
import { Context } from '@stores/index.tsx'
import Routers from '@routes/Routers'
import './app.scss'
const App = () => {
+4 -2
View File
@@ -1,8 +1,10 @@
import { Segmented, theme } from 'antd'
import { useContext } from 'react'
import { darkTheme, lightTheme } from '../../constants/theme.ts'
import { Context } from '../../store'
import { darkTheme, lightTheme } from '@constants/theme.ts'
import { Context } from '@stores/index.tsx'
import './header.scss'
const options = [
+13 -7
View File
@@ -2,13 +2,19 @@ import { Menu } from 'antd'
import { useEffect, useState } from 'react'
import { Navigate, Outlet, useNavigate } from 'react-router-dom'
import { routePaths } from '../../constants/routes.ts'
import { useAppSelector } from '../../hooks/redux.ts'
import useRole from '../../hooks/useRole.tsx'
import { StateProfileStatus } from '../../redusers/ProfileSlice.ts'
import { MenuItemKeys, menuKeys } from '../../types/layout.type.ts'
import { PermissionKeys } from '../../types/roles.type.ts'
import Header from '../Header'
import Header from '@components/Header'
import { useAppSelector } from '@hooks/redux.ts'
import { useRole } from '@hooks/useRole.tsx'
import { StateProfileStatus } from '@stores/redusers/ProfileSlice.ts'
import { routePaths } from '@routes/routePaths.ts'
import { PermissionKeys } from '@type/roles.type.ts'
import { MenuItemKeys, menuKeys } from './layout.type.ts'
import './layout.scss'
const Layout = () => {
File renamed without changes.
-26
View File
@@ -1,26 +0,0 @@
import { App } from 'antd'
import { Route, Routes } from 'react-router-dom'
import HomePages from '../../pages/HomePage'
import LoginPage from '../../pages/LoginPage'
import ErrorPage from '../ErrorPage'
import Layout from '../Layout'
import PrivateRoute from '../PrivateRoute'
const Routers = () => {
return (
<App>
<Routes>
<Route element={<PrivateRoute />}>
<Route path="/" element={<Layout />}>
<Route index element={<HomePages />} />
</Route>
</Route>
<Route path="/login" element={<LoginPage />} />
<Route path="/error" element={<ErrorPage />} />
</Routes>
</App>
)
}
export default Routers
+1 -1
View File
@@ -1,6 +1,6 @@
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux'
import { AppDispatch, RootState } from '../store'
import { AppDispatch, RootState } from '../stores'
export const useAppDispatch = () => useDispatch<AppDispatch>()
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
+2 -1
View File
@@ -1,6 +1,7 @@
import { useMemo } from 'react'
import { PermissionKeys } from '../types/roles.type.ts'
import { PermissionKeys } from '@type/roles.type.ts'
import { useAppSelector } from './redux.ts'
export const useRole = () => {
+5 -3
View File
@@ -1,16 +1,18 @@
import { setupListeners } from '@reduxjs/toolkit/query'
import ReactDOM from 'react-dom/client'
import { createRoot } from 'react-dom/client'
import { Provider } from 'react-redux'
import { BrowserRouter } from 'react-router-dom'
import App from './components/App.tsx'
import './index.css'
import { setupStore } from './store'
import { setupStore } from './stores'
const store = setupStore()
setupListeners(store.dispatch)
const root = createRoot(document.getElementById('root') as HTMLElement)
ReactDOM.createRoot(document.getElementById('root')!).render(
root.render(
<Provider store={store}>
<BrowserRouter>
<App />
+4 -3
View File
@@ -1,9 +1,10 @@
import { Button, theme } from 'antd'
import useRole from '../../hooks/useRole.tsx'
import { PermissionKeys } from '../../types/roles.type.ts'
import './home.scss'
import { useRole } from '@hooks/useRole.tsx'
import { PermissionKeys } from '@type/roles.type.ts'
import './home.scss'
const HomePages = () => {
const { hasPermission } = useRole()
@@ -1,8 +1,10 @@
import { Navigate, Outlet, useLocation } from 'react-router-dom'
import { localStorageKeys } from '../../constants/localStorageKeys.ts'
import { routePaths } from '../../constants/routes.ts'
import { LocalStorage } from '../../utils/localStorageUtils.ts'
import { localStorageKeys } from '@constants/localStorageKeys.ts'
import { LocalStorage } from '@utils/localStorageUtils.ts'
import { routePaths } from '@routes/routePaths.ts'
const PrivateRoute = () => {
const location = useLocation()
+29
View File
@@ -0,0 +1,29 @@
import { App } from 'antd'
import { Route, Routes } from 'react-router-dom'
import ErrorPage from '@components/ErrorPage'
import Layout from '@components/Layout'
import HomePages from '@pages/HomePage'
import LoginPage from '@pages/LoginPage'
import PrivateRoute from '@routes/PrivateRoute'
import { routePaths } from '@routes/routePaths.ts'
const Routers = () => {
return (
<App>
<Routes>
<Route element={<PrivateRoute />}>
<Route path="/" element={<Layout />}>
<Route index element={<HomePages />} />
</Route>
</Route>
<Route path={routePaths.login} element={<LoginPage />} />
<Route path={routePaths.error} element={<ErrorPage />} />
</Routes>
</App>
)
}
export default Routers
File renamed without changes.
+8 -5
View File
@@ -1,11 +1,14 @@
import { message } from 'antd'
import axios, { AxiosError } from 'axios'
import { localStorageKeys } from '../constants/localStorageKeys.ts'
import { routePaths } from '../constants/routes.ts'
import { MSPError } from '../types'
import { getConfigProperty } from '../utils/configUtils.ts'
import { LocalStorage } from '../utils/localStorageUtils.ts'
import { localStorageKeys } from '@constants/localStorageKeys.ts'
import { getConfigProperty } from '@utils/configUtils.ts'
import { LocalStorage } from '@utils/localStorageUtils.ts'
import { routePaths } from '@routes/routePaths.ts'
import { MSPError } from '@type/index.ts'
export const apiService = axios.create({
timeout: 15000,
+1 -1
View File
@@ -3,7 +3,7 @@ import { theme } from 'antd'
import { MapToken, SeedToken } from 'antd/es/theme/interface'
import { createContext, Dispatch, SetStateAction } from 'react'
import profileReducer from '../redusers/ProfileSlice.ts'
import profileReducer from './redusers/ProfileSlice.ts'
export interface ContextProps {
setTheme: Dispatch<
@@ -1,8 +1,8 @@
import { createAsyncThunk } from '@reduxjs/toolkit'
import { apiPaths } from '../constants/api/apiPaths.ts'
import { apiService } from '../services/apiService.ts'
import { ProfileDataType } from '../types/profile.type.ts'
import { apiPaths } from '../../constants/api/apiPaths.ts'
import { apiService } from '../../services/apiService.ts'
import { ProfileDataType } from '../../type/profile.type.ts'
export const fetchProfile = createAsyncThunk(
'profile/fetchProfile',
@@ -4,7 +4,7 @@ import {
createSlice
} from '@reduxjs/toolkit'
import { ProfileDataType, ProfileType } from '../types/profile.type.ts'
import { ProfileDataType, ProfileType } from '../../type/profile.type.ts'
import { fetchProfile } from './ActionCreators.ts'
export enum StateProfileStatus {
File renamed without changes.
@@ -1,4 +1,4 @@
import { StateProfileStatus } from '../redusers/ProfileSlice.ts'
import { StateProfileStatus } from '../stores/redusers/ProfileSlice.ts'
export type ProfileDataType = {
email: string
File renamed without changes.