import type { FormState } from '@/app/admin/actions';

export default function FormMessage({ state }: { state: FormState }) {
  if (!state || (!state.ok && !state.error)) return null;
  return (
    <div className={`msg ${state.error ? 'error' : 'ok'}`} role="status">
      {state.error ?? state.ok}
      {state.details && state.details.length > 0 && (
        <ul>
          {state.details.map((d, i) => (
            <li key={i}>{d}</li>
          ))}
        </ul>
      )}
    </div>
  );
}
