Merge pull request #1205 from bluewave-labs/fix/fe/text-input-register

fix: fe/text input register
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-11-25 21:20:17 -08:00
commit 9d8ea82e7c
5 files changed
+27 -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"
@@ -6,6 +6,11 @@ import PropTypes from "prop-types";
const getSx = (theme, type, maxWidth) => { const getSx = (theme, type, maxWidth) => {
const sx = { const sx = {
maxWidth: maxWidth, maxWidth: maxWidth,
"& .MuiFormHelperText-root": {
position: "absolute",
bottom: `-${theme.spacing(12)}`,
minHeight: theme.spacing(12),
},
}; };
if (type === "url") { if (type === "url") {
@@ -57,6 +62,7 @@ const TextInput = forwardRef(
( (
{ {
id, id,
name,
type, type,
value, value,
placeholder, placeholder,
@@ -91,6 +97,7 @@ const TextInput = forwardRef(
</Typography> </Typography>
<TextField <TextField
id={id} id={id}
name={name}
type={fieldType} type={fieldType}
value={value} value={value}
placeholder={placeholder} placeholder={placeholder}
@@ -120,6 +127,7 @@ TextInput.displayName = "TextInput";
TextInput.propTypes = { TextInput.propTypes = {
type: PropTypes.string, type: PropTypes.string,
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
name: PropTypes.string,
value: PropTypes.string, value: PropTypes.string,
placeholder: PropTypes.string, placeholder: PropTypes.string,
isRequired: PropTypes.bool, isRequired: PropTypes.bool,
@@ -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