Skip to main content

Login Page

🧾 LoginPage Component Documentation​

πŸ“ Overview​

The LoginPage is a configurable authentication module built using React, PrimeReact, Formik, Yup, and Tailwind CSS. It supports customer ID, username, password inputs, and includes dialog support for:

  • Forgot Password
  • Reset Password
  • Project Selection

πŸš€ Usage Example​

The states and the handler functions needs to be defined in the consumer app. For reference look into the Signin component in the playground project (playground/src/components/SignIn/SignIn.jsx).

import LoginPage from "@/Modules/Login/LoginPage";  // Change the path based on the name of the library

<LoginPage
showEyeButtonOnPassword={true}
showCustomerTextBox={true}
showForgotPasswordButton={true}
handleSubmit={handleSubmit}
handleGetOtp={handleGetOtp}
handleResetPasswordSubmit={handleResetPasswordSubmit}
handleProceedOnProjectSelection={handleProceedOnProjectSelection}
handleValidateOtp={handleValidateOtp}
loginPageStates={loginPageStates}
resetPasswordDialogStates={resetPasswordDialogStates}
selectProjectDialogStates={selectProjectDialogStates}
forgotPasswordDialogStates={forgotPasswordDialogStates}
/>

βš™οΈ Props​

πŸ”Ή Basic Props​

PropTypeDefaultDescription
titlestring"Login to your Account"Title displayed at the top
showCustomerTextBoxbooltrueToggles visibility of the Customer ID field
showUsernameTextBoxbooltrueToggles visibility of the Username field
showPasswordTextBoxbooltrueToggles visibility of the Password field
showEyeButtonOnPasswordbooltrueEnables the password visibility toggle
showForgotPasswordButtonbooltrueToggles the β€œForgot Password?” button
customerLabelstring"CustomerId"Custom label for customer field

πŸ”Ή Handler Functions​

HandlerDescription
handleSubmitCalled on login form submit with values
handleGetOtpCalled when requesting OTP (Forgot Password)
handleValidateOtpCalled to validate OTP entered by user
handleResetPasswordSubmitCalled on reset password form submission
handleProceedOnProjectSelectionCalled when a project is selected in the project dialog

πŸ”Ή State Prop Groups​

Each group should be defined and managed in the parent (consumer) component.

loginPageStates​

KeyTypeDescription
submitErrorstringError shown after submit failure
loadingboolSubmit button loading state
showProjectDialogboolControls project selection dialog
setShowProjectDialogfunctionSetter for project dialog visibility
showForgotPasswordboolControls Forgot Password dialog
setShowForgotPasswordfunctionSetter for Forgot Password dialog
showResetPasswordDialogboolControls Reset Password dialog
setShowResetPasswordDialogfunctionSetter for Reset Password dialog

forgotPasswordDialogStates​

KeyTypeDescription
otpSentLoadingboolLoading state for OTP send button
setOtpSentLoadingfuncSetter
otpSentboolFlag if OTP has been sent
setOtpSentfuncSetter
otpstringOTP entered by user
setOtpfuncSetter
forgotPasswordUsernamestringUsername used for OTP
setForgotPasswordUsernamefuncSetter
otpErrorstringOTP validation error
setOtpErrorfuncSetter
otpSentEmailstringMasked email for OTP notification
setOtpSentEmailfuncSetter
otpValidateLoadingboolLoading state during OTP validation

resetPasswordDialogStates​

KeyTypeDescription
newPasswordstringNew password value
setNewPasswordfuncSetter
confirmPasswordstringConfirm password value
setConfirmPasswordfuncSetter
triggerToastboolFlag to trigger success toast
setTriggerToastfuncSetter

selectProjectDialogStates​

KeyTypeDescription
projectsarrayList of project objects
selectedProjectobjectCurrently selected project
setSelectedProjectfunctionSetter for selected project

πŸ–ΌοΈ Screens​

  1. Login Form with Customer ID / Username / Password
  2. Forgot Password Dialog (Username input β†’ OTP input)
  3. Reset Password Dialog (New Password & Confirm Password)
  4. Select Project Dialog (Dropdown or selectable list)

πŸ› οΈ Styling​

  • All components are styled using Tailwind CSS 4.x
  • Make sure PrimeReact theming is supported in your consumer app by checking for the below imports in your app's global css file.
import "primereact/resources/themes/lara-light-blue/theme.css";
import "primereact/resources/primereact.min.css";
import "primeicons/primeicons.css";

πŸ” Dependencies​

  • formik
  • yup
  • primereact
  • primeicons
  • tailwindcss
  • react, react-dom

βœ… Validation​

Uses Yup schema built dynamically based on which fields are visible (customer, username, password).


πŸ“¦ Reusability​

  • Fully controlled via props β€” no internal state.
  • Modular dialog components.
  • Easy to integrate with custom logic like APIs, notifications, etc.

**For real usage example go to the SignIn component of the Playground app (playground/src/components/SignIn/SignIn.jsx).​