page.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use client";
  2. import { Suspense, useState, useCallback } from "react";
  3. import { LayoutConfigurationsTable } from "@/app/components/layout-configurations/LayoutConfigurationsTable";
  4. import { CreateLayoutConfigurationDialog } from "@/app/components/layout-configurations/CreateLayoutConfigurationDialog";
  5. import { Skeleton } from "@/components/ui/skeleton";
  6. import { Button } from "@/components/ui/button";
  7. import { RefreshCw } from "lucide-react";
  8. export default function LayoutConfigurationsPage() {
  9. const [refreshKey, setRefreshKey] = useState(0);
  10. const handleRefresh = useCallback(() => {
  11. setRefreshKey(prev => prev + 1);
  12. }, []);
  13. return (
  14. <div className="container mx-auto py-8 px-4">
  15. <div className="flex justify-between items-center mb-6">
  16. <h1 className="text-3xl font-bold">Layout Configurations</h1>
  17. <div className="flex gap-2">
  18. <Button
  19. variant="outline"
  20. size="sm"
  21. onClick={handleRefresh}
  22. className="flex items-center gap-2"
  23. >
  24. <RefreshCw className="h-4 w-4" />
  25. Refresh
  26. </Button>
  27. <CreateLayoutConfigurationDialog />
  28. </div>
  29. </div>
  30. <div className="bg-white rounded-lg shadow">
  31. <Suspense fallback={<LayoutConfigurationsSkeleton />}>
  32. <LayoutConfigurationsTable key={refreshKey} />
  33. </Suspense>
  34. </div>
  35. </div>
  36. );
  37. }
  38. function LayoutConfigurationsSkeleton() {
  39. return (
  40. <div className="p-4 space-y-4">
  41. {[...Array(5)].map((_, i) => (
  42. <div key={i} className="flex items-center space-x-4">
  43. <Skeleton className="h-12 w-full" />
  44. </div>
  45. ))}
  46. </div>
  47. );
  48. }