Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
368 changes: 358 additions & 10 deletions client/package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@react-navigation/native": "^6.0.8",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.3",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.1.3",
"encrypt-storage": "^2.2.6",
"react": "^17.0.2",
"react-bootstrap": "^2.2.3",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
"react-native-web": "^0.17.7",
"react-router-dom": "^6.2.2",
"react-scripts": "5.0.0",
"react-toastify": "^8.2.0",
"react-use-navigate": "^0.1.1",
"styled-components": "^5.3.3",
"use-navigation": "0.0.3",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
17 changes: 15 additions & 2 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="/components/pagecss/loginregister.css" />

<title>Essential Health</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div class="mainbg" id="root"></div>
<div id="root"></div>
</body>
<!--Start of Tawk.to Script-->
<script type="text/javascript">
var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();
(function(){
var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
s1.async=true;
s1.src='https://embed.tawk.to/624f8379c72df874911df262/1g039j58j';
s1.charset='UTF-8';
s1.setAttribute('crossorigin','*');
s0.parentNode.insertBefore(s1,s0);
})();
</script>
<!--End of Tawk.to Script-->
</html>
15 changes: 10 additions & 5 deletions client/src/App.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
@import url("https://fonts.googleapis.com/css2?family=Sora&display=swap");

* {
font-family: "Sora", sans-serif;
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: "Sora", sans-serif;
box-sizing: border-box;
margin: 0;
padding: 0;
}
.background {
background-image: url("components/pictures/peace.jpg");
background-size: "cover";
background-repeat: "no-repeat";
height: 100vh;
}
173 changes: 103 additions & 70 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ import {
Route,
Navigate,
} from "react-router-dom";

import Home from "./components/Home";
import Login from "./components/Login";
import Register from "./components/Register";
import PersonalForm from "./components/PersonalForm";
import MedicalForm from "./components/MedicalForm";
import Navbar from "./components/Navbar/nav";


