LoginForm container
The LoginForm
is a conditional container. It is designed to handle user email input and validation within the checkout process.
LoginForm configurations
The LoginForm
container provides the following configuration options:
(*) Properties inherited from ConditionalContainer
These configuration options are implementing the LoginFormProps
interface:
LoginFormProps interface
The LoginForm
container receives an object as a parameter which implements the LoginFormProps
interface with the following properties:
export interface LoginFormProps extends HTMLAttributes<HTMLFormElement> { onSignInClick?: (email: string) => void; onSignOutClick?: () => void;}
onSignInClick
property is a handler used to perform actions called when the sign-in button is clicked. It accepts an email as an input parameter.onSignOutClick
property is a handler used to perform actions called when the sign-out button is clicked.Example
The following example renders the LoginForm
container on a checkout page, which includes rendering the AuthCombine
container from the user auth drop-in component in a modal for authentication:
import { ProgressSpinner, provider as UI,} from '@dropins/tools/components.js';
import * as authApi from '@dropins/storefront-auth/api.js';import AuthCombine from '@dropins/storefront-auth/containers/AuthCombine.js';import { render as AuthProvider } from '@dropins/storefront-auth/render.js';
import LoginForm from '@dropins/storefront-checkout/containers/LoginForm.js';import { render as CheckoutProvider } from '@dropins/storefront-checkout/render.js';
import { authPrivacyPolicyConsentSlot } from '../../scripts/constants.js';
const LOGIN_FORM_NAME = 'login-form';
const $loader = checkoutFragment.querySelector('.checkout__loader');const $login = checkoutFragment.querySelector('.checkout__login');
let loader;
const displayOverlaySpinner = async () => { if (loader) return;
loader = await UI.render(ProgressSpinner, { className: '.checkout__overlay-spinner', })($loader);};
CheckoutProvider.render(LoginForm, { name: LOGIN_FORM_NAME, onSignInClick: async (initialEmailValue) => { const signInForm = document.createElement('div');
AuthProvider.render(AuthCombine, { signInFormConfig: { renderSignUpLink: true, initialEmailValue, onSuccessCallback: () => { displayOverlaySpinner(); }, }, signUpFormConfig: { slots: { ...authPrivacyPolicyConsentSlot, }, }, resetPasswordFormConfig: {}, })(signInForm);
showModal(signInForm); }, onSignOutClick: () => { authApi.revokeCustomerToken(); },})($login),