From 5ad190b11d366815e169fa8dae43a057f09a620a Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Wed, 27 Aug 2025 08:10:24 -0600 Subject: [PATCH] Improve UI for sample images when there are no samples --- ui/src/components/SampleImages.tsx | 56 ++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/ui/src/components/SampleImages.tsx b/ui/src/components/SampleImages.tsx index 8f4b80d9..192ba8a4 100644 --- a/ui/src/components/SampleImages.tsx +++ b/ui/src/components/SampleImages.tsx @@ -3,6 +3,7 @@ import useSampleImages from '@/hooks/useSampleImages'; import SampleImageCard from './SampleImageCard'; import { Job } from '@prisma/client'; import { JobConfig } from '@/types'; +import { LuImageOff, LuLoader, LuBan } from 'react-icons/lu'; interface SampleImagesProps { job: Job; @@ -23,6 +24,58 @@ export default function SampleImages({ job }: SampleImagesProps) { return 10; }, [job]); + const PageInfoContent = useMemo(() => { + let icon = null; + let text = ''; + let subtitle = ''; + let showIt = false; + let bgColor = ''; + let textColor = ''; + let iconColor = ''; + + if (sampleImages.length > 0) return null; + + if (status == 'loading') { + icon = ; + text = 'Loading Samples'; + subtitle = 'Please wait while we fetch your samples...'; + showIt = true; + bgColor = 'bg-gray-50 dark:bg-gray-800/50'; + textColor = 'text-gray-900 dark:text-gray-100'; + iconColor = 'text-gray-500 dark:text-gray-400'; + } + if (status == 'error') { + icon = ; + text = 'Error Loading Samples'; + subtitle = 'There was a problem fetching the samples.'; + showIt = true; + bgColor = 'bg-red-50 dark:bg-red-950/20'; + textColor = 'text-red-900 dark:text-red-100'; + iconColor = 'text-red-600 dark:text-red-400'; + } + if (status == 'success' && sampleImages.length === 0) { + icon = ; + text = 'No Samples Found'; + subtitle = 'No samples have been generated yet'; + showIt = true; + bgColor = 'bg-gray-50 dark:bg-gray-800/50'; + textColor = 'text-gray-900 dark:text-gray-100'; + iconColor = 'text-gray-500 dark:text-gray-400'; + } + + if (!showIt) return null; + + return ( +
+
{icon}
+

{text}

+

{subtitle}

+
+ ); + }, [status, sampleImages.length]); + // Use direct Tailwind class without string interpolation // This way Tailwind can properly generate the class // I hate this, but it's the only way to make it work @@ -118,8 +171,7 @@ export default function SampleImages({ job }: SampleImagesProps) { return (
- {status === 'loading' && sampleImages.length === 0 &&

Loading...

} - {status === 'error' &&

Error fetching sample images

} + {PageInfoContent} {sampleImages && (
{sampleImages.map((sample: string) => (