From f6710cac891c951d713f5e32f29459f9f8f39227 Mon Sep 17 00:00:00 2001 From: JackHurew Date: Sat, 16 Nov 2024 17:48:14 -0500 Subject: [PATCH 1/3] commit message --- src/components/EateryCard.tsx | 27 +++++++++++++++++++--- src/types/joiLocationTypes.ts | 1 + src/types/locationTypes.ts | 1 + src/util/queryLocations.ts | 2 ++ src/util/time.ts | 42 +++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/components/EateryCard.tsx b/src/components/EateryCard.tsx index 5c570aec..adf76452 100644 --- a/src/components/EateryCard.tsx +++ b/src/components/EateryCard.tsx @@ -174,6 +174,7 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) { todaysSpecials = [], statusMsg, todaysSoups = [], + timesListDisplay,//me } = location; const changesSoon = !location.closedLongTerm && location.changesSoon; const isOpen = !location.closedLongTerm && location.isOpen; @@ -238,14 +239,13 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) { Menu )} - {(todaysSpecials.length !== 0 || - todaysSoups.length !== 0) && ( + {(true) && (//todaysSpecials.length !== 0 || todaysSoups.length !== 0 GO BACK { setModalOpen(true); }} > - Specials + Specials & Times )} @@ -306,6 +306,27 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) { {locationText} + + {"Sunday: ".concat(timesListDisplay[0])} + + + {"Monday: ".concat(timesListDisplay[1])} + + + {"Tuesday: ".concat(timesListDisplay[2])} + + + {"Wednesday: ".concat(timesListDisplay[3])} + + + {"Thursday: ".concat(timesListDisplay[4])} + + + {"Friday: ".concat(timesListDisplay[5])} + + + {"Saturday: ".concat(timesListDisplay[6])} + {todaysSpecials.concat(todaysSoups).map((special) => ( diff --git a/src/types/joiLocationTypes.ts b/src/types/joiLocationTypes.ts index bc387130..d3a4209d 100644 --- a/src/types/joiLocationTypes.ts +++ b/src/types/joiLocationTypes.ts @@ -42,6 +42,7 @@ export const ILocationAPIJoiSchema = Joi.object({ .message('Received invalid (probably improperly sorted) time slots!'), todaysSpecials: Joi.array().items(ISpecialJoiSchema), todaysSoups: Joi.array().items(ISpecialJoiSchema), + timesListDisplay: Joi.array().items(string), }); export const IAPIResponseJoiSchema = Joi.object<{ locations: any[] }>({ locations: Joi.array().required(), diff --git a/src/types/locationTypes.ts b/src/types/locationTypes.ts index e7ec84c4..169c89ba 100644 --- a/src/types/locationTypes.ts +++ b/src/types/locationTypes.ts @@ -78,6 +78,7 @@ interface IAPILocation { times: ITimeSlot[]; todaysSpecials?: ISpecial[]; todaysSoups?: ISpecial[]; + timesListDisplay: string[]; } // All of the following are extended from the base API type diff --git a/src/util/queryLocations.ts b/src/util/queryLocations.ts index 482e4f47..6cd0abc5 100644 --- a/src/util/queryLocations.ts +++ b/src/util/queryLocations.ts @@ -17,6 +17,7 @@ import { isTimeSlotTime, isValidTimeSlotArray, getTimeString, + getTimeSlotsString, minutesSinceSundayTimeSlotTime, minutesSinceSundayDateTime, getApproximateTimeStringFromMinutes, @@ -157,6 +158,7 @@ export async function queryLocations( return validLocations.map((location) => ({ ...location, name: toTitleCase(location.name ?? 'Untitled'), // Convert names to title case + timesListDisplay: getTimeSlotsString(location.times), })); } catch (err: any) { console.error(err); diff --git a/src/util/time.ts b/src/util/time.ts index 87879212..64832984 100644 --- a/src/util/time.ts +++ b/src/util/time.ts @@ -101,6 +101,48 @@ export function getTimeString(time: ITimeSlotTime) { return `${hour12H}:${minutePadded} ${ampm}`; } + +/**ME-(GO BACK) + * Converts an ITimeSlotTime to a human-readable string (12-hour time) + * @param time + * @returns HH:MM (AM/PM) + */ +export function getTimeSlotString(time: ITimeSlot) { + assert(isTimeSlot(time)); + const start=getTimeString(time.start); + const end=getTimeString(time.end); + return `${start}-${end}`; +} + +export function getTimeSlotsString(times: ITimeSlots) { + assert(isValidTimeSlotArray(times)); + const listByDate=[]; + var index=0; + var r=index; + r=r+1; + assert(index!=1); + for (let date=0; date<7; date+=1){//idea: one for loop and concat to relevant places + var concatted_string=""; + for (let i = index; i Date: Sat, 23 Nov 2024 16:18:03 -0500 Subject: [PATCH 2/3] times_display --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c115dc94..448c46a3 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "mapkit-react": "^1.14.1", "million": "latest", "netlify-plugin-mapkitjs-token": "^1.2.0", - "posthog-js": "^1.181.0", + "posthog-js": "^1.188.0", "prettier-eslint": "^16.3.0", "prettier-eslint-cli": "^8.0.1", "react": "^18.2.0", @@ -66,7 +66,6 @@ ] }, "devDependencies": { - "bun-types": "^1.0.35", "@happy-dom/global-registrator": "^14.3.1", "@types/jest": "^29.5.12", "@types/jsonwebtoken": "^9.0.6", @@ -76,6 +75,7 @@ "@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react-swc": "^3.6.0", "@vitest/coverage-v8": "^1.4.0", + "bun-types": "^1.0.35", "eslint": "^8.57.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^18.0.0", From 81f2f27dde42e906b8e66dcd0b5b1aca85fcc3e8 Mon Sep 17 00:00:00 2001 From: JackHurew Date: Sat, 23 Nov 2024 17:19:32 -0500 Subject: [PATCH 3/3] times_display --- src/components/EateryCard.tsx | 27 ++++++++++++++++++++++++++- src/util/time.ts | 6 +++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/components/EateryCard.tsx b/src/components/EateryCard.tsx index adf76452..daf90587 100644 --- a/src/components/EateryCard.tsx +++ b/src/components/EateryCard.tsx @@ -88,6 +88,11 @@ const DescriptionText = styled(Typography)({ color: 'white', }); +const LongDescriptionText = styled(Typography)({ + color: 'white', + marginBottom: '5px', +}); + const OpenText = styled(Typography)(({ changesSoon }) => ({ color: changesSoon ? colors[LocationState.CLOSES_SOON] @@ -169,12 +174,14 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) { name, location: locationText, url, + description, shortDescription, menu, todaysSpecials = [], statusMsg, todaysSoups = [], - timesListDisplay,//me + timesListDisplay, + // acceptsOnlineOrders, } = location; const changesSoon = !location.closedLongTerm && location.changesSoon; const isOpen = !location.closedLongTerm && location.isOpen; @@ -306,6 +313,9 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) { {locationText} + + {description} + {"Sunday: ".concat(timesListDisplay[0])} @@ -327,6 +337,21 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) { {"Saturday: ".concat(timesListDisplay[6])} + {/* {({acceptsOnlineOrders} ? ( + + {"Accepts Online Orders"} + + ) : ( + + {"Does Not Accept Online Orders"} + + ))} */} {todaysSpecials.concat(todaysSoups).map((special) => ( diff --git a/src/util/time.ts b/src/util/time.ts index 64832984..fbdcf286 100644 --- a/src/util/time.ts +++ b/src/util/time.ts @@ -102,7 +102,7 @@ export function getTimeString(time: ITimeSlotTime) { } -/**ME-(GO BACK) +/**ME * Converts an ITimeSlotTime to a human-readable string (12-hour time) * @param time * @returns HH:MM (AM/PM) @@ -111,7 +111,7 @@ export function getTimeSlotString(time: ITimeSlot) { assert(isTimeSlot(time)); const start=getTimeString(time.start); const end=getTimeString(time.end); - return `${start}-${end}`; + return `${start} - ${end}`; } export function getTimeSlotsString(times: ITimeSlots) { @@ -134,7 +134,7 @@ export function getTimeSlotsString(times: ITimeSlots) { if (concatted_string.length==0){ concatted_string="CLOSED"; }else{ - concatted_string.substring(0, concatted_string.length-1); + concatted_string=concatted_string.substring(0, concatted_string.length-1); } listByDate.push(concatted_string); }