import Navbar from "./components/navbar";
import { encryptStorage } from "../src/components/encrypt";
import MedicalForm from "./components/MedicalForm";
import ListPersonalForm from "./components/ListPersonalForm";
import Results from "./components/Results"
toast.configure();
function App(props) {
// const [username, setUsername] = useState("");

function App() {
const [username, setUsername] = useState("");
const [user_id, setuserid] = useState("");
// we want to make sure it set to false first
const [isAuthenticated, setAuthenticated] = useState(false);

//this is going to the be toggle function to set the auth
const setAuth = (Boolean) => {
setAuthenticated(Boolean); //this will change the state
Expand All @@ -31,7 +34,7 @@ function App(props) {
async function isAuth() {
try {
//check if the user is still validated
const response = await fetch("http://localhost:4001/auth/is-verify", {
const response = await fetch("http://localhost:3005/auth/is-verify", {
method: "GET",
headers: { token: localStorage.token },
});
Expand All @@ -45,6 +48,10 @@ function App(props) {
}
useEffect(() => {
isAuth();
//in the login comp we are setting user id
// this app.js we are doing reading the value user id val that was set in the login comp
// and setting the user id value of the app comp to value from what we receive the
// encrypt storage
const storedUserID = encryptStorage.getItem("user_id");
//const value = encryptStorage.decryptString(storedUserID);
setuserid(storedUserID); //
Expand All @@ -53,9 +60,11 @@ function App(props) {
return (
<Fragment>
<Router>
<Navbar setAuth={setAuth} />
{/* reason why we use render instead of component props is because
anytime we send props to a component we don't want it to remount /}
<div className="background">
<Navbar setAuth={setAuth} user_id={user_id} />
{/* reason why we use render instead of component props is because
anytime we send props to a component we don't want it to remount /}

!isAuthenticated ?
(<Route exact path="/login">
<Login/>
Expand All @@ -65,66 +74,90 @@ function App(props) {
<Link to="/home"/>
</Route>)
*/}
<div className="container">
<Routes>
<Route
exact
path="/login"
element={
!isAuthenticated ? (
<Login setAuth={setAuth} />
) : (
<Navigate to="/home" />
)
}
/>
<Route
exact
path="/register"
element={
!isAuthenticated ? (
<Register setAuth={setAuth} />
) : (
<Navigate to="/home" />
)
}
/>
<Route
exact
path="/home"
element={
isAuthenticated ? (
<Home setAuth={setAuth} />
) : (
<Navigate to="/login" />
)
}
/>
<Route
exact
path="/pform"
element={
isAuthenticated ? (
<PersonalForm setAuth={setAuth} user_id={user_id} />
) : (
<Navigate to="/home" />
)
}
/>
<Route
exact
path="/mform"
element={
isAuthenticated ? (
<MedicalForm setAuth={setAuth} user_id={user_id} />
) : (
<Navigate to="/home" />
)
}
/>
{/* <Route exact path="/pfrom" element={<Personalform/>}/> */}
{/* {/ <Route exact path="/home" element={props => <Home {...props} />} /> */}
</Routes>
<div className="container">
<Routes>
<Route
exact
path="/login"
element={
!isAuthenticated ? (
<Login setAuth={setAuth} />
) : (
<Navigate to="/home" />
)
}
/>
<Route
exact
path="/register"
element={
!isAuthenticated ? (
<Register setAuth={setAuth} />
) : (
<Navigate to="/home" />
)
}
/>
<Route
exact
path="/home"
element={
isAuthenticated ? (
<Home setAuth={setAuth} user_id={user_id} />
) : (
<Navigate to="/login" />
)
}
/>
<Route
exact
path="/pform"
element={
isAuthenticated ? (
<PersonalForm setAuth={setAuth} user_id={user_id} />
) : (
<Navigate to="/home" />
)
}
/>
<Route
exact
path="/mform"
element={
isAuthenticated ? (
<MedicalForm setAuth={setAuth} user_id={user_id} />
) : (
<Navigate to="/home" />
)
}
/>
<Route
exact
path="/profile"
element={
isAuthenticated ? (
<ListPersonalForm setAuth={setAuth} user_id={user_id} />
) : (
<Navigate to="/home" />
)
}
/>
<Route
exact
path="/results"
element={
isAuthenticated ? (
<Results setAuth={setAuth} user_id={user_id} />
) : (
<Navigate to="/home" />
)
}
/>

{/* <Route exact path="/pfrom" element={<Personalform/>}/> */}
{/* {/ <Route exact path="/home" element={props => <Home {...props} />} /> */}
</Routes>
</div>
</div>
</Router>
</Fragment>
Expand Down
94 changes: 94 additions & 0 deletions client/src/components/EditMForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import React, { useState, setShow } from "react";
import { Button, Form, Modal } from "react-bootstrap";
function EditMForm(props) {
console.log(props);
const [show, setShow] = useState(false);

const handleClose = () => setShow(false);
const handleShow = () => setShow(true);

const handleSubmit = async function (event) {
console.log(event);
event.preventDefault();
const userId = props.MedicalForm.user_id;
const any_medication = event.target.form.elements.any_medication.value;
const medication_description =
event.target.form.elements.medication_description.value;
const insurance = event.target.form.elements.insurance.value;
// const phoneNumber = event.target.form.elements.phoneNumber.value;

const body = { any_medication, medication_description, insurance };
const response = await fetch(
`http://localhost:3005/MForm/update/${userId}`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
token: localStorage.token,
},
body: JSON.stringify(body),
}
);
console.log(response);
};

return (
<>
<Button variant="primary" onClick={handleShow}>
Launch demo modal
</Button>

<Modal show={show} onHide={handleClose}>
<Modal.Header closeButton>
<Modal.Title>Modal heading</Modal.Title>
</Modal.Header>
<Modal.Body>
<Form>
<Form.Group className="mb-3">
<Form.Label>First Name</Form.Label>
<Form.Control
name="any_medication"
defaultValue={props.MedicalForm.any_medication}
type="text"
/>
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Last Name</Form.Label>
<Form.Control
name="medication_description"
defaultValue={props.MedicalForm.medication_description}
type="text"
/>
</Form.Group>
<Form.Group className="mb-3">
<Form.Label>Occupation</Form.Label>
<Form.Control
name="insurance"
defaultValue={props.MedicalForm.insurance}
type="text"
/>
</Form.Group>

<Button variant="primary" onClick={handleSubmit}>
Save Changes
</Button>
<Button variant="secondary" onClick={handleClose}>
Close
</Button>
</Form>
</Modal.Body>
<Modal.Footer>
{/* <Button variant="secondary" onClick={handleClose}>
Close
</Button> */}
{/* <Button variant="primary" onClick={handleSubmit}>
Save Changes
</Button>
*/}
</Modal.Footer>
</Modal>
</>
);
}

export default EditMForm;
Loading