add project structure
This commit is contained in:
1 parent
07fc6c0b6c
commit
6eaf18285a
28 files changed
+1309
-648
No files matched your search
@@ -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()
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -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.
@@ -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
@@ -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
|
||||
@@ -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
@@ -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 />
|
||||
|
||||
@@ -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()
|
||||
@@ -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.
@@ -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,
|
||||
|
||||
@@ -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.
Reference in new issue
Block a user