Skip to content

Commit

Permalink
update to sign up and signin page
Browse files Browse the repository at this point in the history
  • Loading branch information
dcgleason committed Dec 29, 2022
1 parent 7066a35 commit 7a0ea3c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions pages/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { CSS } from '@dnd-kit/utilities';





const UserComponent = ({
id,
body
Expand Down
2 changes: 1 addition & 1 deletion pages/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function LoginSignupForm() {
// Use axios to send a POST request to the /login or /signup route
// depending on whether the user is trying to login or sign up
const res = await axios.post(
'/login',
'http://localhost:3000/login/signin',
body,
config
);
Expand Down
29 changes: 13 additions & 16 deletions pages/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ import axios from 'axios';
import { Link } from 'react-router-dom';

function SignUpPage() {
const [formData, setFormData] = useState({
username: '',
password: '',
});
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");

const { username, password } = formData;

const onChange = e =>
setFormData({ ...formData, [e.target.name]: e.target.value });

const onSubmit = async e => {
e.preventDefault();
Expand All @@ -25,16 +20,17 @@ function SignUpPage() {
const body = JSON.stringify({ username, password });

try {
console.log("body: ", body);
// Use axios to send a POST request to the /signup route
const res = await axios.post(
'/register',
'http://localhost:3001/login/signup',
body,
config
);

console.log(res.data);
} catch (err) {
console.error(err.response.data);
console.error(err.response);
}
};

Expand All @@ -47,7 +43,7 @@ function SignUpPage() {
src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600"
alt="Your Company"
/>
<h2 className="mt-6 text-center text-3xl font-bold tracking-tight text-gray-900">Sign in to your account</h2>
<h2 className="mt-6 text-center text-3xl font-bold tracking-tight text-gray-900">Sign up for your account</h2>
<p className="mt-2 text-center text-sm text-gray-600">
Or{' '}
<a href="#" className="font-medium text-indigo-600 hover:text-indigo-500">
Expand All @@ -58,20 +54,20 @@ function SignUpPage() {

<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div className="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
<form className="space-y-6" onSubmit={e => onSubmit(e)}>
<form className="space-y-6" >
<div>
<label htmlFor="email" className="block text-sm font-medium text-gray-700">
Email address
</label>
<div className="mt-1">
<input
id="email"
name="email"
name="username"
type="email"
autoComplete="email"
required
value={username}
onChange={e => onChange(e)}
onChange={e => setUsername(e.target.value)}
required
// autoComplete="email"
className="block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm"
/>
</div>
Expand All @@ -87,7 +83,7 @@ function SignUpPage() {
name="password"
type="password"
value={password}
onChange={e => onChange(e)}
onChange={e => setPassword(e.target.value)}
autoComplete="current-password"
required
className="block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm"
Expand Down Expand Up @@ -118,6 +114,7 @@ function SignUpPage() {
<div>
<button
type="submit"
onClick={e => onSubmit(e)}
className="flex w-full justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
Sign up
Expand Down

0 comments on commit 7a0ea3c

Please sign in to comment.