-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from mpumzee/ft_add_user_list_fe
Added user sign up view
- Loading branch information
Showing
15 changed files
with
186 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contributors | ||
|
||
## This project is a result of the hard work of the following volunteers |
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,19 @@ | ||
# Generated by Django 4.2.4 on 2024-01-26 20:49 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("accounts", "0002_profile"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="profile", | ||
name="follows", | ||
field=models.ManyToManyField( | ||
blank=True, related_name="followers", to="accounts.profile" | ||
), | ||
), | ||
] |
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
Binary file not shown.
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 |
---|---|---|
@@ -1,3 +1,60 @@ | ||
import { Button, Card, TextInput, Avatar } from "flowbite-react"; | ||
import { useState } from "react"; | ||
import axios from "axios" | ||
|
||
export default function Registration() { | ||
return <div>Registration</div>; | ||
const [data, setData] = useState({ | ||
email: "", | ||
password: "", | ||
first_name: "", | ||
last_name: "", | ||
username: "", | ||
}) | ||
|
||
const onChange = (e) => { | ||
setData({ ...data, [e.target.id]: e.target.value }) | ||
} | ||
|
||
const onSubmit = () => { | ||
if (data.email === "" || data.password === "" || data.first_name === "" || data.last_name === "" || data.username === "") ( | ||
alert("All fields are required") | ||
) | ||
axios.post("http://localhost:8000/api/signup", data).then((res) => { | ||
alert("Successfully signed up") | ||
}).catch((err) => { | ||
alert("Failed to submit") | ||
}) | ||
} | ||
|
||
return <center style={{ marginTop: "250px" }}> | ||
<Card className="max-w-md"> | ||
<Avatar img="/user.png" rounded size="xl" /> | ||
<h3 className="text-center text-xl mb-4 mt-4">Welcome to Chit-Chat</h3> | ||
<form className="flex flex-col gap-4"> | ||
<div> | ||
<TextInput id="first_name" placeholder="First Name" required type="text" onChange={onChange} /> | ||
</div> | ||
<div> | ||
<TextInput id="last_name" placeholder="Last Name" required type="text" onChange={onChange} /> | ||
</div> | ||
<div> | ||
<TextInput id="username" placeholder="Username" required type="text" onChange={onChange} /> | ||
</div> | ||
<div> | ||
<TextInput id="email" placeholder="Email" required type="email" onChange={onChange} /> | ||
</div> | ||
<div> | ||
<TextInput | ||
id="password" | ||
required | ||
type="password" | ||
placeholder="Password" | ||
onChange={onChange} | ||
/> | ||
</div> | ||
|
||
<Button onClick={onSubmit}>Register</Button> | ||
</form> | ||
</Card> | ||
</center> | ||
} |
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,6 @@ | ||
import Registration from "../../components/registration"; | ||
|
||
|
||
export default function SignUpView() { | ||
return <Registration /> | ||
} |
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,25 @@ | ||
import React, { useEffect, useState } from "react"; | ||
|
||
function UsersList() { | ||
const [users, setUsers] = useState([]); | ||
|
||
useEffect(() => { | ||
fetch('http://127.0.0.1:9000/api/profiles/') | ||
.then(response => response.json()) | ||
.then(data => setUsers(data)); | ||
|
||
}, []); | ||
|
||
return ( | ||
<div> | ||
<h1>Users</h1> | ||
<ul> | ||
{users.map(user => ( | ||
<li key={user.id}>{user.user}</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
|
||
export default UsersList; |