Skip to content

Commit

Permalink
Merge pull request #44 from TritonSE/categories-page
Browse files Browse the repository at this point in the history
Categories page
  • Loading branch information
Anthonyp0329 authored Jun 4, 2024
2 parents dfad5cf + 119795e commit c3f62fa
Show file tree
Hide file tree
Showing 41 changed files with 6,807 additions and 6,784 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
- name: Install frontend dependencies
run: |
cd admin-portal-frontend/
touch .env
echo "API_URL=https://sideline-sidekick-app.web.app/api/"
cat .env
npm ci
npm run build
- name: Install backend dependencies
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
- uses: actions/checkout@v4
- run: |
cd admin-portal-frontend/
touch .env
echo "API_URL=https://sideline-sidekick-app.web.app/api/"
cat .env
npm ci
npm run build
- name: Install backend dependencies
Expand Down
2 changes: 1 addition & 1 deletion .husky/lint-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
enabled=1

# Directories containing JavaScript projects to be linted, separated by spaces.
node_dirs='backend dfm-sideline-sidekick-app'
node_dirs='backend dfm-sideline-sidekick-app admin-portal-frontend'

# Command used to run a lint check.
check_command='npm run lint-check'
Expand Down
1 change: 1 addition & 0 deletions admin-portal-frontend/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_URL=REPLACE_ME
109 changes: 109 additions & 0 deletions admin-portal-frontend/emergencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { get, handleAPIError, post, put } from "./requests";

import type { APIResult } from "./requests";

// export type Emergency = {
// _id: string;
// title: string;
// overview?: {
// Importance?: string;
// "Mechanism of Injury"?: string[];
// Diagnosis?: string[];
// "Physical Exam"?: string[];
// };
// treatment?: {
// "Acute Management"?: string[];
// Dispo?: string[];
// Considerations?: {
// Header?: string;
// Content?: string[];
// };
// };
// content?: object;
// };

export type Emergency = {
_id: string;
title: string;
subtitle: string;
overview?: object;
treatment?: object;
content?: object;
};

/**
* The expected inputs when we want to create a new Task object. In the MVP, we only
* need to provide the title and optionally the description, but in the course of
* this tutorial you'll likely want to add more fields here.
*/
export type CreateEmergencyRequest = {
title: string;
subtitle: string;
overview?: object;
treatment?: object;
content?: object;
};

/**
* The expected inputs when we want to update an existing Task object. Similar to
* `CreateTaskRequest`.
*/
export type UpdateEmergencyRequest = {
_id: string;
title: string;
subtitle: string;
overview?: object;
treatment?: object;
content?: object;
};

/**
* The implementations of these API client functions are provided as part of the
* MVP. You can use them as a guide for writing the other client functions.
*/
export async function createEmergency(
emergency: CreateEmergencyRequest,
): Promise<APIResult<Emergency>> {
try {
const response = await post("/api/emergencies", emergency);
const json = (await response.json()) as Emergency;
return { success: true, data: json };
} catch (error) {
return handleAPIError(error);
}
}

export async function getEmergency(id: string): Promise<APIResult<Emergency>> {
try {
const response = await get(`/api/emergencies/${id}`);
const json = (await response.json()) as Emergency;
return { success: true, data: json };
} catch (error) {
return handleAPIError(error);
}
}

export async function getAllEmergencies(): Promise<APIResult<Emergency[]>> {
try {
const response = await get(`/api/emergencies/`);
const json = (await response.json()) as Emergency[];
// const parsedJson = json.map((element) => (element));
return { success: true, data: json };
// your code here
} catch (error) {
return handleAPIError(error);
}
}

export async function updateEmergency(
emergency: UpdateEmergencyRequest,
): Promise<APIResult<Emergency>> {
try {
// your code here
const response = await put(`/api/emergencies/${emergency._id}`, emergency);
const json = (await response.json()) as Emergency;
return { success: true, data: json };
} catch (error) {
return handleAPIError(error);
}
}
15 changes: 10 additions & 5 deletions admin-portal-frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/** @type {import('next').NextConfig} */
import "dotenv/config";

const nextConfig = {
output: "export",
images: {
unoptimized: true,
},
trailingSlash: true,
env: {
API_URL: process.env.API_URL,
},
output: "export",
images: {
unoptimized: true,
},
trailingSlash: true,
};

export default nextConfig;
Loading

0 comments on commit c3f62fa

Please sign in to comment.