Skip to content

Customer Components

Available Components

ComponentDescription
CustomerListTablePaginated customer list
CustomerFormCreate/edit customer
CustomerViewDisplay customer details
CustomerSelectDropdown for selecting customers

CustomerListTable

Display a searchable list of customers:

Customer Listtypescript
import { CustomerListTable } from "@/components/space-invoices/customers";
import { useEntities } from "@/providers/entities-provider";

function _CustomersPage() {
  const { activeEntity } = useEntities();

  return (
    id}
      onRowClick={(customer) => {
        navigate(`/customers/${customer.id}`);
      }}
      onCreateClick={() => navigate("/customers/new")}
    />
  );
}

Props

PropTypeDescription
entityIdstringEntity ID
onRowClick(customer) => voidRow click handler
onCreateClick() => voidCreate button handler

CustomerForm

Create or edit customers:

Customer Formtypescript
import { CustomerForm } from "@/components/space-invoices/customers";
import { useEntities } from "@/providers/entities-provider";

// Create new customer
function _NewCustomerPage() {
  const { activeEntity } = useEntities();

  return (
    id}
      onSuccess={(customer) => {
        toast.success("Customer created");
        navigate(`/customers/${customer.id}`);
      }}
      onCancel={() => navigate("/customers")}
    />
  );
}

// Edit existing customer
function _EditCustomerPage({ customerId }) {
  return (
     {
        toast.success("Customer updated");
        navigate(`/customers/${customerId}`);
      }}
      onCancel={() => navigate(`/customers/${customerId}`)}
    />
  );
}

Props

PropTypeDescription
entityIdstringEntity ID (for create)
customerIdstringCustomer ID (for edit)
onSuccess(customer) => voidSuccess callback
onCancel() => voidCancel callback

CustomerSelect

Dropdown for selecting a customer:

Customer Selecttypescript
import { CustomerSelect } from "@/components/space-invoices/customers";

function _InvoiceForm() {
  const [customerId, setCustomerId] = useState();

  return (
    id}
      value={customerId}
      onChange={setCustomerId}
      placeholder="Select a customer..."
    />
  );
}

Props

PropTypeDescription
entityIdstringEntity ID
valuestringSelected customer ID
onChange(customerId) => voidChange handler
placeholderstringPlaceholder text

CustomerView

Display customer details:

Customer Viewtypescript
import { CustomerView } from "@/components/space-invoices/customers";

function _CustomerDetailPage({ customerId }) {
  return (
     navigate(`/customers/${customerId}/edit`)}
      onCreateInvoice={() => {
        navigate(`/invoices/new?customerId=${customerId}`);
      }}
    />
  );
}

Next Steps

  • Items — Product/service components
  • Invoices — Invoice components