diff --git a/src/index.tsx b/src/index.tsx
index 218d64f..99f5b6d 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -36,7 +36,7 @@ const componentsArray = [
["/promocode", ],
["/support", ],
["/support/:ticketId", ],
-];
+] as const;
const container = document.getElementById("root");
const root = createRoot(container!);
@@ -103,8 +103,8 @@ root.render(
}
/>
- {componentsArray.map((element: any) => (
-
+ {componentsArray.map((element) => (
+
))}
diff --git a/src/kitUI/privateRoute.tsx b/src/kitUI/privateRoute.tsx
index 8b0db86..e59e659 100644
--- a/src/kitUI/privateRoute.tsx
+++ b/src/kitUI/privateRoute.tsx
@@ -2,7 +2,11 @@ import { useToken } from "@frontend/kitui";
import * as React from "react";
import { useLocation, Navigate } from "react-router-dom";
-export default ({ children }: any) => {
+interface Props {
+ children: JSX.Element;
+}
+
+export default function PrivateRoute({ children }: Props) {
const token = useToken();
const location = useLocation();
//Если пользователь авторизован, перенаправляем его на нужный путь. Иначе выкидываем в регистрацию
diff --git a/src/kitUI/publicRoute.tsx b/src/kitUI/publicRoute.tsx
index 5759210..e6c1878 100644
--- a/src/kitUI/publicRoute.tsx
+++ b/src/kitUI/publicRoute.tsx
@@ -2,7 +2,12 @@ import { useLocation, Navigate } from "react-router-dom";
import { useToken } from "@frontend/kitui";
-const PublicRoute = ({ children }: any) => {
+
+interface Props {
+ children: JSX.Element;
+}
+
+const PublicRoute = ({ children }: Props) => {
const location = useLocation();
const token = useToken();
diff --git a/src/pages/Setting/CardPrivilegie.tsx b/src/pages/Setting/CardPrivilegie.tsx
index 6927870..09a81df 100644
--- a/src/pages/Setting/CardPrivilegie.tsx
+++ b/src/pages/Setting/CardPrivilegie.tsx
@@ -1,4 +1,4 @@
-import { useRef, useState } from "react";
+import { KeyboardEvent, useRef, useState } from "react";
import { enqueueSnackbar } from "notistack";
import { Box, IconButton, TextField, Tooltip, Typography } from "@mui/material";
import ModeEditOutlineOutlinedIcon from "@mui/icons-material/ModeEditOutlineOutlined";
@@ -17,7 +17,7 @@ const baseUrl =
export const СardPrivilegie = ({ privilege }: CardPrivilegie) => {
const [inputOpen, setInputOpen] = useState(false);
const [inputValue, setInputValue] = useState("");
- const priceRef = useRef(null);
+ const priceRef = useRef(null);
const translationType = {
count: "за единицу",
@@ -41,6 +41,8 @@ export const СardPrivilegie = ({ privilege }: CardPrivilegie) => {
},
})
.then(() => {
+ if (!priceRef.current) return;
+
priceRef.current.innerText = "price: " + inputValue;
setInputValue("");
setInputOpen(false);
@@ -50,19 +52,16 @@ export const СardPrivilegie = ({ privilege }: CardPrivilegie) => {
});
};
- const requestOnclickEnter = (event: any) => {
+ const onTextfieldKeyDown = (event: KeyboardEvent) => {
+ if (event.key === "Escape") {
+ return setInputOpen(false);
+ }
if (event.key === "Enter" && inputValue !== "") {
PutPrivilegies();
setInputOpen(false);
}
};
- const onCloseInput = (event: any) => {
- if (event.key === "Escape") {
- setInputOpen(false);
- }
- };
-
return (
{
{inputOpen ? (
setInputValue(event.target.value)}
diff --git a/src/pages/dashboard/Content/ServiceUsersDG.tsx b/src/pages/dashboard/Content/ServiceUsersDG.tsx
index c851255..ec808c5 100644
--- a/src/pages/dashboard/Content/ServiceUsersDG.tsx
+++ b/src/pages/dashboard/Content/ServiceUsersDG.tsx
@@ -6,50 +6,41 @@ import DataGrid from "@kitUI/datagrid";
import type { UserType } from "@root/api/roles";
-const columns: GridColDef[] = [
- { field: "login", headerName: "Логин", width: 100 },
- { field: "email", headerName: "E-mail", width: 200 },
- { field: "phoneNumber", headerName: "Номер телефона", width: 200 },
- { field: "isDeleted", headerName: "Удалено", width: 100 },
- { field: "createdAt", headerName: "Дата создания", width: 200 },
+const columns: GridColDef[] = [
+ { field: "login", headerName: "Логин", width: 200, valueGetter: ({ row }) => row.login, },
+ { field: "email", headerName: "E-mail", width: 200, valueGetter: ({ row }) => row.email, },
+ { field: "phoneNumber", headerName: "Номер телефона", width: 200, valueGetter: ({ row }) => row.phoneNumber, },
+ { field: "isDeleted", headerName: "Удалено", width: 100, valueGetter: ({ row }) => `${row.isDeleted ? "true" : "false"}`, },
+ { field: "createdAt", headerName: "Дата создания", width: 200, valueGetter: ({ row }) => row.createdAt, },
];
interface Props {
- handleSelectionChange: (selectionModel: GridSelectionModel) => void;
- users: UserType[];
+ handleSelectionChange: (selectionModel: GridSelectionModel) => void;
+ users: UserType[];
}
export default function ServiceUsersDG({
- handleSelectionChange,
- users = [],
+ handleSelectionChange,
+ users = [],
}: Props) {
- const navigate = useNavigate();
+ const navigate = useNavigate();
- const gridData = users.map((user) => ({
- id: user._id,
- login: user.login,
- email: user.email,
- phoneNumber: user.phoneNumber,
- isDeleted: `${user.isDeleted ? "true" : "false"}`,
- createdAt: user.createdAt,
- }));
-
- return (
- <>
- {users.length ? (
- users.login}
- checkboxSelection={true}
- rows={gridData}
- columns={columns}
- components={{ Toolbar: GridToolbar }}
- onSelectionModelChange={handleSelectionChange}
- onRowClick={({ row }) => navigate(row.id)}
- />
- ) : (
- Loading...
- )}
- >
- );
+ return (
+ <>
+ {users.length ? (
+ users._id}
+ checkboxSelection={true}
+ rows={users}
+ columns={columns}
+ components={{ Toolbar: GridToolbar }}
+ onSelectionModelChange={handleSelectionChange}
+ onRowClick={({ row }) => navigate(row.id)}
+ />
+ ) : (
+ Loading...
+ )}
+ >
+ );
}
diff --git a/src/pages/dashboard/Content/Support/Chat/Chat.tsx b/src/pages/dashboard/Content/Support/Chat/Chat.tsx
index 2347a48..6db5467 100644
--- a/src/pages/dashboard/Content/Support/Chat/Chat.tsx
+++ b/src/pages/dashboard/Content/Support/Chat/Chat.tsx
@@ -9,8 +9,7 @@ import { TicketMessage } from "@root/model/ticket";
import { sendTicketMessage } from "@root/api/tickets";
import { enqueueSnackbar } from "notistack";
import { useTicketStore } from "@root/stores/tickets";
-import { throttle } from "@root/utils/throttle";
-import { getMessageFromFetchError, useEventListener, useSSESubscription, useTicketMessages, useToken } from "@frontend/kitui";
+import { getMessageFromFetchError, throttle, useEventListener, useSSESubscription, useTicketMessages, useToken } from "@frontend/kitui";
export default function Chat() {
diff --git a/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx b/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx
index b871701..7d92abf 100644
--- a/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx
+++ b/src/pages/dashboard/Content/Support/TicketList/TicketList.tsx
@@ -3,9 +3,9 @@ import SearchOutlinedIcon from '@mui/icons-material/SearchOutlined';
import { Box, Button, useMediaQuery, useTheme } from "@mui/material";
import { Ticket } from "@root/model/ticket";
import { incrementTicketsApiPage, useTicketStore } from "@root/stores/tickets";
-import { throttle } from '@root/utils/throttle';
import { useEffect, useRef } from "react";
import TicketItem from "./TicketItem";
+import { throttle } from '@frontend/kitui';
export default function TicketList() {
diff --git a/src/pages/dashboard/Menu/index.tsx b/src/pages/dashboard/Menu/index.tsx
index 04e93cf..e9c55db 100644
--- a/src/pages/dashboard/Menu/index.tsx
+++ b/src/pages/dashboard/Menu/index.tsx
@@ -110,7 +110,12 @@ const links: { path: string; element: JSX.Element; title: string; className: str
{ path: "/support", element: , title: "Служба поддержки", className: "menu" },
];
-const Navigation = (props: any) => {
+interface Props {
+ visible: boolean;
+ SladeMobileHC?: () => void;
+}
+
+const Navigation = (props: Props) => {
return (
void;
- onError?: (error: any) => void;
+ onError?: (error: unknown) => void;
}) {
useEffect(() => {
const controller = new AbortController();
diff --git a/src/utils/throttle.ts b/src/utils/throttle.ts
deleted file mode 100644
index 64a8c25..0000000
--- a/src/utils/throttle.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-type ThrottledFunction any> = (...args: Parameters) => void;
-
-export function throttle any>(func: T, ms: number): ThrottledFunction {
- let isThrottled = false;
- let savedArgs: Parameters | null;
- let savedThis: any;
-
- function wrapper(this: any, ...args: Parameters) {
- if (isThrottled) {
- savedArgs = args;
- savedThis = this;
- return;
- }
-
- func.apply(this, args);
-
- isThrottled = true;
-
- setTimeout(function () {
- isThrottled = false;
- if (savedArgs) {
- wrapper.apply(savedThis, savedArgs);
- savedArgs = savedThis = null;
- }
- }, ms);
- }
-
- return wrapper;
-}
\ No newline at end of file