pagamio-frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
59 lines (58 loc) • 2.06 kB
TypeScript
import React from 'react';
import type { PartialToastData } from '../../context/ToastContext';
import type { FormRef } from '../../form-engine';
/**
* Base props shared across authentication page components
*/
export interface BaseAuthPageProps {
/** Logo configuration for branding */
logo?: {
src: string;
alt: string;
width: number;
height: number;
};
/** App Label Text */
appLabel?: string;
/** Styling options */
className?: string;
cardClassName?: string;
}
/**
* Common password validation for authentication forms
*/
export declare const passwordValidation: {
required: string;
min: {
value: number;
message: string;
};
validate: (value: string) => true | "Password must contain at least one uppercase letter, one lowercase letter, and one number";
};
/**
* Renders a back to login button
*/
export declare const BackToLoginButton: ({ onBackToLogin, label }: {
onBackToLogin: () => void;
label: string;
}) => import("react/jsx-runtime").JSX.Element;
/**
* Common form submission handler configuration
*/
export interface FormSubmissionConfig {
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
setError?: React.Dispatch<React.SetStateAction<string | null>>;
addToast: (toast: PartialToastData) => void;
formRef: React.MutableRefObject<FormRef | undefined>;
onSuccess?: (response?: any) => void;
onError?: (error: Error) => void;
}
/**
* Creates a standardized form submission handler
* @param config Form submission configuration
* @param submitAction The action to perform during form submission
* @param successMessage Message to display on success
* @param fallbackErrorMessage Optional fallback error message to display on failure
* @returns A form submission handler function
*/
export declare const createFormSubmissionHandler: (config: FormSubmissionConfig, submitAction: (data: any) => Promise<any>, successMessage: string, fallbackErrorMessage?: string) => (data: any) => Promise<void>;