From 43b41377994d860cbfb695da73f04df64361b03f Mon Sep 17 00:00:00 2001 From: hayaa1234 Date: Mon, 3 Jan 2022 16:01:48 +0200 Subject: [PATCH 1/6] added some style --- components/hospitalProfile.js | 38 ++++++--------- pages/_app.js | 2 +- pages/home_compnenet/Form2.js | 41 ++++++++++++++++ pages/home_compnenet/Table2.js | 89 ++++++++++++++++++++++++++++++++++ pages/index.js | 3 +- styles/hospitalProfile.css | 22 +++++++++ 6 files changed, 171 insertions(+), 24 deletions(-) create mode 100644 pages/home_compnenet/Form2.js create mode 100644 pages/home_compnenet/Table2.js create mode 100644 styles/hospitalProfile.css diff --git a/components/hospitalProfile.js b/components/hospitalProfile.js index 5f28f00..8103363 100644 --- a/components/hospitalProfile.js +++ b/components/hospitalProfile.js @@ -1,12 +1,15 @@ import axios from "axios"; import { useState } from "react"; - +import { GlobeAltIcon ,SearchIcon } from "@heroicons/react/outline"; +import Form2 from "../pages/home_compnenet/Form2"; +import Table2 from "../pages/home_compnenet/Table2" function HospitalProfile() { const [result, setResult] = useState([]); const [location, setLocation] = useState([]); const [bloodType, setBloodType] = useState([]); + let locationHandler = (e) => { setLocation(e.target.value) }; @@ -23,35 +26,26 @@ function HospitalProfile() { }; return ( <> -
+
hospital -

Isteqlal

- +

Isteqlal

-

- Website -

+
+ + istiqlal-hospital.com +
-
-
- - - - - -
+
+ - + + {/*
@@ -79,7 +73,7 @@ function HospitalProfile() { ); })} -
Name Location
+ */}
); diff --git a/pages/_app.js b/pages/_app.js index 6b01fc5..f57cc4a 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -2,7 +2,7 @@ import '../styles/globals.css' import '../styles/video.css' import '../styles/tailwind.css' import '../styles/form.css' - +import '../styles/hospitalProfile.css' function MyApp({ Component, pageProps }) { return } diff --git a/pages/home_compnenet/Form2.js b/pages/home_compnenet/Form2.js new file mode 100644 index 0000000..dca18c7 --- /dev/null +++ b/pages/home_compnenet/Form2.js @@ -0,0 +1,41 @@ +import React from 'react' +import { SearchIcon } from "@heroicons/react/outline"; + +export default function Form2(props) { + return ( + <> +
+
+
+
+
+
+
+
+ + +
+ +
+ + +
+ +
+
+
+ + +
+
+
+
+
+
+ + + + ) +} diff --git a/pages/home_compnenet/Table2.js b/pages/home_compnenet/Table2.js new file mode 100644 index 0000000..9b5ea56 --- /dev/null +++ b/pages/home_compnenet/Table2.js @@ -0,0 +1,89 @@ +/* This example requires Tailwind CSS v2.0+ */ +const people = [ + { + name: 'Jane Cooper', + title: 'Regional Paradigm Technician', + department: 'Optimization', + role: 'Admin', + email: 'jane.cooper@example.com', + image: + 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=4&w=256&h=256&q=60', + }, + // More people... + ] + + export default function Example() { + return ( +
+
+
+
+ + + + + + + + + + + + + + {people.map((person) => ( + + + + + + + + ))} + +
+ Name + + Location + + blood Type + + Phone Number + + Edit +
+
+
+ +
+
+
{person.name}
+
{person.email}
+
+
+
+
{person.title}
+
{person.department}
+
+ + Active + + {person.role}
+
+
+
+
+ ) + } \ No newline at end of file diff --git a/pages/index.js b/pages/index.js index 33b3629..7dcec77 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,13 +1,14 @@ import Head from 'next/head' import Homa_page from './home_compnenet/Homa_page' import HospitalProfile from '../components/hospitalProfile' + import UserProfile from '../components/userProfile' export default function Home() { return ( <> - + ) } diff --git a/styles/hospitalProfile.css b/styles/hospitalProfile.css new file mode 100644 index 0000000..d96f582 --- /dev/null +++ b/styles/hospitalProfile.css @@ -0,0 +1,22 @@ +/* #hospital-form-table form{ + display: flex; + flex-direction: row; + align-content: center; + align-items: center; + justify-content: space-evenly; + width:75%; + margin: auto; +} +#hospital-form-table form div{ + width: 30%; + display: flex; + flex-direction: row; + align-content: center; + align-items: center; + justify-content: space-evenly; +} + +#hospital-form-table form input[type="text"]{ + border:none; + border-bottom: 1px solid gray; +} */ \ No newline at end of file From 19fbeb648cb1371fd3d16d3373a5bb86999b2c1d Mon Sep 17 00:00:00 2001 From: yaseen1998 Date: Mon, 3 Jan 2022 16:48:05 +0200 Subject: [PATCH 2/6] login --- contexts/auth.js | 10 +- pages/TestForm.js | 29 +++++ pages/components/userProfile.js | 13 +-- pages/home_compnenet/LoginForm.js | 15 ++- pages/home_compnenet/Signupform.js | 118 +++++++++++++-------- pages/home_compnenet/Signupfromhospital.js | 14 +-- pages/index.js | 3 +- styles/video.css | 6 +- 8 files changed, 137 insertions(+), 71 deletions(-) create mode 100644 pages/TestForm.js diff --git a/contexts/auth.js b/contexts/auth.js index a824654..c75e798 100644 --- a/contexts/auth.js +++ b/contexts/auth.js @@ -3,7 +3,7 @@ import jwt from 'jsonwebtoken'; import axios from 'axios' const baseUrl = "http://127.0.0.1:8000/" // const baseUrl = process.env.NEXT_PUBLIC_API_URL; -const tokenUrl = baseUrl + 'donater/auth/'; +const tokenUrl = baseUrl + 'accounts/donater/auth/'; const AuthContext = createContext(); @@ -21,7 +21,7 @@ export function AuthProvider(props) { login, logout, }); - + async function login(username, password) { const response = await axios.post(tokenUrl, { username, password }); @@ -30,15 +30,11 @@ export function AuthProvider(props) { const newState = { tokens: response.data, - // user: { - // username: response.data.username, - // id: decodedAccess.user_id - // }, } setState(prevState => ({ ...prevState, ...newState })); + } - function logout() { const newState = { tokens: null, diff --git a/pages/TestForm.js b/pages/TestForm.js new file mode 100644 index 0000000..660f75e --- /dev/null +++ b/pages/TestForm.js @@ -0,0 +1,29 @@ +import React from 'react' +import axios from 'axios'; +export default function Testfrom() { + const adddata = async(e)=>{ + e.preventDefault(); + let city={city:e.target.city.value} + let area={area:e.target.area.value} + const area_id = await axios.post('http://127.0.0.1:8000/address/area/',area) + const city_id = await axios.post('http://127.0.0.1:8000/address/city/',city) + + let address={ + area:area_id.data.id, + city:city_id.data.id, + direction:e.target.direction.value + } + const address_id = await axios.post('http://127.0.0.1:8000/address/address/',address) + console.log(address_id.data); + } + return ( +
+
+ + + + +
+
+ ) +} \ No newline at end of file diff --git a/pages/components/userProfile.js b/pages/components/userProfile.js index 3234575..991afa4 100644 --- a/pages/components/userProfile.js +++ b/pages/components/userProfile.js @@ -2,12 +2,13 @@ import { useState, useEffect } from "react"; import EditForm from "./editForm"; import axios from "axios"; import { useRouter } from 'next/router' -import { PencilAltIcon } from "@heroicons/react/outline"; +import { useAuth } from "../../contexts/auth"; +// import { PencilAltIcon } from "@heroicons/react/outline"; function UserProfile(props) { - // const router = useRouter(); - // let profile = JSON.parse(router.query.data) - + const { login ,tokens} = useAuth() + console.log(tokens); + const [result, setResult] = useState([]); const [editForm, setEditForm] = useState(false); @@ -48,11 +49,11 @@ function UserProfile(props) { Personal Information
- + /> */}

