// components/ClientList.tsx import React, { useEffect, useState } from "react"; import { getClientList, ClientData } from "../index"; import { ClientListProps } from "../types"; /** * The ClientList component. * Renders a client list for the given data and provides options for customization. * @param {string} [className] - CSS class for the main container. Optional. * @param {string} [clientClassName] - CSS class for individual client container. Optional. * @param {string} [avatarClassName] - CSS class for client avatar. Optional. * @param {string} [backgroundClassName] - CSS class for client background. Optional. * @param {string} [textClassName] - CSS class for text elements. Optional. * @param {React.CSSProperties} [style] - Inline styles for the main container. Optional. */ export const ClientList: React.FC = ({ clients: clientsProp, className, clientClassName, avatarClassName, backgroundClassName, textClassName, style, }) => { const [clientsState, setClients] = useState(clientsProp || []); const [isLoading, setIsLoading] = useState(true); /** * Fetches client list from API */ useEffect(() => { if (!clientsProp) { getClientList() .then((response) => { if ("data" in response) { setClients(response.data); setIsLoading(false); } }) .catch((error) => { console.error("Error fetching client list:", error); setIsLoading(false); }); } else { setIsLoading(false); } }, [clientsProp]); const clients = clientsProp || clientsState; if (isLoading) { return
Loading...
; } return (
{clients.map((client) => (
{`${client.client}

Client: {client.client}

Trial: {client.trial ? "Yes" : "No"}

Is Hidden: {client.is_hidden ? "Yes" : "No"}

))}
Powered by Tribe{" "} Tribe Logo
); };