export function StatusMessage({
  updated,
  deleted,
  error
}: {
  updated?: string | string[];
  deleted?: string | string[];
  error?: string | string[];
}) {
  const updatedText = Array.isArray(updated) ? updated[0] : updated;
  const deletedText = Array.isArray(deleted) ? deleted[0] : deleted;
  const errorText = Array.isArray(error) ? error[0] : error;

  if (errorText) {
    const message =
      errorText === "receipt"
        ? "Receipt must be a JPG, JPEG, PNG, WEBP, or PDF file under 10 MB."
        : errorText === "document"
          ? "Document must be a supported file type under the size limit. Please check the file and try again."
          : errorText === "recurring-bill"
            ? "Recurring bill could not be saved. Please check the bill fields and try again."
            : errorText === "last-owner"
              ? "Every project must keep at least one active Owner."
          : "Update failed. Please check the form and try again.";

    return (
      <div className="mb-4 rounded-md border border-red-200 bg-red-50 px-4 py-3 text-sm font-medium text-red-700">
        {message}
      </div>
    );
  }

  if (updatedText) {
    return (
      <div className="mb-4 rounded-md border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm font-medium text-emerald-800">
        Saved changes.
      </div>
    );
  }

  if (deletedText) {
    return (
      <div className="mb-4 rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm font-medium text-amber-800">
        Deleted record.
      </div>
    );
  }

  return null;
}
