diff --git a/components/Cahngepas.js b/components/Cahngepas.js new file mode 100644 index 0000000..b988412 --- /dev/null +++ b/components/Cahngepas.js @@ -0,0 +1,81 @@ +import React from 'react' +import axios from 'axios'; +export default function Cahngepas(props) { + const url = 'https://lifeshareproject.herokuapp.com/' + console.log(props.token); + const handlesubmit=async(e)=>{ + e.preventDefault(); + let password = { + new_password:e.target.new_password.value, + old_password : e.target.old_password.value + + } + const config = { + headers:{'Authorization':`Bearer ${props.token}`}, + } + const change = await axios.put(`${url}accounts/api/change-password/`,password,config) + console.log(change.data); + } + + return ( +
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ ) +} diff --git a/components/EditHospital.js b/components/EditHospital.js new file mode 100644 index 0000000..6c764dc --- /dev/null +++ b/components/EditHospital.js @@ -0,0 +1,267 @@ +import { useState, useEffect } from "react"; +import axios from "axios"; +// import { comment } from "postcss"; +// import { Component } from "react/cjs/react.production.min"; +import { useAuth } from "../contexts/auth"; + +export default function EditHospital(props) { + let url = 'https://lifeshareproject.herokuapp.com/' + const [address, setaddress] = useState(""); + const { tokens } = useAuth(); + // useEffect(async () => { + // await axios + // .get(`${url}address/address/${props.result.address}/`) + // .then((data) => { + // setaddress(data.data) + // console.log(data); + // }); + // }, []); + + const handlesubmit = async (e) => { + e.preventDefault(); + let area = { + area: e.target.Area.value, + + } + let city = { + city: e.target.City.value, + + } + const Area = await axios.post(`${url}address/area/`, area) + const City = await axios.post(`${url}address/city/`, city) + let address = { + + area: Area.data.id, + city: City.data.id, + direction: e.target.direction.value + } + + const Address = await axios.post(`${url}address/address/`, address) + console.log(Area.data); + console.log(City.data); + console.log(Address.data); + + console.log(e.target.img.files[0]); + let data = new FormData(); + + data.append("first_name", e.target.firstname.value); + data.append("username", e.target.username.value); + data.append("email", e.target.email.value); + if (e.target.img.files[0]){ + data.append("image", e.target.img.files[0]); + } + + data.append("phone_number", e.target.phone_number.value); + data.append("address", Address.data.id); + data.append("website", e.target.Website.value); + + let urls = `${url}accounts/hospital/${tokens.id}/`; + + + + axios.put(urls, data, { + headers: { + "content-type": "multipart/form-data", + }, + }) + .then((res) => { + console.log(res); + props.setprofile(res.data); + props.setedit(false) + + }); + }; + + const closing = () => { + props.setedit(false) + } + + return ( + <> +
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + + +
+
+ + {/* {address.area && */} + + {/* } */} +
+
+ +
+ +
+ +
+ + + + +
+
+
+ + +
+
+
+
+ + +
+ +
+
+
+
+
+ +