Guest User

Untitled

a guest
Mar 5th, 2024
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { useFormState, useFormStatus } from 'react-dom';
  2. import { authenticate } from '@/app/rms-admin/lib/actions';
  3. import Button from '@/app/rms-admin/ui/button';
  4.  
  5. export default function LoginForm(){
  6.     const [errorMessage, formS] = useFormState(authenticate, undefined);
  7.     return(
  8.         <form action={formS} className="space-y-3">
  9.         <div className="flex-1 rounded-lg bg-gray-50 px-6 pb-4 pt-8">
  10.           <h1 className={` mb-3 text-2xl`}>
  11.             Please log in to continue.
  12.           </h1>
  13.           <div className="w-full">
  14.             <div>
  15.               <label
  16.                 className="mb-3 mt-5 block text-xs font-medium text-gray-900"
  17.                 htmlFor="email"
  18.               >
  19.                 Email
  20.               </label>
  21.               <div className="relative">
  22.                 <input
  23.                   className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500"
  24.                   id="email"
  25.                   type="email"
  26.                   name="email"
  27.                   placeholder="Enter your email address"
  28.                   required
  29.                 />
  30.                 <AtSymbolIcon className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 text-gray-500 peer-focus:text-gray-900" />
  31.               </div>
  32.             </div>
  33.             <div className="mt-4">
  34.               <label
  35.                 className="mb-3 mt-5 block text-xs font-medium text-gray-900"
  36.                 htmlFor="password"
  37.               >
  38.                 Password
  39.               </label>
  40.               <div className="relative">
  41.                 <input
  42.                   className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500"
  43.                   id="password"
  44.                   type="password"
  45.                   name="password"
  46.                   placeholder="Enter password"
  47.                   required
  48.                   minLength={6}
  49.                 />
  50.                 <KeyIcon className="pointer-events-none absolute left-3 top-1/2 h-[18px] w-[18px] -translate-y-1/2 text-gray-500 peer-focus:text-gray-900" />
  51.               </div>
  52.             </div>
  53.           </div>
  54.           <LoginButton />
  55.           <div
  56.             className="flex h-8 items-end space-x-1"
  57.             aria-live="polite"
  58.             aria-atomic="true"
  59.           >
  60.             {errorMessage && (
  61.               <>
  62.                 <ExclamationCircleIcon className="h-5 w-5 text-red-500" />
  63.                 <p className="text-sm text-red-500">{errorMessage}</p>
  64.               </>
  65.             )}
  66.           </div>
  67.         </div>
  68.       </form>
  69.     )
  70. }
  71.  
  72. function LoginButton(){
  73.     const { pending } = useFormStatus();
  74.  
  75.     return (
  76.         <Button className="mt-4 w-full" ariaDisabled={pending} onClick={function (): void {
  77.         throw new Error('Function not implemented.');
  78.       } } radius={''} width={''}>
  79.             Log In <ArrowRightIcon className="ml-auto h-5 w-5 text-gray-50" />
  80.         </Button>
  81.     )
  82. }
Advertisement
Add Comment
Please, Sign In to add comment