From fe41e1e45aecae9f479bafa9a58acd1ce7e88c43 Mon Sep 17 00:00:00 2001 From: HasanMu Date: Thu, 13 Feb 2025 09:10:10 +0700 Subject: [PATCH] fix: unused import / params for build --- .env.example | 2 +- package-lock.json | 141 ++++++++++++++++++++++++++++-- package.json | 3 + src/components/IconButton.tsx | 2 - src/components/ReactTable.tsx | 5 +- src/layouts/Dashboard/Header.tsx | 2 - src/layouts/Dashboard/Sidebar.tsx | 1 - src/pages/Backbone.tsx | 2 - src/pages/Devices.tsx | 1 - src/pages/Fishbone.tsx | 1 - src/pages/Towers.tsx | 1 - src/pages/auth/Login.tsx | 1 - src/stores/authStore.ts | 5 +- src/stores/storage.ts | 15 ++-- src/theme/components/Switch.ts | 8 +- src/theme/index.tsx | 4 +- src/theme/typography.ts | 6 +- 17 files changed, 155 insertions(+), 45 deletions(-) diff --git a/.env.example b/.env.example index 8f419ab..5643237 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,2 @@ VITE_API_URL="http://localhost:8000" -VITE_APP_KEY="123456" \ No newline at end of file +VITE_APP_KEY="4ae931db63f0d18f5082781be5e2c622" \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c233d37..1431b5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@emotion/styled": "^11.14.0", "@fontsource/public-sans": "^5.1.2", "@mui/icons-material": "^6.4.3", + "@mui/lab": "^6.0.0-beta.27", "@mui/material": "^6.4.3", "@tanstack/react-table": "^8.21.2", "axios": "^1.7.9", @@ -26,6 +27,8 @@ }, "devDependencies": { "@eslint/js": "^9.19.0", + "@types/crypto-js": "^4.2.2", + "@types/lodash": "^4.17.15", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", @@ -997,6 +1000,40 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@floating-ui/core": { + "version": "1.6.9", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.9.tgz", + "integrity": "sha512-uMXCuQ3BItDUbAMhIXw7UPXRfAlOAvZzdK9BWpE60MCn+Svt3aLn9jsPTi/WNGlRUu2uI0v5S7JiIUsbsvh3fw==", + "dependencies": { + "@floating-ui/utils": "^0.2.9" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.13.tgz", + "integrity": "sha512-umqzocjDgNRGTuO7Q8CU32dkHkECqI8ZdMZ5Swb6QAM0t5rnlrN3lGo1hdpscRd3WS8T6DKYK4ephgIH9iRh3w==", + "dependencies": { + "@floating-ui/core": "^1.6.0", + "@floating-ui/utils": "^0.2.9" + } + }, + "node_modules/@floating-ui/react-dom": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.2.tgz", + "integrity": "sha512-06okr5cgPzMNBy+Ycse2A6udMi4bqwW/zgBF/rwjcNqWkyr82Mcg8b0vjX8OJpZFy/FKjJmw6wV7t44kK6kW7A==", + "dependencies": { + "@floating-ui/dom": "^1.0.0" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.9", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.9.tgz", + "integrity": "sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==" + }, "node_modules/@fontsource/public-sans": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@fontsource/public-sans/-/public-sans-5.1.2.tgz", @@ -1106,10 +1143,42 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@mui/base": { + "version": "5.0.0-beta.69", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.69.tgz", + "integrity": "sha512-r2YyGUXpZxj8rLAlbjp1x2BnMERTZ/dMqd9cClKj2OJ7ALAuiv/9X5E9eHfRc9o/dGRuLSMq/WTjREktJVjxVA==", + "deprecated": "This package has been replaced by @base-ui-components/react", + "dependencies": { + "@babel/runtime": "^7.26.0", + "@floating-ui/react-dom": "^2.1.1", + "@mui/types": "^7.2.21", + "@mui/utils": "^6.4.1", + "@popperjs/core": "^2.11.8", + "clsx": "^2.1.1", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@mui/core-downloads-tracker": { - "version": "6.4.3", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-6.4.3.tgz", - "integrity": "sha512-hlyOzo2ObarllAOeT1ZSAusADE5NZNencUeIvXrdQ1Na+FL1lcznhbxfV5He1KqGiuR8Az3xtCUcYKwMVGFdzg==", + "version": "6.4.4", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-6.4.4.tgz", + "integrity": "sha512-r+J0EditrekkTtO2CnCBCOGpNaDYwJqz8lH4rj6o/anDcskZFJodBlG8aCJkS8DL/CF/9EHS+Gz53EbmYEnQbw==", "funding": { "type": "opencollective", "url": "https://opencollective.com/mui-org" @@ -1140,13 +1209,57 @@ } } }, - "node_modules/@mui/material": { - "version": "6.4.3", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-6.4.3.tgz", - "integrity": "sha512-ubtQjplbWneIEU8Y+4b2VA0CDBlyH5I3AmVFGmsLyDe/bf0ubxav5t11c8Afem6rkSFWPlZA2DilxmGka1xiKQ==", + "node_modules/@mui/lab": { + "version": "6.0.0-beta.27", + "resolved": "https://registry.npmjs.org/@mui/lab/-/lab-6.0.0-beta.27.tgz", + "integrity": "sha512-weLxPsCs2wJKgWKf46shXHE+x7qlf5VxMK3P+4HsWasMakV/uTmxsoT7PG3QCvakGQ2TdpZtQLE2umJKC0mvKQ==", "dependencies": { "@babel/runtime": "^7.26.0", - "@mui/core-downloads-tracker": "^6.4.3", + "@mui/base": "5.0.0-beta.69", + "@mui/system": "^6.4.3", + "@mui/types": "^7.2.21", + "@mui/utils": "^6.4.3", + "clsx": "^2.1.1", + "prop-types": "^15.8.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@emotion/react": "^11.5.0", + "@emotion/styled": "^11.3.0", + "@mui/material": "^6.4.4", + "@mui/material-pigment-css": "^6.4.3", + "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@emotion/react": { + "optional": true + }, + "@emotion/styled": { + "optional": true + }, + "@mui/material-pigment-css": { + "optional": true + }, + "@types/react": { + "optional": true + } + } + }, + "node_modules/@mui/material": { + "version": "6.4.4", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-6.4.4.tgz", + "integrity": "sha512-ISVPrIsPQsxnwvS40C4u03AuNSPigFeS2+n1qpuEZ94hDsdMi19dQM2JcC9CHEhXecSIQjP1RTyY0mPiSpSrFQ==", + "dependencies": { + "@babel/runtime": "^7.26.0", + "@mui/core-downloads-tracker": "^6.4.4", "@mui/system": "^6.4.3", "@mui/types": "^7.2.21", "@mui/utils": "^6.4.3", @@ -1706,6 +1819,12 @@ "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==" }, + "node_modules/@types/crypto-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/crypto-js/-/crypto-js-4.2.2.tgz", + "integrity": "sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==", + "dev": true + }, "node_modules/@types/estree": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", @@ -1724,6 +1843,12 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-w/P33JFeySuhN6JLkysYUK2gEmy9kHHFN7E8ro0tkfmlDOgxBDzWEZ/J8cWA+fHqFevpswDTFZnDx+R9lbL6xw==", + "dev": true + }, "node_modules/@types/parse-json": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz", diff --git a/package.json b/package.json index d0f9be6..3fb4cf2 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@emotion/styled": "^11.14.0", "@fontsource/public-sans": "^5.1.2", "@mui/icons-material": "^6.4.3", + "@mui/lab": "^6.0.0-beta.27", "@mui/material": "^6.4.3", "@tanstack/react-table": "^8.21.2", "axios": "^1.7.9", @@ -28,6 +29,8 @@ }, "devDependencies": { "@eslint/js": "^9.19.0", + "@types/crypto-js": "^4.2.2", + "@types/lodash": "^4.17.15", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^4.3.4", diff --git a/src/components/IconButton.tsx b/src/components/IconButton.tsx index 6a4ad30..b7ccc7e 100644 --- a/src/components/IconButton.tsx +++ b/src/components/IconButton.tsx @@ -36,8 +36,6 @@ function getColorStyle({ variant, theme, color }: IconButtonStyleProps) { outlineOffset: 2 } }; - - console.log(main); switch (variant) { case 'contained': diff --git a/src/components/ReactTable.tsx b/src/components/ReactTable.tsx index 5a03880..114cb16 100644 --- a/src/components/ReactTable.tsx +++ b/src/components/ReactTable.tsx @@ -28,14 +28,12 @@ interface ReactTableProps { columns: ColumnDef[]; data: T[]; striped?: boolean; - title?: string; } function ComponentReactTable({ columns, data, striped, - title, }: ReactTableProps) { const [sorting, setSorting] = useState([]); const [columnFilters, setColumnFilters] = useState([]); @@ -135,9 +133,8 @@ function ComponentReactTable({ export default function ReactTable({ striped, - title, data, columns, }: ReactTableProps) { - return ; + return ; } diff --git a/src/layouts/Dashboard/Header.tsx b/src/layouts/Dashboard/Header.tsx index 1b1d165..3958502 100644 --- a/src/layouts/Dashboard/Header.tsx +++ b/src/layouts/Dashboard/Header.tsx @@ -5,8 +5,6 @@ import Menu from "@mui/material/Menu"; import MenuItem from "@mui/material/MenuItem"; import IconButton from "@mui/material/IconButton"; import MenuIcon from "@mui/icons-material/Menu"; -import Avatar from "@mui/material/Avatar"; -import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; import React from "react"; import { useNavigate } from "react-router"; diff --git a/src/layouts/Dashboard/Sidebar.tsx b/src/layouts/Dashboard/Sidebar.tsx index a62e1ef..44dc6df 100644 --- a/src/layouts/Dashboard/Sidebar.tsx +++ b/src/layouts/Dashboard/Sidebar.tsx @@ -1,6 +1,5 @@ import Drawer from "@mui/material/Drawer"; import Toolbar from "@mui/material/Toolbar"; -import Divider from "@mui/material/Divider"; import List from "@mui/material/List"; import ListItem from "@mui/material/ListItem"; import ListSubheader from "@mui/material/ListSubheader"; diff --git a/src/pages/Backbone.tsx b/src/pages/Backbone.tsx index dddfea1..a4c184f 100644 --- a/src/pages/Backbone.tsx +++ b/src/pages/Backbone.tsx @@ -89,8 +89,6 @@ export default function Backbone() { diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx index 19999cb..d8d7168 100644 --- a/src/pages/Devices.tsx +++ b/src/pages/Devices.tsx @@ -102,7 +102,6 @@ export default function Devices() { diff --git a/src/pages/Fishbone.tsx b/src/pages/Fishbone.tsx index 3495213..dcb63a4 100644 --- a/src/pages/Fishbone.tsx +++ b/src/pages/Fishbone.tsx @@ -84,7 +84,6 @@ export default function Fishbone() { diff --git a/src/pages/Towers.tsx b/src/pages/Towers.tsx index 47ccb63..4cf51c5 100644 --- a/src/pages/Towers.tsx +++ b/src/pages/Towers.tsx @@ -87,7 +87,6 @@ export default function Towers() { diff --git a/src/pages/auth/Login.tsx b/src/pages/auth/Login.tsx index 5dbc6ea..a8f4d93 100644 --- a/src/pages/auth/Login.tsx +++ b/src/pages/auth/Login.tsx @@ -5,7 +5,6 @@ import Card from "@mui/material/Card"; import FormControlLabel from "@mui/material/FormControlLabel"; import Checkbox from "@mui/material/Checkbox"; import Typography from "@mui/material/Typography"; -import Link from "@mui/material/Link"; import Grid from "@mui/material/Grid2"; import { useNavigate } from "react-router"; import { useAuthStore } from "../../stores/authStore"; diff --git a/src/stores/authStore.ts b/src/stores/authStore.ts index 24c5e9c..42a7823 100644 --- a/src/stores/authStore.ts +++ b/src/stores/authStore.ts @@ -6,12 +6,11 @@ import { createJSONStorage } from 'zustand/middleware'; import { secureStorage } from './storage'; type PersistedAuthState = Pick; -console.log(import.meta.env); export const useAuthStore = create()( persist( - (set, get) => ({ - token: null, + (set) => ({ + token: null, user: null, isLoading: false, error: null, diff --git a/src/stores/storage.ts b/src/stores/storage.ts index acd2bce..3c76413 100644 --- a/src/stores/storage.ts +++ b/src/stores/storage.ts @@ -1,25 +1,22 @@ -import CryptoJS from "crypto-js"; import { StateStorage } from "zustand/middleware"; +const KEY = import.meta.env.VITE_APP_KEY; + export const secureStorage: StateStorage = { getItem: (name: string): string | null => { const data = localStorage.getItem(name); if (!data) return null; try { - const decrypted = CryptoJS.AES.decrypt( - data, - import.meta.env.VITE_APP_KEY - ).toString(CryptoJS.enc.Utf8); + const decrypted = CryptoJS.AES.decrypt(data, KEY).toString( + CryptoJS.enc.Utf8 + ); return decrypted || null; } catch { return null; } }, setItem: (name: string, value: string): void => { - const encrypted = CryptoJS.AES.encrypt( - value, - import.meta.env.VITE_APP_KEY - ).toString(); + const encrypted = CryptoJS.AES.encrypt(value, KEY).toString(); localStorage.setItem(name, encrypted); }, removeItem: (name: string): void => { diff --git a/src/theme/components/Switch.ts b/src/theme/components/Switch.ts index 3ef9b54..81bc792 100644 --- a/src/theme/components/Switch.ts +++ b/src/theme/components/Switch.ts @@ -24,7 +24,7 @@ function getSizeStyle(size?: SwitchProps['size']): SwitchSizeProps { } } -function switchStyle(theme: Theme, size?: SwitchProps['size']) { +function switchStyle(size?: SwitchProps['size']) { const sizes: SwitchSizeProps = getSizeStyle(size); return { @@ -88,11 +88,11 @@ export default function Switch(theme: Theme) { '& ~ .MuiFormControlLabel-label': { margin: 6 }, - ...switchStyle(theme, 'medium') + ...switchStyle('medium') }, - sizeLarge: { ...switchStyle(theme, 'large') }, + sizeLarge: { ...switchStyle('large') }, sizeSmall: { - ...switchStyle(theme, 'small') + ...switchStyle('small') } } } diff --git a/src/theme/index.tsx b/src/theme/index.tsx index b7a8f9f..394f373 100644 --- a/src/theme/index.tsx +++ b/src/theme/index.tsx @@ -50,9 +50,9 @@ export default function ThemeCustomization({ const themeTypography: TypographyVariantsOptions = useMemo( - () => Typography(themeMode, fontFamily, theme), + () => Typography(fontFamily), // eslint-disable-next-line react-hooks/exhaustive-deps - [themeMode, fontFamily] + [fontFamily] ); const themeCustomShadows: CustomShadowProps = useMemo( () => CustomShadows(theme), diff --git a/src/theme/typography.ts b/src/theme/typography.ts index 6c17ca0..00cd930 100644 --- a/src/theme/typography.ts +++ b/src/theme/typography.ts @@ -1,10 +1,10 @@ // MATERIAL - UI -import { Theme, TypographyVariantsOptions } from '@mui/material/styles'; -import { FontFamily, ThemeMode } from '../types/config'; +import { TypographyVariantsOptions } from '@mui/material'; +import { FontFamily } from '../types/config'; // ==============================|| DEFAULT THEME - TYPOGRAPHY ||============================== // -const Typography = (mode: ThemeMode, fontFamily: FontFamily, theme: Theme): TypographyVariantsOptions => ({ +const Typography = (fontFamily: FontFamily): TypographyVariantsOptions => ({ htmlFontSize: 16, fontFamily, fontWeightLight: 300,