From 2bb14b91ea87843a8258b79a06f57440c6dfeb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Zaninotto?= Date: Tue, 20 Aug 2024 18:52:11 +0200 Subject: [PATCH] Fix double progress while loading --- examples/crm/src/companies/CompanyList.tsx | 5 ++--- examples/crm/src/contacts/ContactList.tsx | 6 +++--- examples/crm/src/deals/DealList.tsx | 4 ++-- examples/crm/src/layout/Layout.tsx | 3 +-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/examples/crm/src/companies/CompanyList.tsx b/examples/crm/src/companies/CompanyList.tsx index fac7d8322ca..0c795dd162e 100644 --- a/examples/crm/src/companies/CompanyList.tsx +++ b/examples/crm/src/companies/CompanyList.tsx @@ -1,4 +1,3 @@ -import * as React from 'react'; import { TopToolbar, ExportButton, @@ -13,7 +12,7 @@ import { import { ImageList } from './GridList'; import { CompanyListFilter } from './CompanyListFilter'; -import { LinearProgress, Stack } from '@mui/material'; +import { Stack } from '@mui/material'; import { CompanyEmpty } from './CompanyEmpty'; export const CompanyList = () => { @@ -30,7 +29,7 @@ const CompanyListLayout = () => { const { data, isPending, filterValues } = useListContext(); const hasFilters = filterValues && Object.keys(filterValues).length > 0; - if (isPending) return ; + if (isPending) return null; if (!data?.length && !hasFilters) return ; return ( diff --git a/examples/crm/src/contacts/ContactList.tsx b/examples/crm/src/contacts/ContactList.tsx index ef45db015b1..5d8702db411 100644 --- a/examples/crm/src/contacts/ContactList.tsx +++ b/examples/crm/src/contacts/ContactList.tsx @@ -1,5 +1,5 @@ /* eslint-disable import/no-anonymous-default-export */ -import { Card, LinearProgress, Stack } from '@mui/material'; +import { Card, Stack } from '@mui/material'; import jsonExport from 'jsonexport/dist'; import type { Exporter, Identifier, RaRecord } from 'react-admin'; import { @@ -17,6 +17,7 @@ import { useGetIdentity, useListContext, } from 'react-admin'; + import { Company, Contact, Sale, Tag } from '../types'; import { ContactEmpty } from './ContactEmpty'; import { ContactImportButton } from './ContactImportButton'; @@ -45,8 +46,7 @@ const ContactListLayout = () => { const hasFilters = filterValues && Object.keys(filterValues).length > 0; - if (!identity) return null; - if (isPending) return ; + if (!identity || isPending) return null; if (!data?.length && !hasFilters) return ; diff --git a/examples/crm/src/deals/DealList.tsx b/examples/crm/src/deals/DealList.tsx index 38ce8e60b57..05546bad152 100644 --- a/examples/crm/src/deals/DealList.tsx +++ b/examples/crm/src/deals/DealList.tsx @@ -14,7 +14,7 @@ import { } from 'react-admin'; import { matchPath, useLocation } from 'react-router'; -import { Card, LinearProgress, Stack } from '@mui/material'; +import { Card, Stack } from '@mui/material'; import { useConfigurationContext } from '../root/ConfigurationContext'; import { DealArchivedList } from './DealArchivedList'; import { DealCreate } from './DealCreate'; @@ -63,7 +63,7 @@ const DealLayout = () => { const { data, isPending, filterValues } = useListContext(); const hasFilters = filterValues && Object.keys(filterValues).length > 0; - if (isPending) return ; + if (isPending) return null; if (!data?.length && !hasFilters) return ( <> diff --git a/examples/crm/src/layout/Layout.tsx b/examples/crm/src/layout/Layout.tsx index ceb28c36335..6ce6dff0a04 100644 --- a/examples/crm/src/layout/Layout.tsx +++ b/examples/crm/src/layout/Layout.tsx @@ -1,9 +1,8 @@ import { Suspense, ReactNode } from 'react'; import { CssBaseline, Container } from '@mui/material'; -import { CheckForApplicationUpdate } from 'react-admin'; +import { Error, Loading, CheckForApplicationUpdate } from 'react-admin'; import { ErrorBoundary } from 'react-error-boundary'; -import { Error, Loading } from 'react-admin'; import Header from './Header'; const Layout = ({ children }: { children: ReactNode }) => (