Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 23x 23x 23x 126x | import { Stack } from "@mui/material";
import { useGetCustomerById } from "@services/api/customer";
import CustomerPanelHeader from "./CustomerPanelHeader";
import CustomerDetails from "./CustomerDetails";
import CustomerLocation from "./CustomerLocation";
import CustomerTransaction from "./CustomerTransaction";
import { Subscriptions } from "./Subscriptions";
import CustomerCustomFields from "./CustomerCustomFields";
import PanelLoadingSkeleton from "features/Merchants/MerchantSidePanel/components/PanelLoadingSkeleton";
interface Props {
id: number;
merchantID?: number;
}
export default function CustomerPanelBody({ id, merchantID }: Props) {
const { data, isDataLoading } = useGetCustomerById(id, merchantID);
const customerName =
`${data?.firstName} ${data?.lastName}`.trim() ||
data?.address?.name ||
data?.cardHolderName ||
"No Name";
return (
<Stack data-testid="customer-panel-body" padding="40px 20px" gap="40px">
{isDataLoading ? (
<PanelLoadingSkeleton variant="customer" />
) : (
<>
<CustomerPanelHeader
name={customerName}
avatarUrl={data?.avatarURL}
customerData={data}
/>
<CustomerDetails data={data} />
<CustomerLocation
address={data?.address}
lastKnownLatitude={data?.lastKnownLatitude}
lastKnownLongitude={data?.lastKnownLongitude}
/>
<CustomerTransaction
purchases={data?.purchases}
totalPurchased={data?.totalPurchased}
/>
<CustomerCustomFields data={data} />
<Subscriptions
customerEmail={data?.email || ""}
customerName={customerName}
merchantID={merchantID}
subscriptions={data?.recurringPurchases?.sort(
(a, b) => b.createdAt - a.createdAt,
)}
/>
</>
)}
</Stack>
);
}
|