mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
FC removal
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { useContext, useEffect } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
@@ -14,7 +13,7 @@ interface SecurityRedirectProps {
|
||||
signOut?: boolean;
|
||||
}
|
||||
|
||||
const RootRedirect: FC<SecurityRedirectProps> = ({ message, signOut }) => {
|
||||
const RootRedirect = ({ message, signOut }: SecurityRedirectProps) => {
|
||||
const authenticationContext = useContext(AuthenticationContext);
|
||||
useEffect(() => {
|
||||
signOut && authenticationContext.signOut(false);
|
||||
@@ -23,26 +22,11 @@ const RootRedirect: FC<SecurityRedirectProps> = ({ message, signOut }) => {
|
||||
return <Navigate to="/" />;
|
||||
};
|
||||
|
||||
export const RemoveTrailingSlashes = () => {
|
||||
const location = useLocation();
|
||||
return (
|
||||
location.pathname.match('/.*/$') && (
|
||||
<Navigate
|
||||
to={{
|
||||
pathname: location.pathname.replace(/\/+$/, ''),
|
||||
search: location.search
|
||||
}}
|
||||
/>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const AppRouting = () => {
|
||||
export default function AppRouting() {
|
||||
const { LL } = useI18nContext();
|
||||
|
||||
return (
|
||||
<Authentication>
|
||||
<RemoveTrailingSlashes />
|
||||
<Routes>
|
||||
<Route
|
||||
path="/unauthorized"
|
||||
@@ -71,6 +55,4 @@ const AppRouting = () => {
|
||||
</Routes>
|
||||
</Authentication>
|
||||
);
|
||||
};
|
||||
|
||||
export default AppRouting;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { FC } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
|
||||
import { ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
|
||||
@@ -13,12 +12,12 @@ interface LayoutMenuItemProps {
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const LayoutMenuItem: FC<LayoutMenuItemProps> = ({
|
||||
const LayoutMenuItem = ({
|
||||
icon: Icon,
|
||||
label,
|
||||
to,
|
||||
disabled
|
||||
}) => {
|
||||
}: LayoutMenuItemProps) => {
|
||||
const { pathname } = useLocation();
|
||||
|
||||
const selected = routeMatches(to, pathname);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { FC } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import NavigateNextIcon from '@mui/icons-material/NavigateNext';
|
||||
@@ -34,14 +33,14 @@ function RenderIcon({ icon: Icon, bgcolor, label, text }: ListMenuItemProps) {
|
||||
);
|
||||
}
|
||||
|
||||
const LayoutMenuItem: FC<ListMenuItemProps> = ({
|
||||
const LayoutMenuItem = ({
|
||||
icon,
|
||||
bgcolor,
|
||||
label,
|
||||
text,
|
||||
to,
|
||||
disabled
|
||||
}) => (
|
||||
}: ListMenuItemProps) => (
|
||||
<>
|
||||
{to && !disabled ? (
|
||||
<ListItem
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { FC } from 'react';
|
||||
|
||||
import RefreshIcon from '@mui/icons-material/Refresh';
|
||||
import { Box, Button, CircularProgress, Typography } from '@mui/material';
|
||||
|
||||
@@ -12,11 +10,11 @@ interface FormLoaderProps {
|
||||
onRetry?: () => void;
|
||||
}
|
||||
|
||||
const FormLoader: FC<FormLoaderProps> = ({
|
||||
const FormLoader = ({
|
||||
errorMessage,
|
||||
onRetry,
|
||||
message = 'Loading…'
|
||||
}) => {
|
||||
}: FormLoaderProps) => {
|
||||
const { LL } = useI18nContext();
|
||||
|
||||
if (errorMessage) {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { FC } from 'react';
|
||||
|
||||
import { Box, CircularProgress, Typography } from '@mui/material';
|
||||
import type { Theme } from '@mui/material';
|
||||
|
||||
@@ -9,7 +7,7 @@ interface LoadingSpinnerProps {
|
||||
height?: number | string;
|
||||
}
|
||||
|
||||
const LoadingSpinner: FC<LoadingSpinnerProps> = ({ height = '100%' }) => {
|
||||
const LoadingSpinner = ({ height = '100%' }: LoadingSpinnerProps) => {
|
||||
const { LL } = useI18nContext();
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Fragment } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { useDropzone } from 'react-dropzone';
|
||||
import type { DropzoneState } from 'react-dropzone';
|
||||
|
||||
@@ -31,12 +30,12 @@ export interface SingleUploadProps {
|
||||
progress: Progress;
|
||||
}
|
||||
|
||||
const SingleUpload: FC<SingleUploadProps> = ({
|
||||
const SingleUpload = ({
|
||||
onDrop,
|
||||
onCancel,
|
||||
isUploading,
|
||||
progress
|
||||
}) => {
|
||||
}: SingleUploadProps) => {
|
||||
const uploading = isUploading && progress.total > 0;
|
||||
|
||||
const dropzoneState = useDropzone({
|
||||
|
||||
Reference in New Issue
Block a user