/** Shared shape for every `useActionState`-driven form in the app. */
export type ActionState =
  | { status: "idle" }
  | { status: "success"; message?: string }
  | { status: "error"; message?: string; errors?: Record<string, string> };

export const IDLE_ACTION: ActionState = { status: "idle" };

export function actionError(message: string, errors?: Record<string, string>): ActionState {
  return { status: "error", message, errors };
}

export function actionSuccess(message?: string): ActionState {
  return { status: "success", message };
}
