Ver Fonte

refactor(layout-config): improve error handling and data normalization

- Remove unused error parameter from catch blocks for cleaner error handling
- Normalize date objects to ISO strings in layout configurations data
- Fix dialog message formatting by removing unnecessary quotes
- Remove unused BadgeIcon import from LayoutSectionCard
- Update page params type to use Promise for Next.js 13+ compatibility
vtugulan há 6 meses atrás
pai
commit
8469effd99

+ 1 - 1
app/components/layout-configurations/CreateLayoutConfigurationDialog.tsx

@@ -45,7 +45,7 @@ export function CreateLayoutConfigurationDialog() {
           variant: "destructive",
         });
       }
-    } catch (error) {
+    } catch {
       toast({
         title: "Error",
         description: "Failed to create layout configuration",

+ 9 - 4
app/components/layout-configurations/LayoutConfigurationsTable.tsx

@@ -47,7 +47,12 @@ export function LayoutConfigurationsTable() {
     try {
       const result = await getLayoutConfigurations();
       if (result.success) {
-        setConfigurations(result.data || []);
+        const configurations = (result.data || []).map(config => ({
+          ...config,
+          createdAt: config.createdAt instanceof Date ? config.createdAt.toISOString() : config.createdAt,
+          updatedAt: config.updatedAt instanceof Date ? config.updatedAt.toISOString() : config.updatedAt,
+        }));
+        setConfigurations(configurations);
       } else {
         toast({
           title: "Error",
@@ -55,7 +60,7 @@ export function LayoutConfigurationsTable() {
           variant: "destructive",
         });
       }
-    } catch (error) {
+    } catch {
       toast({
         title: "Error",
         description: "Failed to load configurations",
@@ -82,7 +87,7 @@ export function LayoutConfigurationsTable() {
           variant: "destructive",
         });
       }
-    } catch (error) {
+    } catch {
       toast({
         title: "Error",
         description: "Failed to delete configuration",
@@ -154,7 +159,7 @@ export function LayoutConfigurationsTable() {
                     <AlertDialogHeader>
                       <AlertDialogTitle>Delete Configuration</AlertDialogTitle>
                       <AlertDialogDescription>
-                        Are you sure you want to delete "{config.name}"? This action cannot be undone.
+                        Are you sure you want to delete {config.name}? This action cannot be undone.
                       </AlertDialogDescription>
                     </AlertDialogHeader>
                     <AlertDialogFooter>

+ 0 - 1
app/components/layout-configurations/LayoutSectionCard.tsx

@@ -3,7 +3,6 @@
 import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
 import { Badge } from "@/components/ui/badge";
 import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
-import { Badge as BadgeIcon } from "lucide-react";
 
 interface LayoutSection {
   id: number;

+ 2 - 2
app/layout-configurations/[id]/page.tsx

@@ -5,9 +5,9 @@ import { LayoutConfigurationDetail } from "@/app/components/layout-configuration
 import { Skeleton } from "@/components/ui/skeleton";
 
 interface PageProps {
-  params: {
+  params: Promise<{
     id: string;
-  };
+  }>;
 }
 
 export default async function LayoutConfigurationDetailPage({ params }: PageProps) {