-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added routes and signup , signup pages
- Loading branch information
Showing
11 changed files
with
210 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
export function InputComponent({changeHandler, placeholder, reference}:{changeHandler?:()=> void, placeholder:string, reference:any}) { | ||
|
||
return <div> | ||
<input type="text" ref={reference} className="py-2 px-4 border rounded border-slate-800 " onChange={changeHandler} placeholder={placeholder}/> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const backendURL = "http://localhost:3000" | ||
//signin and signup | ||
export const signinURL = "/user/signin" //POST | ||
export const signupURL = "/user/signup" //POST | ||
|
||
//content | ||
export const userContentDeleteURL = "/user/content" | ||
//POST, GET, DELETE and auth | ||
|
||
//share links | ||
export const brainShareURL = "/user/brain/share" //POST and auth | ||
export const brainShareLink = "/user/brain/" //GET and non-auth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
import { Button } from "../components/ui/Button" | ||
import { InputComponent } from "../components/ui/input" | ||
import BrainLogo from "../assets/brain.png" | ||
import { SideBarItems } from "../components/ui/SideBar" | ||
import { useNavigate } from "react-router-dom" | ||
import { useRef } from "react" | ||
|
||
export function Signin() { | ||
|
||
return <div className="bg-purple-600 h-screen w-screen fixed top-0 left-0"> | ||
const usernameRef = useRef<any>() | ||
const passwordRef = useRef<any>() | ||
|
||
|
||
const navigate = useNavigate(); | ||
|
||
return <div className="bg-purple-600 h-screen w-screen fixed top-0 left-0 flex items-center justify-center"> | ||
<div className="h-96 w-72 bg-purple-300 rounded-md py-6 px-4 select-none flex flex-col items-center"> | ||
|
||
<SideBarItems variant="header" startIcon={BrainLogo} text="Brainly" /> | ||
<div className="space-y-4"> | ||
|
||
<InputComponent reference={usernameRef} placeholder="username" /> | ||
<InputComponent reference={passwordRef} placeholder="password" /> | ||
</div> | ||
|
||
<div className="button mt-8 flex justify-between gap-2"> | ||
<Button variant="primary" text="Sign In" loading={false} handlerClick={function() { | ||
console.log(usernameRef.current.value, passwordRef.current.value) | ||
}}/> | ||
<Button variant="secondary" text="Signup instead" handlerClick={function () { | ||
navigate("/signup") | ||
}} /> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,49 @@ | ||
import { Button } from "../components/ui/Button" | ||
import { InputComponent } from "../components/ui/input" | ||
import BrainLogo from "../assets/brain.png" | ||
import { SideBarItems } from "../components/ui/SideBar" | ||
import { useNavigate } from "react-router-dom" | ||
import { useRef } from "react" | ||
import axios from "axios" | ||
import { backendURL, signupURL } from "../config" | ||
|
||
export function Signup() { | ||
const usernameRef = useRef<any>() | ||
const passwordRef = useRef<any>() | ||
|
||
return <div className="bg-purple-600 h-screen w-screen fixed top-0 left-0"> | ||
async function sendData() { | ||
let username = usernameRef.current.value; | ||
let password = passwordRef.current.value; | ||
let response = await axios.post(backendURL+signupURL, { | ||
data:{ | ||
username, password | ||
} | ||
}) | ||
console.log(response) | ||
|
||
alert("user is added") | ||
} | ||
|
||
const navigate = useNavigate(); | ||
|
||
return <div className="bg-purple-600 h-screen w-screen fixed top-0 left-0 flex items-center justify-center"> | ||
<div className="h-96 w-72 bg-purple-300 rounded-md py-6 px-4 select-none flex flex-col items-center"> | ||
|
||
<SideBarItems variant="header" startIcon={BrainLogo} text="Brainly" /> | ||
<div className="space-y-4"> | ||
|
||
<InputComponent reference={usernameRef} placeholder="username" /> | ||
<InputComponent reference={passwordRef} placeholder="password" /> | ||
</div> | ||
|
||
<div className="button mt-8 flex justify-between gap-2"> | ||
<Button variant="primary" text="Sign Up" loading={false} handlerClick={sendData}/> | ||
<Button variant="secondary" text="Signin instead" handlerClick={function () { | ||
navigate("/") | ||
}} /> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
} |