From 261f62e3535aaf64c8eff74009c64a4e28ef5df6 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Sat, 3 Aug 2024 13:44:17 +0530 Subject: [PATCH] Fix automations mobile view by using a wrapper component that chooses a dialog or a drawer --- src/interface/web/app/automations/page.tsx | 280 +++++++++++---------- 1 file changed, 147 insertions(+), 133 deletions(-) diff --git a/src/interface/web/app/automations/page.tsx b/src/interface/web/app/automations/page.tsx index 251c3500..fda33138 100644 --- a/src/interface/web/app/automations/page.tsx +++ b/src/interface/web/app/automations/page.tsx @@ -1,10 +1,9 @@ 'use client' import useSWR from 'swr'; -import Loading, { InlineLoading } from '../components/loading/loading'; +import { InlineLoading } from '../components/loading/loading'; import { Card, - CardDescription, CardContent, CardFooter, CardHeader, @@ -54,7 +53,7 @@ import { useToast } from '@/components/ui/use-toast'; import { ToastAction } from '@/components/ui/toast'; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert" import SidePanel from '../components/sidePanel/chatHistorySidePanel'; -import NavMenu from '../components/navMenu/navMenu'; +import { Drawer, DrawerContent, DrawerTitle, DrawerTrigger } from '@/components/ui/drawer'; const automationsFetcher = () => window.fetch('/api/automations').then(res => res.json()).catch(err => console.log(err)); @@ -219,6 +218,7 @@ function sendAPreview(automationId: string, setToastMessage: (toastMessage: stri interface AutomationsCardProps { automation: AutomationsData; + isMobileWidth: boolean; locationData?: LocationData | null; suggestedCard?: boolean; setNewAutomationData?: (data: AutomationsData) => void; @@ -303,30 +303,17 @@ function AutomationsCard(props: AutomationsCardProps) { Delete { - !props.suggestedCard && ( - { - setIsEditing(open); - }} - > - - - - - Edit Automation - - - + (!props.suggestedCard && props.locationData) && ( + ) } { @@ -375,31 +362,17 @@ function AutomationsCard(props: AutomationsCardProps) { { props.suggestedCard && props.setNewAutomationData && ( - { - setIsEditing(open); - }} - > - - - - - Add Automation - - - + ) } @@ -413,6 +386,7 @@ interface SharedAutomationCardProps { isLoggedIn: boolean; setShowLoginPrompt: (showLoginPrompt: boolean) => void; authenticatedData: UserProfile | null; + isMobileWidth: boolean; } function SharedAutomationCard(props: SharedAutomationCardProps) { @@ -438,30 +412,19 @@ function SharedAutomationCard(props: SharedAutomationCardProps) { } return ( - { - setIsCreating(open); - }} - > - - - - - - Create Automation - - - - + isCreating ? + + : null ) } @@ -596,8 +559,6 @@ function AutomationModificationForm(props: AutomationModificationFormProps) { const [isSaving, setIsSaving] = useState(false); const { errors } = props.form.formState; - console.log(errors); - function recommendationPill(recommendationText: string, onChange: (value: any, event: React.MouseEvent) => void) { return ( + + + Automation + + + + ) : + ( + { + props.setIsCreating(open); + }} + > + + + + + Automation + + + + ) + ); + +} + export default function Automations() { const authenticatedData = useAuthenticatedData(); @@ -932,7 +969,7 @@ export default function Automations() { } }, [personalAutomations, allNewAutomations]); - if (error) return
Failed to load
; + if (error) return ; return (
@@ -950,7 +987,7 @@ export default function Automations() {
{ authenticatedData ? ( - {authenticatedData.email} + {authenticatedData.email} ) : null } @@ -986,34 +1023,18 @@ export default function Automations() { Your Creations { - authenticatedData ? ( - { - setIsCreating(open); - }} - > - - - - - Create Automation - - - - ) + authenticatedData ? + : ( - - - Create Automation - - - - ) + authenticatedData ? + : (