import React from 'react';

export interface ServerErrors {
  [path: string]: string;
}
export interface ServerErrorContextProps {
  errors: ServerErrors;
  getError: (path: string) => string | undefined;
  setError: (path: string, errorMessage: string | undefined) => void;
}
/** Context to store the API errors from the server for the form. */
export const ServerErrorContext = React.createContext<ServerErrorContextProps>({
  errors: {},
  getError: (path: string) => {
    return undefined;
  },
  setError: (path: string, errorMessage: string | undefined) => {},
});
