Skip to content

Commit

Permalink
Merge pull request #36 from ChangePlusPlusVandy/app-97-addPassenger
Browse files Browse the repository at this point in the history
App 97 add passenger
  • Loading branch information
jacoblurie29 authored Apr 12, 2024
2 parents 78cacfb + 98cf7ec commit 0e107e3
Show file tree
Hide file tree
Showing 12 changed files with 532 additions and 14 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@hookform/resolvers": "^3.3.4",
"axios": "^1.6.7",
"axios": "^1.6.8",
"@tanstack/react-query": "^5.28.6",
"dotenv": "^16.3.1",
"moon-loader": "^0.1.0",
Expand Down
38 changes: 38 additions & 0 deletions src/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,44 @@ export const createUser = (
})
.then((res) => res.data);

export const createPassenger = (
passenger: {
fields: {
"First Name": string;
"Last Name": string;
Relationship:
| "Mother"
| "Father"
| "Step-mother"
| "Step-father"
| "Legal Guardian"
| "Spouse"
| "Family Member"
| "Other Caregiver";
"Date of Birth": Date | string;
Diagnoses?: (string | undefined)[];
Gender: "Male" | "Female" | "Other";
Street: string;
City: string;
State: string;
Zip: string;
Country: string;
"Cell Phone": string;
Email: string;
Waiver: boolean;
};
},
userId: string,
token?: string | null,
): Promise<PassengerData> =>
axios
.post(`${process.env.VITE_HOST}/passenger/${userId}`, passenger, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => res.data);

export const linkUser = (
airtableRecordId: string,
token?: string | null,
Expand Down
8 changes: 8 additions & 0 deletions src/pages/PassengersPage/PassengersPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
font-weight: 700;
color: var(--miracle-color-dark);
margin-top: 2rem;
display: flex;
align-items: center;
}

.description {
Expand All @@ -43,8 +45,14 @@
justify-content: space-evenly;
justify-content: flex-start;
margin-top: 2rem;
overflow-x: auto;
overflow-y: hidden;
}

.passengerCard {
margin-right: 3rem;
}

.plusButton {
margin-left: 0.5rem;
}
17 changes: 15 additions & 2 deletions src/pages/PassengersPage/PassengersPage.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import styles from "./PassengersPage.module.css";
import PatientCard from "./components/PatientCard/PatientCard";
import PassengerCard from "./components/PassengerCard/PassengerCard";
import PlusButton from "./components/PlusButton/PlusButton";
import AddPassengerModal from "./components/AddPassengerModal/AddPassengerModal";
import { getAccompanyingPassengers, getPassengers } from "../../api/queries";
import { useUserContext } from "../../context/User.context";
import { useNavigationContext } from "../../context/Navigation.context";
import { Tabs } from "../../layout/SideBar/SideBar.definitions";
import { useQuery } from "@tanstack/react-query";
import { useAuth } from "@clerk/clerk-react";
import { useEffect } from "react";
import { useEffect, useState } from "react";
import type { PassengerData } from "../../interfaces/passenger.interface";

const PassengersPage = () => {
const { getToken } = useAuth();
const { currentUser } = useUserContext();
const { setCurrentTab } = useNavigationContext();
const [isModalOpen, setIsModalOpen] = useState(false);

// ping the getUserByID endpoint to get the user's data
const { data: passengerData, isLoading: passengerLoading } =
Expand Down Expand Up @@ -55,6 +58,9 @@ const PassengersPage = () => {

return (
<>
{isModalOpen && (
<AddPassengerModal onClose={() => setIsModalOpen(false)} />
)}
<div className={styles.container}>
<div className={styles.patientSection}>
<h2 className={styles.header}>Patients and Companions</h2>
Expand All @@ -64,7 +70,14 @@ const PassengersPage = () => {
</div>
</div>
<div className={styles.passengerSection}>
<h3 className={styles.subheader}>Companion Information</h3>
<div className={styles.passengerSectionHeader}>
<h3 className={styles.subheader}>
Companion Information
<div className={styles.plusButton}>
<PlusButton setOpen={setIsModalOpen} />
</div>{" "}
</h3>
</div>
<h5 className={styles.description}>
Companions of {passengerData["First Name"]}
</h5>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export type FormData = {
"First Name": string;
"Last Name": string;
Relationship:
| "Mother"
| "Father"
| "Step-mother"
| "Step-father"
| "Legal Guardian"
| "Spouse"
| "Family Member"
| "Other Caregiver";
"Date of Birth": Date | string;
Diagnoses?: (string | undefined)[];
Gender: "Male" | "Female" | "Other";
Street: string;
City: string;
State: string;
Zip: string;
Country: string;
"Cell Phone": string;
Email: string;
Waiver: "Yes" | "No";
};

export type AddPassengerModalProps = {
onClose: () => void;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.inputList {
display: flex;
flex-direction: column;
gap: 0.5rem;
width: 100%;
}

.errorMessage {
color: red;
margin-top: 0.2rem;
text-align: center;
font-size: medium;
}
Loading

0 comments on commit 0e107e3

Please sign in to comment.