fix unnecessary any
This commit is contained in:
parent
be06d61933
commit
490f0c0480
@ -36,7 +36,7 @@ const componentsArray = [
|
||||
["/promocode", <PromocodeManagement />],
|
||||
["/support", <Support />],
|
||||
["/support/:ticketId", <Support />],
|
||||
];
|
||||
] as const;
|
||||
|
||||
const container = document.getElementById("root");
|
||||
const root = createRoot(container!);
|
||||
@ -103,8 +103,8 @@ root.render(
|
||||
</PrivateRoute>
|
||||
}
|
||||
/>
|
||||
{componentsArray.map((element: any) => (
|
||||
<Route key={element} path={element[0]} element={element[1]} />
|
||||
{componentsArray.map((element) => (
|
||||
<Route key={element[0]} path={element[0]} element={element[1]} />
|
||||
))}
|
||||
</Route>
|
||||
|
||||
|
||||
@ -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();
|
||||
//Если пользователь авторизован, перенаправляем его на нужный путь. Иначе выкидываем в регистрацию
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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<boolean>(false);
|
||||
const [inputValue, setInputValue] = useState<string>("");
|
||||
const priceRef = useRef<any>(null);
|
||||
const priceRef = useRef<HTMLDivElement>(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 (
|
||||
<Box
|
||||
key={privilege.type}
|
||||
@ -130,8 +129,7 @@ export const СardPrivilegie = ({ privilege }: CardPrivilegie) => {
|
||||
{inputOpen ? (
|
||||
<TextField
|
||||
type="number"
|
||||
onKeyDown={onCloseInput}
|
||||
onKeyPress={requestOnclickEnter}
|
||||
onKeyDown={onTextfieldKeyDown}
|
||||
placeholder="введите число"
|
||||
fullWidth
|
||||
onChange={(event) => setInputValue(event.target.value)}
|
||||
|
||||
@ -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<UserType, string>[] = [
|
||||
{ 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 ? (
|
||||
<DataGrid
|
||||
sx={{ maxWidth: "90%", mt: "30px" }}
|
||||
getRowId={(users: any) => users.login}
|
||||
checkboxSelection={true}
|
||||
rows={gridData}
|
||||
columns={columns}
|
||||
components={{ Toolbar: GridToolbar }}
|
||||
onSelectionModelChange={handleSelectionChange}
|
||||
onRowClick={({ row }) => navigate(row.id)}
|
||||
/>
|
||||
) : (
|
||||
<Skeleton>Loading...</Skeleton>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
{users.length ? (
|
||||
<DataGrid
|
||||
sx={{ maxWidth: "90%", mt: "30px" }}
|
||||
getRowId={(users) => users._id}
|
||||
checkboxSelection={true}
|
||||
rows={users}
|
||||
columns={columns}
|
||||
components={{ Toolbar: GridToolbar }}
|
||||
onSelectionModelChange={handleSelectionChange}
|
||||
onRowClick={({ row }) => navigate(row.id)}
|
||||
/>
|
||||
) : (
|
||||
<Skeleton>Loading...</Skeleton>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -110,7 +110,12 @@ const links: { path: string; element: JSX.Element; title: string; className: str
|
||||
{ path: "/support", element: <HeadsetMicOutlinedIcon />, title: "Служба поддержки", className: "menu" },
|
||||
];
|
||||
|
||||
const Navigation = (props: any) => {
|
||||
interface Props {
|
||||
visible: boolean;
|
||||
SladeMobileHC?: () => void;
|
||||
}
|
||||
|
||||
const Navigation = (props: Props) => {
|
||||
return (
|
||||
<List
|
||||
sx={{
|
||||
|
||||
@ -4,7 +4,7 @@ import { useEffect } from "react";
|
||||
|
||||
export default function usePrivileges({ onError, onNewPrivileges }: {
|
||||
onNewPrivileges: (response: PrivilegeWithAmount[]) => void;
|
||||
onError?: (error: any) => void;
|
||||
onError?: (error: unknown) => void;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
|
||||
|
||||
type ThrottledFunction<T extends (...args: any) => any> = (...args: Parameters<T>) => void;
|
||||
|
||||
export function throttle<T extends (...args: any) => any>(func: T, ms: number): ThrottledFunction<T> {
|
||||
let isThrottled = false;
|
||||
let savedArgs: Parameters<T> | null;
|
||||
let savedThis: any;
|
||||
|
||||
function wrapper(this: any, ...args: Parameters<T>) {
|
||||
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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user