import React, { memo } from "react";
import { MappedStatusBadge, type StatusBadgeProps } from "@/components/ui/StatusBadge";

type ShipmentStatus = "delivered" | "shipped" | "pending" | "canceled" | "cancelled" | string;

interface ShipmentStatusBadgeProps {
  status: ShipmentStatus;
}

const statusMap: Record<
  string,
  { label: string; status: StatusBadgeProps["status"] }
> = {
  delivered: {
    label: "Zugestellt",
    status: "success",
  },
  shipped: {
    label: "Versendet",
    status: "success",
  },
  pending: {
    label: "Ausstehend",
    status: "warning",
  },
  canceled: {
    label: "Storniert",
    status: "error",
  },
  cancelled: {
    label: "Storniert",
    status: "error",
  },
};

/**
 * ⚡ Optimization: Memoized ShipmentStatusBadge
 * Standardizes shipment tracking status indicators using the MappedStatusBadge primitive.
 */
export const ShipmentStatusBadge = memo(({ status }: ShipmentStatusBadgeProps) => {
  return <MappedStatusBadge status={status} mapping={statusMap} />;
});

ShipmentStatusBadge.displayName = "ShipmentStatusBadge";
