import React, { useState } from "react"; import { base44 } from "@/api/base44Client"; import { useQuery } from "@tanstack/react-query"; import { Link } from "react-router-dom"; import { createPageUrl } from "@/utils"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { Building2, Plus, Search, Users, Edit } from "lucide-react"; import PageHeader from "../components/common/PageHeader"; export default function EnterpriseManagement() { const [searchTerm, setSearchTerm] = useState(""); const { data: enterprises = [], isLoading } = useQuery({ queryKey: ['enterprises'], queryFn: () => base44.entities.Enterprise.list('-created_date'), initialData: [], }); const filteredEnterprises = enterprises.filter(e => !searchTerm || e.enterprise_name?.toLowerCase().includes(searchTerm.toLowerCase()) || e.enterprise_code?.toLowerCase().includes(searchTerm.toLowerCase()) ); return (
} /> {/* Search */}
setSearchTerm(e.target.value)} className="pl-10" />
{/* Enterprises Grid */} {isLoading ? (
{[...Array(4)].map((_, i) => (
))}
) : filteredEnterprises.length > 0 ? (
{filteredEnterprises.map((enterprise) => (
{enterprise.enterprise_code}

{enterprise.enterprise_name}

{enterprise.headquarters_address}

{enterprise.brand_family && enterprise.brand_family.length > 0 && (

Brand Family

{enterprise.brand_family.map((brand, i) => ( {brand} ))}
)} {enterprise.sector_registry && enterprise.sector_registry.length > 0 && (
{enterprise.sector_registry.length} Sectors
)}
))}
) : (

No Enterprises Found

Add your first enterprise

)}
); }