Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Times and Description Update #535

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
52 changes: 49 additions & 3 deletions src/components/EateryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ const DescriptionText = styled(Typography)({
color: 'white',
});

const LongDescriptionText = styled(Typography)({
color: 'white',
marginBottom: '5px',
});

const OpenText = styled(Typography)<TextProps>(({ changesSoon }) => ({
color: changesSoon
? colors[LocationState.CLOSES_SOON]
Expand Down Expand Up @@ -169,11 +174,14 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) {
name,
location: locationText,
url,
description,
shortDescription,
menu,
todaysSpecials = [],
statusMsg,
todaysSoups = [],
timesListDisplay,
// acceptsOnlineOrders,
} = location;
const changesSoon = !location.closedLongTerm && location.changesSoon;
const isOpen = !location.closedLongTerm && location.isOpen;
Expand Down Expand Up @@ -238,14 +246,13 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) {
Menu
</ActionButton>
)}
{(todaysSpecials.length !== 0 ||
todaysSoups.length !== 0) && (
{(true) && (//todaysSpecials.length !== 0 || todaysSoups.length !== 0 GO BACK
<ActionButton
onClick={() => {
setModalOpen(true);
}}
>
Specials
Specials & Times
</ActionButton>
)}
</CardActions>
Expand Down Expand Up @@ -306,6 +313,45 @@ function EateryCard({ location }: { location: IReadOnlyExtendedLocation }) {
<LocationText variant="subtitle2">
{locationText}
</LocationText>
<LongDescriptionText variant="subtitle2">
{description}
</LongDescriptionText>
<LocationText variant="subtitle2">
{"Sunday: ".concat(timesListDisplay[0])}
</LocationText>
<LocationText variant="subtitle2">
{"Monday: ".concat(timesListDisplay[1])}
</LocationText>
<LocationText variant="subtitle2">
{"Tuesday: ".concat(timesListDisplay[2])}
</LocationText>
<LocationText variant="subtitle2">
{"Wednesday: ".concat(timesListDisplay[3])}
</LocationText>
<LocationText variant="subtitle2">
{"Thursday: ".concat(timesListDisplay[4])}
</LocationText>
<LocationText variant="subtitle2">
{"Friday: ".concat(timesListDisplay[5])}
</LocationText>
<LocationText variant="subtitle2">
{"Saturday: ".concat(timesListDisplay[6])}
</LocationText>
{/* {({acceptsOnlineOrders} ? (
<OpenText
variant="subtitle1"
changesSoon={acceptsOnlineOrders}
>
{"Accepts Online Orders"}
</OpenText>
) : (
<ClosedText
variant="subtitle1"
changesSoon={acceptsOnlineOrders}
>
{"Does Not Accept Online Orders"}
</ClosedText>
))} */}
</CardContent>
{todaysSpecials.concat(todaysSoups).map((special) => (
<SpecialsContent style={{}} key={special.title}>
Expand Down
1 change: 1 addition & 0 deletions src/types/joiLocationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const ILocationAPIJoiSchema = Joi.object<IReadOnlyAPILocation>({
.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(),
Expand Down
1 change: 1 addition & 0 deletions src/types/locationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/util/queryLocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
isTimeSlotTime,
isValidTimeSlotArray,
getTimeString,
getTimeSlotsString,
minutesSinceSundayTimeSlotTime,
minutesSinceSundayDateTime,
getApproximateTimeStringFromMinutes,
Expand Down Expand Up @@ -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);
Expand Down
42 changes: 42 additions & 0 deletions src/util/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,48 @@ export function getTimeString(time: ITimeSlotTime) {
return `${hour12H}:${minutePadded} ${ampm}`;
}


/**ME
* 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<times.length && date == (times[i]).start.day; i += 1) {
assert(i<times.length);
// times[i].start.day;
// assert(!isTimeSlot(times[0]));
concatted_string=concatted_string.concat(getTimeSlotString(times[i]));
concatted_string=concatted_string.concat(",");
index=index+1;
}
if (concatted_string.length==0){
concatted_string="CLOSED";
}else{
concatted_string=concatted_string.substring(0, concatted_string.length-1);
}
listByDate.push(concatted_string);
}
return listByDate;
}



/**
*
* @param timeSlots
Expand Down
Loading