From 9464b1d4089a06e339b860d5712dc67450cdd77b Mon Sep 17 00:00:00 2001 From: Thomas Trompette Date: Thu, 30 May 2024 11:44:34 +0200 Subject: [PATCH 1/4] Add empty state for records --- .../components/RecordTableEmptyState.tsx | 59 +++++++++++++++++++ .../components/RecordTableWithWrappers.tsx | 38 +++--------- 2 files changed, 67 insertions(+), 30 deletions(-) create mode 100644 packages/twenty-front/src/modules/object-record/record-table/components/RecordTableEmptyState.tsx diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableEmptyState.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableEmptyState.tsx new file mode 100644 index 000000000000..48c7d58c52d5 --- /dev/null +++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableEmptyState.tsx @@ -0,0 +1,59 @@ +import { useNavigate } from 'react-router-dom'; +import { IconPlus, IconSettings } from 'twenty-ui'; + +import { Button } from '@/ui/input/button/components/Button'; +import AnimatedPlaceholder from '@/ui/layout/animated-placeholder/components/AnimatedPlaceholder'; +import { + AnimatedPlaceholderEmptyContainer, + AnimatedPlaceholderEmptySubTitle, + AnimatedPlaceholderEmptyTextContainer, + AnimatedPlaceholderEmptyTitle, +} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled'; + +type RecordTableEmptyStateProps = { + objectLabel: string; + createRecord: () => void; + isRemote: boolean; +}; + +export const RecordTableEmptyState = ({ + objectLabel, + createRecord, + isRemote, +}: RecordTableEmptyStateProps) => { + const navigate = useNavigate(); + + const [title, subTitle, Icon, onClick, buttonTitle] = isRemote + ? [ + 'No Data Available for Remote Table', + 'If this is unexpected, please verify your settings.', + IconSettings, + () => navigate('/settings/integrations'), + 'Go to Settings', + ] + : [ + `Add your first ${objectLabel}`, + `Use our API or add your first ${objectLabel} manually`, + IconPlus, + createRecord, + `Add a ${objectLabel}`, + ]; + + return ( + + + + {title} + + {subTitle} + + +