Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

1.5 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

import { Text } from "@react-pdf/renderer";
import { createTw } from "react-pdf-tailwind";

type AddressBlockProps = {
  name?: string | null;
  addressLine1?: string | null;
  addressLine2?: string | null;
  city?: string | null;
  stateProvince?: string | null;
  postalCode?: string | null;
  country?: string | null;
};

const tw = createTw({
  theme: {
    fontFamily: {
      sans: ["Inter", "Helvetica", "Arial", "sans-serif"]
    }
  }
});

/**
 * Render the address portion of a party block: name (bold), address lines, and
 * combined city/state/postal/country. Returns a Fragment so callers can wrap
 * it in their own <View> and add extra lines (Tax ID, VAT, contact info, etc.)
 * as siblings. AddressBlock is address-only by design.
 */
const AddressBlock = ({
  name,
  addressLine1,
  addressLine2,
  city,
  stateProvince,
  postalCode,
  country
}: AddressBlockProps) => {
  const stateAndPostal = [stateProvince, postalCode].filter(Boolean).join(" ");
  return (
    <>
      {name ? <Text style={tw("font-bold")}>{name}</Text> : null}
      {addressLine1 ? <Text>{addressLine1}</Text> : null}
      {addressLine2 ? <Text>{addressLine2}</Text> : null}
      {city ? <Text>{city}</Text> : null}
      {stateAndPostal ? <Text>{stateAndPostal}</Text> : null}
      {country ? <Text>{country}</Text> : null}
    </>
  );
};

export { AddressBlock };