integrate TextInput into register page

This commit is contained in:
Alex Holliday committed 2024-11-26 13:14:46 +08:00
1 parent 7b392bc454
commit 475e92787e
4 files changed
+19 -14

No files matched your search

+1 -2
View File
@@ -24,10 +24,9 @@ const Check = ({ text, noHighlightText, variant = "info", outlined = false }) =>
const theme = useTheme(); const theme = useTheme();
const colors = { const colors = {
success: theme.palette.success.main, success: theme.palette.success.main,
error: theme.palette.error.contrastText, error: theme.palette.error.main,
info: theme.palette.info.border, info: theme.palette.info.border,
}; };
return ( return (
<Stack <Stack
direction="row" direction="row"
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { Box, Button, Stack, Typography } from "@mui/material"; import { Box, Button, Stack, Typography } from "@mui/material";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded"; import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import Field from "../../../../Components/Inputs/Field"; import TextInput from "../../../../Components/Inputs/TextInput";
StepOne.propTypes = { StepOne.propTypes = {
form: PropTypes.object, form: PropTypes.object,
@@ -60,7 +60,7 @@ function StepOne({ form, errors, onSubmit, onChange, onBack }) {
display="grid" display="grid"
gap={{ xs: theme.spacing(8), sm: theme.spacing(12) }} gap={{ xs: theme.spacing(8), sm: theme.spacing(12) }}
> >
<Field <TextInput
id="register-firstname-input" id="register-firstname-input"
label="Name" label="Name"
isRequired={true} isRequired={true}
@@ -68,10 +68,11 @@ function StepOne({ form, errors, onSubmit, onChange, onBack }) {
autoComplete="given-name" autoComplete="given-name"
value={form.firstName} value={form.firstName}
onChange={onChange} onChange={onChange}
error={errors.firstName} error={errors.firstName ? true : false}
helperText={errors.firstName}
ref={inputRef} ref={inputRef}
/> />
<Field <TextInput
id="register-lastname-input" id="register-lastname-input"
label="Surname" label="Surname"
isRequired={true} isRequired={true}
@@ -79,7 +80,9 @@ function StepOne({ form, errors, onSubmit, onChange, onBack }) {
autoComplete="family-name" autoComplete="family-name"
value={form.lastName} value={form.lastName}
onChange={onChange} onChange={onChange}
error={errors.lastName} error={errors.lastName ? true : false}
helperText={errors.lastName}
ref={inputRef}
/> />
</Box> </Box>
<Stack <Stack
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { Box, Button, Stack, Typography } from "@mui/material"; import { Box, Button, Stack, Typography } from "@mui/material";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded"; import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import Field from "../../../../Components/Inputs/Field"; import TextInput from "../../../../Components/Inputs/TextInput";
import Check from "../../../../Components/Check/Check"; import Check from "../../../../Components/Check/Check";
import { useValidatePassword } from "../../hooks/useValidatePassword"; import { useValidatePassword } from "../../hooks/useValidatePassword";
@@ -31,6 +31,7 @@ function StepThree({ onSubmit, onBack }) {
}, []); }, []);
const { handleChange, feedbacks, form, errors } = useValidatePassword(); const { handleChange, feedbacks, form, errors } = useValidatePassword();
console.log(errors);
return ( return (
<> <>
<Stack <Stack
@@ -59,7 +60,7 @@ function StepThree({ onSubmit, onBack }) {
display="grid" display="grid"
gap={{ xs: theme.spacing(8), sm: theme.spacing(12) }} gap={{ xs: theme.spacing(8), sm: theme.spacing(12) }}
> >
<Field <TextInput
type="password" type="password"
id="register-password-input" id="register-password-input"
name="password" name="password"
@@ -69,10 +70,10 @@ function StepThree({ onSubmit, onBack }) {
autoComplete="current-password" autoComplete="current-password"
value={form.password} value={form.password}
onChange={handleChange} onChange={handleChange}
error={errors.password && errors.password[0]} error={errors.password && errors.password[0] ? true : false}
ref={inputRef} ref={inputRef}
/> />
<Field <TextInput
type="password" type="password"
id="register-confirm-input" id="register-confirm-input"
name="confirm" name="confirm"
@@ -82,7 +83,7 @@ function StepThree({ onSubmit, onBack }) {
autoComplete="current-password" autoComplete="current-password"
value={form.confirm} value={form.confirm}
onChange={handleChange} onChange={handleChange}
error={errors.confirm && errors.confirm[0]} error={errors.confirm && errors.confirm[0] ? true : false}
/> />
</Box> </Box>
<Stack <Stack
@@ -3,6 +3,7 @@ import PropTypes from "prop-types";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { Box, Button, Stack, Typography } from "@mui/material"; import { Box, Button, Stack, Typography } from "@mui/material";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded"; import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import TextInput from "../../../../Components/Inputs/TextInput";
import Field from "../../../../Components/Inputs/Field"; import Field from "../../../../Components/Inputs/Field";
StepTwo.propTypes = { StepTwo.propTypes = {
@@ -55,7 +56,7 @@ function StepTwo({ form, errors, onSubmit, onChange, onBack }) {
display="grid" display="grid"
gap={{ xs: theme.spacing(12), sm: theme.spacing(16) }} gap={{ xs: theme.spacing(12), sm: theme.spacing(16) }}
> >
<Field <TextInput
type="email" type="email"
id="register-email-input" id="register-email-input"
label="Email" label="Email"
@@ -65,7 +66,8 @@ function StepTwo({ form, errors, onSubmit, onChange, onBack }) {
value={form.email} value={form.email}
onInput={(e) => (e.target.value = e.target.value.toLowerCase())} onInput={(e) => (e.target.value = e.target.value.toLowerCase())}
onChange={onChange} onChange={onChange}
error={errors.email} error={errors.email ? true : false}
helperText={errors.email}
ref={inputRef} ref={inputRef}
/> />
<Stack <Stack