Location:

{result.location}

diff --git a/pages/home_compnenet/LoginForm.js b/pages/home_compnenet/LoginForm.js index 29ac80f..b8506ad 100644 --- a/pages/home_compnenet/LoginForm.js +++ b/pages/home_compnenet/LoginForm.js @@ -18,10 +18,17 @@ export default function LoginForm() { try{ await login(username, password) - // router.push({ - // pathname: '/components/userProfile', - // query: { data: JSON.stringify(tokens)} - // }); + if (tokens.Role == 'Doner'){ + router.push({ + pathname: '/components/userProfile', + }); + } + if (tokens.Role == 'Hospital'){ + router.push({ + pathname: '/components/hospitalProfile', + }); + } + } catch(error){ console.log('the password or username not correct'); diff --git a/pages/home_compnenet/Signupform.js b/pages/home_compnenet/Signupform.js index 2516b5e..ff2e703 100644 --- a/pages/home_compnenet/Signupform.js +++ b/pages/home_compnenet/Signupform.js @@ -11,15 +11,21 @@ export default function Signupform() { const handlesubmitsignup = async (e) => { let data = new FormData(); e.preventDefault(); - + const url =' http://127.0.0.1:8000/' + let blood = { + blood_type:e.target.blood_type.value, + description : e.target.description.value + } + const create_blood =await axios.post(`${url}blood/add/`, blood) + data.append("first_name", e.target.firstname.value); data.append("username", e.target.username.value); data.append("email", e.target.email.value); data.append("password", e.target.password.value); - data.append("blood_type", e.target.blood_type.value); - data.append("roles", "Donater"); - let url = "http://127.0.0.1:8000/donater/signup/"; - const create = axios.post(url, data, { + data.append("blood_type", create_blood.data.id); + data.append("roles", "Doner"); + let urls = `${url}accounts/donater/signup/`; + const create = axios.post(urls, data, { headers: { "content-type": "multipart/form-data", }, @@ -47,6 +53,7 @@ export default function Signupform() {
+
-
- - +
+ + +
-
- -
- - +
+
+ + +
+
+ + +
+
- + > + + + + + + + + +
- + +
+
- +
- +
+