pagamio-frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
74 lines (73 loc) • 2.69 kB
TypeScript
import type { AuthenticatorType } from '../authenticators';
import type { AuthResponse, BaseAuthCredentials, CustomAuthConfig } from '../types';
import type { BaseAuthPageProps } from './AuthFormUtils';
/**
* Base login credentials interface that can be extended for specific implementations
*/
interface PagamioLoginCredentials {
username: string;
password: string;
rememberMe?: boolean;
}
/**
* Props for the PagamioLoginPage component
* @template T - Authentication configuration type
*/
interface PagamioLoginPageProps<T extends CustomAuthConfig> extends BaseAuthPageProps {
/** Customizable text content */
text?: {
welcomeTitle: string;
welcomeSubtitle: string;
usernameLabel: string;
passwordLabel: string;
rememberMeLabel: string;
loginButtonLabel: string;
loadingButtonLabel: string;
forgotPasswordLabel: string;
createAccountLabel: string;
};
/** Callback handlers */
onForgotPassword?: () => void;
onLoginSuccess?: (authResponse?: AuthResponse<T>) => void;
onLoginError?: (error: Error) => void;
/** Account creation options */
hasCreateAccount?: boolean;
createAccountRoute?: string;
onCreateAccount?: () => void;
/**
* Custom data transformation handler for login data
* Should return object to be used as login credentials
* @template TFormData - Type of the form data
*/
transformLoginData?: (credentials: BaseAuthCredentials) => Record<string, unknown>;
/** Styling options */
className?: string;
cardClassName?: string;
/**
* Authenticator type to use for login
* Supports 'default', 'strapi', or any custom registered type
*/
authenticatorType?: AuthenticatorType | string;
}
export interface LoginErrorProps {
code: string;
message: string;
}
export declare const loginPageDefaultText: {
welcomeTitle: string;
welcomeSubtitle: string;
usernameLabel: string;
passwordLabel: string;
rememberMeLabel: string;
loginButtonLabel: string;
loadingButtonLabel: string;
forgotPasswordLabel: string;
createAccountLabel: string;
};
/**
* Generic Login Page component
* @template T - Authentication configuration type
*/
export declare function PagamioLoginPage<T extends CustomAuthConfig>({ logo, text, appLabel, onForgotPassword, onLoginSuccess, onLoginError, hasCreateAccount, createAccountRoute, onCreateAccount, transformLoginData, authenticatorType, className, }: Readonly<PagamioLoginPageProps<T>>): import("react/jsx-runtime").JSX.Element;
export default PagamioLoginPage;
export type { PagamioLoginCredentials, PagamioLoginPageProps };