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 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;
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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) {

View File

@@ -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 (

View File

@@ -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({