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

+4
View File
@@ -0,0 +1,4 @@
node_modules/
tsconfig.json
public/config.js
vite.config.ts
+70
View File
@@ -0,0 +1,70 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript"
],
"ignorePatterns": ["node_modules", "build"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json",
"tsconfigRootDir": "./"
},
"plugins": [
"react",
"import",
"@typescript-eslint",
"react-hooks",
"prettier"
],
"rules": {
"import/no-named-as-default":"off",
"prettier/prettier": "error",
"quotes": ["error", "single"],
"react/jsx-filename-extension": [
1,
{
"extensions": [".js", ".jsx", ".tsx"]
}
],
"react/prop-types": 0,
"react/react-in-jsx-scope": "off",
"semi": ["error", "never"],
"@typescript-eslint/no-unused-vars": ["off"],
"@typescript-eslint/no-explicit-any": ["off", null],
"@typescript-eslint/no-non-null-assertion": ["off"],
"import/no-unresolved": "error",
"no-unused-vars": "off"
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"react": {
"version": "detect"
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
},
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"],
"moduleDirectory": ["node_modules", "src/"]
}
}
}
}
+9 -5
View File
@@ -21,18 +21,22 @@
],
"importOrder": [
"^@core/(.*)$",
"^@assets/(.*)$",
"^@constants/(.*)$",
"^@ui/(.*)$",
"^@components/(.*)$",
"^@widgets/(.*)$",
"^@components/(.*)$",
"^@modules/(.*)$",
"^@pages/(.*)$",
"^@utils/(.*)$",
"^@hooks/(.*)$",
"^@assets/(.*)$",
"^@api/(.*)$",
"^@store/(.*)$",
"^@services/(.*)$",
"^@stores/(.*)$",
"^@routes/(.*)$",
"^@type/(.*)$",
"^./*.*.ts",
"^[./]",
".(scss|css)$"
"^./*.*.(scss|css)"
],
"importOrderSeparation": true
}
+1 -1
View File
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
+24 -23
View File
@@ -14,7 +14,7 @@
"prepare": "husky install"
},
"dependencies": {
"@reduxjs/toolkit": "^2.2.2",
"@reduxjs/toolkit": "^2.2.3",
"@types/react-router-dom": "^5.3.3",
"axios": "^1.6.8",
"isp-ui-kit": "https://github.com/integration-system/isp-ui-kit.git",
@@ -25,31 +25,32 @@
},
"devDependencies": {
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.11.24",
"@types/react": "^18.2.56",
"@types/react-dom": "^18.2.19",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-react": "^4.1.1",
"@vitejs/plugin-react-swc": "^3.5.0",
"antd": "5.15.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"@types/node": "^20.12.4",
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"@vitejs/plugin-legacy": "^5.3.2",
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react-swc": "^3.6.0",
"antd": "5.16.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"husky": "^8.0.0",
"prettier": "^2.8.7",
"sass": "^1.71.1",
"terser": "^5.28.1",
"typescript": "^5.2.2",
"vite": "^5.1.4",
"eslint-plugin-react-refresh": "^0.4.6",
"husky": "^9.0.11",
"prettier": "^3.2.5",
"sass": "^1.74.1",
"terser": "^5.30.3",
"typescript": "^5.4.3",
"vite": "^5.2.8",
"vite-plugin-style-import": "^2.0.0",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.2.3"
"vite-tsconfig-paths": "^4.3.2"
},
"eslintConfig": {
"extends": [
+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.
+17 -1
View File
@@ -19,7 +19,23 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"typeRoots": ["./node_modules/@types", "./src/types"]
"baseUrl": ".",
"paths": {
"@assets/*": ["src/assets/*"],
"@constants/*": ["src/constants/*"],
"@ui/*": ["src/ui/*"],
"@widgets/*": ["src/widgets/*"],
"@components/*": ["src/components/*"],
"@modules/*": ["src/modules/*"],
"@hooks/*": ["src/hooks/*"],
"@pages/*": ["src/pages/*"],
"@services/*": ["src/services/*"],
"@stores/*": ["src/stores/*"],
"@type/*": ["src/type/*"],
"@utils/*": ["src/utils/*"],
"@routes/*": ["src/routes/*"]
},
"allowSyntheticDefaultImports": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
+7 -20
View File
@@ -1,7 +1,8 @@
import legacy from '@vitejs/plugin-legacy'
import react from '@vitejs/plugin-react'
import path from 'path'
import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import svgr from 'vite-plugin-svgr'
import tsconfigPaths from 'vite-tsconfig-paths'
// https://vitejs.dev/config/
@@ -14,16 +15,7 @@ export default defineConfig(({ mode }) => {
},
build: {
minify: 'terser',
outDir: 'build',
sourcemap: false,
chunkSizeWarningLimit: 200,
rollupOptions: {
output: {
manualChunks(id: string) {
return 'vendor'
}
}
}
outDir: 'build'
},
server: {
watch: {
@@ -31,16 +23,11 @@ export default defineConfig(({ mode }) => {
},
host: true,
strictPort: true,
port: 8070,
port: 8000,
proxy: {
'/api': 'https://land.mos.ru/'
'/api': env.PROXY_URL
}
},
plugins: [react(), svgr(), tsconfigPaths(), splitVendorChunkPlugin()],
resolve: {
alias: {
'@styles': path.resolve(__dirname, './src/styles')
}
}
plugins: [react(), svgr(), legacy(), tsconfigPaths()]
}
})
+1091 -536
View File
File diff suppressed because it is too large. Load diff