This commit is contained in:
Kenneth Jannette
2024-01-11 20:15:42 -06:00
parent 605f3983ed
commit 88fd2b630c

View File

@@ -23,9 +23,8 @@ import "../../styles/signup.scss";
const SignupPage = () => { const SignupPage = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const [notice, setNotice] = useState(""); const [notice, setNotice] = useState("");
const [isMobile, setIsMobile] = useState(window.innerWidth < 440);
const fieldsChunkSize = 2; const fieldsChunkSize = 2;
const [isBusy, setIsBusy] = useState(false); const [isBusy, setIsBusy] = useState(false);
const [data, setData] = useState(getFormDataDefaults(signupfields)); const [data, setData] = useState(getFormDataDefaults(signupfields));
@@ -113,14 +112,35 @@ const SignupPage = () => {
} }
}; };
return ( const MobileForm = () => {
<div className="signup-super-container"> return splitEvery(
<div className="signup-sub-container"> Object.keys(signupfields).slice(0, -2),
<div className="signup-header"> fieldsChunkSize
<h1 className="signup-header-text">Create a Novodraft account</h1> ).map((names, j) => (
</div> <Col key={`row${j}`}>
<Form className="signup-form"> {names.map((name, i) => (
{splitEvery( <Col key={`${name}${i + fieldsChunkSize * j}`} className="mb-3">
<TextInput
name={name}
value={data[name].value}
onChange={(e) => handleChangeInput(e, name)}
error={data[name].error}
message={data[name].message}
label={
data[name].value.length === 0 ? signupfields[name].label : ""
}
type={signupfields[name].type}
values={signupfields[name].values}
disabled={isBusy}
/>
</Col>
))}
</Col>
));
};
const DesktopForm = () => {
return splitEvery(
Object.keys(signupfields).slice(0, -2), Object.keys(signupfields).slice(0, -2),
fieldsChunkSize fieldsChunkSize
).map((names, j) => ( ).map((names, j) => (
@@ -134,9 +154,7 @@ const SignupPage = () => {
error={data[name].error} error={data[name].error}
message={data[name].message} message={data[name].message}
label={ label={
data[name].value.length === 0 data[name].value.length === 0 ? signupfields[name].label : ""
? signupfields[name].label
: ""
} }
type={signupfields[name].type} type={signupfields[name].type}
values={signupfields[name].values} values={signupfields[name].values}
@@ -145,7 +163,17 @@ const SignupPage = () => {
</Col> </Col>
))} ))}
</Row> </Row>
))} ));
};
return (
<div className="signup-super-container">
<div className="signup-sub-container">
<div className="signup-header">
<h1 className="signup-header-text">Create a Novodraft account</h1>
</div>
<Form className="signup-form">
{isMobile ? <MobileForm /> : <DesktopForm />}
<Row> <Row>
<Col className="mb-3"> <Col className="mb-3">
<TextInput <TextInput