"use client";

import type { TFunction } from "i18next";

import { formatPlayerInstant } from "@/lib/player-datetime";

type OrderMetaLineProps = {
  orderNo: string | null | undefined;
  placedAt: string | null | undefined;
  t: TFunction<"player">;
  className?: string;
};

/** 订单号 + 下单时间（与 hall.result.orderNo 文案一致） */
export function OrderMetaLine({ orderNo, placedAt, t, className }: OrderMetaLineProps) {
  const trimmed = (orderNo ?? "").trim();
  const displayNo = trimmed || t("orders.noOrderNo");

  return (
    <p className={className ?? "mt-1 truncate text-xs text-slate-500"}>
      <span>{t("orders.orderNoLabel")}</span>{" "}
      <span className="font-mono font-semibold text-slate-600">{displayNo}</span>
      <span aria-hidden> · </span>
      <span>{formatPlayerInstant(placedAt ?? null)}</span>
    </p>
  );
}
