Skip to content

Commit

Permalink
fix redirect paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dlustre committed May 24, 2024
1 parent 255df0a commit ae14041
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
2 changes: 2 additions & 0 deletions apps/expo/src/app/events/event/[title].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default function Event() {
<Stack.Screen
options={{
headerTitle: event.title,
headerBackTitle: "Events",
headerTitleStyle: { color: "white" },
}}
/>
<ScrollView
Expand Down
40 changes: 18 additions & 22 deletions apps/expo/src/app/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
} from "@zotmeal/utils";

import { RestaurantTabs } from "~/components";
import { CategoryCard } from "~/components/menu/category-card";
import { api } from "~/utils/api";
import useZotmealStore from "~/utils/useZotmealStore";
import { CategoryCard } from "~/components/menu/category-card";
import { EventToast } from "./_components/event-toast";
import { PeriodPicker } from "./_components/period-picker";
import { StationTabs } from "./_components/station-tabs";
Expand All @@ -41,22 +41,22 @@ export function Home() {
// TODO: how should we handle fetching when restaurant is closed?
const [anteateryQuery, brandywineQuery] = api.useQueries((t) =>
restaurantNames.map((restaurantName) =>
t.menu.get({
date: date.toLocaleDateString("en-US"),
period: periodName,
restaurant: restaurantName,
}),
t.menu.get(
{
date: date.toLocaleDateString("en-US"),
period: periodName,
restaurant: restaurantName,
},
{
refetchOnWindowFocus: false,
},
),
),
);

useEffect(() => {
if (anteateryQuery?.data) {
setAnteateryMenu(anteateryQuery.data);
}

if (brandywineQuery?.data) {
setBrandywineMenu(brandywineQuery.data);
}
if (anteateryQuery?.data) setAnteateryMenu(anteateryQuery.data);
if (brandywineQuery?.data) setBrandywineMenu(brandywineQuery.data);

if (
anteateryQuery &&
Expand All @@ -81,14 +81,12 @@ export function Home() {
toast,
]);

if (!anteateryQuery || !brandywineQuery) {
return <Text>Fetching menus</Text>;
}
if (!anteateryQuery || !brandywineQuery)
throw new Error("Unreachable: anteateryQuery and brandywineQuery are null");

// TODO: maybe loading spinner instead
if (anteateryQuery.isLoading || brandywineQuery.isLoading) {
if (anteateryQuery.isLoading || brandywineQuery.isLoading)
return <Text>Loading...</Text>;
}

if (anteateryQuery.isError || brandywineQuery.isError) {
console.error(anteateryQuery.error, brandywineQuery.error);
Expand All @@ -100,9 +98,7 @@ export function Home() {
);
}

if (!anteateryMenu || !brandywineMenu) {
return <Text>Menus not found</Text>;
}
if (!anteateryMenu || !brandywineMenu) return <Text>Menus not found</Text>;

return (
<RestaurantTabs>
Expand Down Expand Up @@ -143,7 +139,7 @@ export function Home() {
/>
)}
</XStack>

<ScrollView horizontal>
<XStack gap={10}>
<CategoryCard
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/src/app/home/item/RateItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function RateItem({
const [rating, setRating] = useState<number>(5);

return (
<Popover placement="top">
<Popover placement="bottom">
<Popover.Trigger asChild width={"28%"}>
<Button
fontWeight={"800"}
Expand Down
6 changes: 3 additions & 3 deletions apps/expo/src/app/home/item/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ export default function MenuItem() {
selectedRestaurant === "anteatery" ? anteateryMenu : brandywineMenu;

// TODO: Log error if menu is not found
if (!menu) return <Redirect href="/home/" />;
if (!menu) return <Redirect href="/" />;

const station = menu.stations.find((station) => station.id === stationId);

// TODO: Log error if station is not found
if (!station) return <Redirect href="/home/" />;
if (!station) return <Redirect href="/" />;

const dish = station.dishes.find((dish) => dish.id === id);

// TODO: Log error if dish is not found
if (!dish) return <Redirect href="/home/" />;
if (!dish) return <Redirect href="/" />;

// Unused fields:
// caloriesFromFat
Expand Down
8 changes: 7 additions & 1 deletion apps/expo/src/components/navigation/HamburgerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ export function HamburgerMenu() {
};

return (
<Popover placement="top">
<Popover
placement="bottom-start"
offset={{
alignmentAxis: -30,
mainAxis: -10,
}}
>
<Popover.Trigger asChild theme="dark">
<Button
backgroundColor={0}
Expand Down

0 comments on commit ae14041

Please sign in to comment.