Skip to content

Commit

Permalink
admin details added to local storage. Submit button on welcome page r…
Browse files Browse the repository at this point in the history
…outed to first steps pages
  • Loading branch information
yawcoder committed Oct 11, 2024
1 parent cbda6f7 commit 1037efa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/components/forms/AdminForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ import { Label } from "../ui/label";
export default function AdminForm({
defaultValues = {},
customSubmitText = "Submit",
onSubmit
}) {
return (
<form
className="grid gap-4 md:grid-cols-2"
onSubmit={(e) => {
e.preventDefault();
// update admin details
}}
onSubmit={onSubmit}
>
<Label className="">
<span className="sr-only">first name</span>
<Input
type="text"
placeholder="firstName"
placeholder="First Name"
name="firstName"
defaultValue={defaultValues?.firstName ?? ""}
required
/>
Expand All @@ -29,7 +28,8 @@ export default function AdminForm({
<span className="sr-only">last name</span>
<Input
type="text"
placeholder="lastName"
placeholder="Last Name"
name="lastName"
defaultValue={defaultValues?.lastName ?? ""}
required
/>
Expand All @@ -39,6 +39,7 @@ export default function AdminForm({
<Input
type="email"
placeholder="Email"
name="email"
defaultValue={defaultValues?.email ?? ""}
required
/>
Expand Down
23 changes: 22 additions & 1 deletion src/pages/Welcome-Page.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import AdminForm from "@/components/forms/AdminForm";
import { useLocalStorage } from "@uidotdev/usehooks";
import { useState } from "react";
import { useNavigate } from "react-router-dom";

function WelcomePage() {
const navigate = useNavigate();

function handleSubmit(e){
e.preventDefault();

const adminData = {
firstName: e.target.firstName.value,
lastName: e.target.lastName.value,
email: e.target.email.value,
}

localStorage.setItem("admin", JSON.stringify(adminData))
navigate("/app/first-group");

}



return (
<div className="welcome-page-container h-screen w-full flex flex-row gap-2 ">
<div className="welcome-images relative hidden lg:flex lg:w-[50%] flex-wrap ">
Expand Down Expand Up @@ -34,7 +55,7 @@ function WelcomePage() {
Join now and be among the first to try it out! Just fill out your
name and email, it’s simple as that!
</p>
<AdminForm></AdminForm>
<AdminForm onSubmit={handleSubmit}/>
</div>
</div>
</div>
Expand Down

0 comments on commit 1037efa

Please sign in to comment.