Skip to content

Commit a9b8d5b

Browse files
DEV-358 Fix Deployment Issues to Prepare for Release (#24)
* Fix typing and package errors in order to deploy * Update react versions * Fix more types * Remove package-lock.json in favor of bun's lock file * Switch to ES6 modules in package.json
1 parent ec837c1 commit a9b8d5b

File tree

15 files changed

+108
-11726
lines changed

15 files changed

+108
-11726
lines changed

frontend/app/api/dining/nutrition/route.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

frontend/app/feature1/page.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import DiningLocations from '@/examples/locations';
3030
import getDiningLocationsServerSide from '@/examples/locationsServerSide';
3131
import { useGetMenu } from '@/hooks/use-endpoints';
3232
import DiningHallCard from '@/components/DiningHallCard';
33+
import { AllergenKey, DietKey } from '@/types/dining';
3334

3435
type MealType = 'Breakfast' | 'Lunch' | 'Dinner';
3536

@@ -159,8 +160,8 @@ export default function Index() {
159160
'Graduate College',
160161
];
161162
const [halls] = useState<string[]>(initialHalls);
162-
const DIETARY = ['Vegetarian', 'Vegan', 'Halal', 'Kosher'];
163-
const ALLERGENS = [
163+
const DIETARY: DietKey[] = ['Vegetarian', 'Vegan', 'Halal', 'Kosher'];
164+
const ALLERGENS: AllergenKey[] = [
164165
'Peanut',
165166
'Tree nut',
166167
'Egg',
@@ -180,16 +181,16 @@ export default function Index() {
180181

181182
// temporary UI selections
182183
const [tempHalls, setTempHalls] = useState<string[]>(initialHalls);
183-
const [tempDietary, setTempDietary] = useState<string[]>([...DIETARY]);
184-
const [tempAllergens, setTempAllergens] = useState<string[]>([...ALLERGENS]);
184+
const [tempDietary, setTempDietary] = useState<DietKey[]>([...DIETARY]);
185+
const [tempAllergens, setTempAllergens] = useState<AllergenKey[]>([...ALLERGENS]);
185186

186187
const [filterOpen, setFilterOpen] = useState(false);
187188
const [modalHall, setModalHall] = useState<UIVenue | null>(null);
188189

189-
const toggle = (
190-
val: string,
191-
arr: string[],
192-
setter: React.Dispatch<React.SetStateAction<string[]>>
190+
const toggle = <T,>(
191+
val: T,
192+
arr: T[],
193+
setter: React.Dispatch<React.SetStateAction<T[]>>
193194
) => setter(arr.includes(val) ? arr.filter((x) => x !== val) : [...arr, val]);
194195

195196
// reset only the temp selections

frontend/app/feature2/page.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,14 @@ export default function DietPlanner() {
744744
let bestScore = Infinity;
745745
let bestFoodIndex = -1;
746746
// We loop through our available foods to find the one that gets us closest to our targets.
747-
remainingFoods.forEach((food, index) => {
747+
for (let j = 0; j < remainingFoods.length; j++) {
748+
const food = remainingFoods[j];
748749
const newCalories = currentTotals.calories + food.nutrition.calories;
749750
const newProtein = currentTotals.protein + food.nutrition.protein;
750751
const newFat = currentTotals.fat + food.nutrition.fat;
751752
const newCarbs = currentTotals.carbohydrates + food.nutrition.carbohydrates;
752753

753-
if (newCalories > targetCalories * 1.25) return; // Don't go too far over the target.
754+
if (newCalories > targetCalories * 1.25) continue; // Don't go too far over the target.
754755
const calError = (newCalories - targetCalories) / (targetCalories || 1);
755756
const proError = (newProtein - targetProtein) / (targetProtein || 1);
756757
const fatError = (newFat - targetFat) / (targetFat || 1);
@@ -760,13 +761,13 @@ export default function DietPlanner() {
760761
if (score < bestScore) {
761762
bestScore = score;
762763
bestFood = food;
763-
bestFoodIndex = index;
764+
bestFoodIndex = j;
764765
}
765-
});
766+
}
766767
if (bestFood && bestFoodIndex > -1) {
767768
mealCombination.push(bestFood);
768769
Object.keys(bestFood.nutrition).forEach((key) => {
769-
currentTotals[key as keyof Nutrients] += bestFood!.nutrition[key as keyof Nutrients];
770+
currentTotals[key as keyof Nutrients] += bestFood.nutrition[key as keyof Nutrients];
770771
});
771772
remainingFoods.splice(bestFoodIndex, 1);
772773
} else {
@@ -931,7 +932,7 @@ export default function DietPlanner() {
931932
padding={majorScale(3)}
932933
backgroundColor='white'
933934
boxShadow='0px 10px 15px -3px rgba(0,0,0,0.07), 0px 4px 6px -2px rgba(0,0,0,0.05)'
934-
onSubmit={(e) => {
935+
onSubmit={(e: React.FormEvent<HTMLFormElement>) => {
935936
e.preventDefault();
936937
handleGeneratePlan(currentDateObj);
937938
}}

frontend/app/feature3/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React from 'react';
55
// --- Helper Components & Data ---
66

77
// Icon for social media links
8-
const SocialIcon = ({ href, children }) => (
8+
const SocialIcon = ({ href, children }: { href: string; children: React.ReactNode }) => (
99
<a
1010
href={href}
1111
target='_blank'

frontend/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const metadata = {
4444
* @param children - The child components to render within the layout.
4545
* @returns JSX Element representing the content area.
4646
*/
47-
async function Content({ children }: { children: ReactNode }): Promise<JSX.Element> {
47+
async function Content({ children }: { children: ReactNode }): Promise<React.JSX.Element> {
4848
const session = await getSession();
4949
const user = session?.user;
5050

@@ -73,7 +73,7 @@ async function Content({ children }: { children: ReactNode }): Promise<JSX.Eleme
7373
* @param children - The child components to render within the layout.
7474
* @returns JSX Element representing the root HTML structure.
7575
*/
76-
export default function RootLayout({ children }: { children: ReactNode }): JSX.Element {
76+
export default function RootLayout({ children }: { children: ReactNode }): React.JSX.Element {
7777
return (
7878
<html lang='en' className={`bg-hoagiemeal-dark-green ${poppins.className}`}>
7979
<head>

frontend/bun.lock

Lines changed: 22 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/components/DiningHallCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import matheyBanner from '../public/images/banners/rockybanner.png';
2222
import yehBanner from '../public/images/banners/yehbanner.png';
2323
import cjlBanner from '../public/images/banners/cjl-banner.png';
2424
import gradBanner from '../public/images/banners/gradbanner.png';
25+
import { StaticImageData } from 'next/image';
2526

2627
interface UIMenuItem {
2728
name: string;
@@ -43,7 +44,7 @@ interface DiningHallCardProps {
4344
showNutrition: boolean;
4445
}
4546

46-
const hallImages: Record<string, string> = {
47+
const hallImages: Record<string, StaticImageData> = {
4748
'Rockefeller College': rockyBanner,
4849
'Forbes College': forbesBanner,
4950
'Mathey College': matheyBanner,

frontend/components/DiningHallMap.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import React, { useEffect, useState } from 'react';
66
import { Pane, Heading, Text, Spinner, majorScale, minorScale } from 'evergreen-ui';
77
import { MapContainer, TileLayer, Marker, Popup, useMap } from 'react-leaflet';
8-
import L from 'leaflet';
98
import 'leaflet/dist/leaflet.css';
109

1110
const diningHalls = [

0 commit comments

Comments
 (0)