feat: Forgot Password Slicing, fix: webp image

This commit is contained in:
boboiazumi
2025-03-29 20:42:54 +07:00
parent a3887519f9
commit ecdaa4a82e
22 changed files with 246 additions and 5 deletions
@@ -0,0 +1,30 @@
import { DetailedHTMLProps, FC, InputHTMLAttributes, ReactElement } from "react"
type TForgotStepProps = Omit<
DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
'size' | 'type'
> & {
step: number
};
export const ForgotStep: FC<TForgotStepProps> = ({
step = 1,
...rest
}): ReactElement => {
return (
<div className="w-full grid grid-cols-3 gap-3">
<div className="flex flex-col items-center justify-center gap-2">
<div className={`${step === 1 ? "bg-primary-500" : "bg-primary-200"} px-5 py-2 rounded-md w-full`}></div>
<h4 className={`${step === 1 ? "text-primary-500" : "text-gray-500"} text-xs`}>Masukkan Email</h4>
</div>
<div className="flex flex-col items-center justify-center gap-2">
<div className={`${step === 2 ? "bg-primary-500" : "bg-primary-200"} px-5 py-2 rounded-md w-full`}></div>
<h4 className={`${step === 2 ? "text-primary-500" : "text-gray-500"} text-xs`}>Verifikasi OTP</h4>
</div>
<div className="flex flex-col items-center justify-center gap-2">
<div className={`${step === 3 ? "bg-primary-500" : "bg-primary-200"} px-5 py-2 rounded-md w-full`}></div>
<h4 className={`${step === 3 ? "text-primary-500" : "text-gray-500"} text-xs`}>Summon Password ^^</h4>
</div>
</div>
)
}
@@ -0,0 +1 @@
export * from './forgot-step';
+2 -1
View File
@@ -1 +1,2 @@
export * from "./forgot-step";
export * from "./forgot-step";
export * from "./otp-form";
+1
View File
@@ -0,0 +1 @@
export * from "./otp-form"
@@ -0,0 +1,60 @@
// eslint-disable-next-line @nx/enforce-module-boundaries
import { Input } from "@imphnen-frontend-service/ui/atoms";
import { ChangeEvent, DetailedHTMLProps, FC, InputHTMLAttributes, ReactElement, useRef, useState } from "react"
type TForgotStepProps = Omit<
DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
'size' | 'type'
> & {
};
export const OtpForm: FC<TForgotStepProps> = ({
step = 1,
...rest
}): ReactElement => {
const [cell, setCell] = useState(new Array(6).fill(""))
const inputRef = useRef([])
const handleChange = (index: number, e: ChangeEvent<HTMLInputElement>) => {
const value = e.target.value
if (!(/^[0-9]?$/.test(value))) return;
const newCell = [...cell]
newCell[index] = value
setCell(newCell)
if(value && index < 6 - 1){
(inputRef.current[index + 1] as HTMLInputElement).focus()
}
}
const handleKeyDown = (index: number, e: React.KeyboardEvent<HTMLInputElement>) => {
if(e.key === "Backspace" && !cell[index] && index > 0){
const newCell = [...cell]
newCell[index] = ""
setCell(newCell)
const ref = (inputRef.current[index - 1] as HTMLInputElement)
ref.focus()
}
}
return (
<div className="w-full grid grid-cols-6 gap-3 my-10">
{cell.map((v, i) => (
<Input
placeholder=""
ref={(el) => {
inputRef.current.push(el as never)
return inputRef.current[i]
}}
onChange={(e) => handleChange(i, e)}
onKeyDown={(e) => handleKeyDown(i, e)}
size="lg"
value={cell[i]}
/>
))}
</div>
)
}