FC removal

This commit is contained in:
proddy
2024-08-08 12:57:04 +02:00
parent 3481a879c2
commit 5355c65da8
6 changed files with 12 additions and 37 deletions

View File

@@ -1,5 +1,4 @@
import { useContext, useEffect } from 'react'; import { useContext, useEffect } from 'react';
import type { FC } from 'react';
import { Navigate, Route, Routes, useLocation } from 'react-router-dom'; import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
import { toast } from 'react-toastify'; import { toast } from 'react-toastify';
@@ -14,7 +13,7 @@ interface SecurityRedirectProps {
signOut?: boolean; signOut?: boolean;
} }
const RootRedirect: FC<SecurityRedirectProps> = ({ message, signOut }) => { const RootRedirect = ({ message, signOut }: SecurityRedirectProps) => {
const authenticationContext = useContext(AuthenticationContext); const authenticationContext = useContext(AuthenticationContext);
useEffect(() => { useEffect(() => {
signOut && authenticationContext.signOut(false); signOut && authenticationContext.signOut(false);
@@ -23,26 +22,11 @@ const RootRedirect: FC<SecurityRedirectProps> = ({ message, signOut }) => {
return <Navigate to="/" />; return <Navigate to="/" />;
}; };
export const RemoveTrailingSlashes = () => { export default function AppRouting() {
const location = useLocation();
return (
location.pathname.match('/.*/$') && (
<Navigate
to={{
pathname: location.pathname.replace(/\/+$/, ''),
search: location.search
}}
/>
)
);
};
const AppRouting = () => {
const { LL } = useI18nContext(); const { LL } = useI18nContext();
return ( return (
<Authentication> <Authentication>
<RemoveTrailingSlashes />
<Routes> <Routes>
<Route <Route
path="/unauthorized" path="/unauthorized"
@@ -71,6 +55,4 @@ const AppRouting = () => {
</Routes> </Routes>
</Authentication> </Authentication>
); );
}; }
export default AppRouting;

View File

@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { Link, useLocation } from 'react-router-dom'; import { Link, useLocation } from 'react-router-dom';
import { ListItemButton, ListItemIcon, ListItemText } from '@mui/material'; import { ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
@@ -13,12 +12,12 @@ interface LayoutMenuItemProps {
disabled?: boolean; disabled?: boolean;
} }
const LayoutMenuItem: FC<LayoutMenuItemProps> = ({ const LayoutMenuItem = ({
icon: Icon, icon: Icon,
label, label,
to, to,
disabled disabled
}) => { }: LayoutMenuItemProps) => {
const { pathname } = useLocation(); const { pathname } = useLocation();
const selected = routeMatches(to, pathname); const selected = routeMatches(to, pathname);

View File

@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import NavigateNextIcon from '@mui/icons-material/NavigateNext'; 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, icon,
bgcolor, bgcolor,
label, label,
text, text,
to, to,
disabled disabled
}) => ( }: ListMenuItemProps) => (
<> <>
{to && !disabled ? ( {to && !disabled ? (
<ListItem <ListItem

View File

@@ -1,5 +1,3 @@
import type { FC } from 'react';
import RefreshIcon from '@mui/icons-material/Refresh'; import RefreshIcon from '@mui/icons-material/Refresh';
import { Box, Button, CircularProgress, Typography } from '@mui/material'; import { Box, Button, CircularProgress, Typography } from '@mui/material';
@@ -12,11 +10,11 @@ interface FormLoaderProps {
onRetry?: () => void; onRetry?: () => void;
} }
const FormLoader: FC<FormLoaderProps> = ({ const FormLoader = ({
errorMessage, errorMessage,
onRetry, onRetry,
message = 'Loading…' message = 'Loading…'
}) => { }: FormLoaderProps) => {
const { LL } = useI18nContext(); const { LL } = useI18nContext();
if (errorMessage) { if (errorMessage) {

View File

@@ -1,5 +1,3 @@
import type { FC } from 'react';
import { Box, CircularProgress, Typography } from '@mui/material'; import { Box, CircularProgress, Typography } from '@mui/material';
import type { Theme } from '@mui/material'; import type { Theme } from '@mui/material';
@@ -9,7 +7,7 @@ interface LoadingSpinnerProps {
height?: number | string; height?: number | string;
} }
const LoadingSpinner: FC<LoadingSpinnerProps> = ({ height = '100%' }) => { const LoadingSpinner = ({ height = '100%' }: LoadingSpinnerProps) => {
const { LL } = useI18nContext(); const { LL } = useI18nContext();
return ( return (

View File

@@ -1,5 +1,4 @@
import { Fragment } from 'react'; import { Fragment } from 'react';
import type { FC } from 'react';
import { useDropzone } from 'react-dropzone'; import { useDropzone } from 'react-dropzone';
import type { DropzoneState } from 'react-dropzone'; import type { DropzoneState } from 'react-dropzone';
@@ -31,12 +30,12 @@ export interface SingleUploadProps {
progress: Progress; progress: Progress;
} }
const SingleUpload: FC<SingleUploadProps> = ({ const SingleUpload = ({
onDrop, onDrop,
onCancel, onCancel,
isUploading, isUploading,
progress progress
}) => { }: SingleUploadProps) => {
const uploading = isUploading && progress.total > 0; const uploading = isUploading && progress.total > 0;
const dropzoneState = useDropzone({ const dropzoneState = useDropzone({