Skip to content

Commit

Permalink
add dump command for easy test data
Browse files Browse the repository at this point in the history
  • Loading branch information
anmho committed May 21, 2024
1 parent 957fd63 commit 25663db
Show file tree
Hide file tree
Showing 21 changed files with 8,686 additions and 70 deletions.
1 change: 1 addition & 0 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"clean": "git clean -xdf .expo .turbo node_modules",
"dev": "expo start",
"start": "NODE_ENV=production expo start",
"dev:android": "expo start --android",
"dev:ios": "expo start --ios",
"android": "expo run:android",
Expand Down
3 changes: 1 addition & 2 deletions apps/expo/src/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { config } from "@tamagui/config/v3";
import { z } from "zod";

import "@tamagui/core/reset.css";

Expand All @@ -18,7 +17,7 @@ import { ToastProvider, ToastViewport } from "@tamagui/toast";
import { createTamagui, TamaguiProvider, Theme } from "tamagui";

import Logo from "~/components/Logo";
import HamburgerMenu from "~/components/navigation/HamburgerMenu";
import { HamburgerMenu } from "~/components/navigation/HamburgerMenu";
import { TRPCProvider } from "~/utils";
import { env } from "../utils/env";

Expand Down
141 changes: 89 additions & 52 deletions apps/expo/src/app/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useEffect, useState } from "react";
import React, { useEffect, useState } from "react";



import { Platform } from "react-native";
import DateTimePicker from "@react-native-community/datetimepicker";
import { CalendarDays } from "@tamagui/lucide-icons";
import { useToastController } from "@tamagui/toast";
import { endOfWeek, startOfWeek } from "date-fns";
import { Button, Tabs, Text, useTheme, XStack } from "tamagui";
import { Button, ScrollView, Tabs, Text, useTheme, XStack } from "tamagui";

import type { PeriodName } from "@zotmeal/utils";
import {
Expand All @@ -13,12 +16,13 @@ import {
restaurantNames,
} from "@zotmeal/utils";

import { RestaurantTabs } from "~/components";
import { CategoryCard } from "~/components/menu/category-card";
import { useMenuStore } from "~/utils";
import { api } from "~/utils/api";
import { EventToast } from "./_components/event-toast";
import { PeriodPicker } from "./_components/period-picker";
import { StationTabs } from "./_components/station-tabs";
import RestaurantTabs from '~/components/navigation/RestaurantTabs';

export function Home() {
const { anteateryMenu, brandywineMenu, setAnteateryMenu, setBrandywineMenu } =
Expand Down Expand Up @@ -47,8 +51,6 @@ export function Home() {
}),
),
);
console.log(anteateryQuery);
console.log(brandywineQuery);

useEffect(() => {
if (anteateryQuery?.data) {
Expand Down Expand Up @@ -103,56 +105,91 @@ export function Home() {

return (
<RestaurantTabs>
<EventToast />
<XStack justifyContent="space-around">
<PeriodPicker
periodName={periodName}
setPeriodName={setPeriodName}
color={theme.color?.val as string}
/>
{Platform.OS === "android" && (
<Button
onPress={() => setShowDatePicker(true)}
icon={CalendarDays}
scaleIcon={1.5}
size="$5"
borderRadius="$10"
pressTheme
>
{date.toLocaleDateString("en-US")}
</Button>
)}
{showDatePicker && (
<DateTimePicker
value={date}
mode="date"
minimumDate={startOfWeek(new Date())}
maximumDate={endOfWeek(new Date())}
onChange={(_, selectedDate) => {
// hide date picker on android
setShowDatePicker(Platform.OS === "ios");
if (selectedDate) {
setDate(selectedDate);
}
}}
<ScrollView>
<EventToast />

<XStack justifyContent="space-around">
<PeriodPicker
periodName={periodName}
setPeriodName={setPeriodName}
color={theme.color?.val as string}
/>
)}
</XStack>

{[brandywineMenu, anteateryMenu].map((menu) => (
<>
{menu && (
<Tabs.Content
key={menu.restaurantId}
value={getRestaurantNameById(menu.restaurantId)}
alignItems="center"
flex={1}
{Platform.OS === "android" && (
<Button
onPress={() => setShowDatePicker(true)}
icon={CalendarDays}
scaleIcon={1.5}
size="$5"
borderRadius="$10"
pressTheme
>
<StationTabs stations={menu.stations} />
</Tabs.Content>
{date.toLocaleDateString("en-US")}
</Button>
)}
</>
))}
{showDatePicker && (
<DateTimePicker
value={date}
mode="date"
minimumDate={startOfWeek(new Date())}
maximumDate={endOfWeek(new Date())}
onChange={(_, selectedDate) => {
// hide date picker on android
setShowDatePicker(Platform.OS === "ios");
if (selectedDate) {
setDate(selectedDate);
}
}}
/>
)}
</XStack>

<ScrollView horizontal>
<XStack gap={10}>
<CategoryCard
category="Soups"
image={""}
onPress={function (): void {
throw new Error("Function not implemented.");
}}
/>
<CategoryCard
category="Vegan"
image={""}
onPress={function (): void {
throw new Error("Function not implemented.");
}}
/>
<CategoryCard
category="Noodles"
image={""}
onPress={function (): void {
throw new Error("Function not implemented.");
}}
/>
</XStack>
</ScrollView>

{[brandywineMenu, anteateryMenu].map((menu) => (
<>
{menu && (
<Tabs.Content
key={menu.restaurantId}
value={getRestaurantNameById(menu.restaurantId)}
alignItems="center"
flex={1}
>
<StationTabs stations={menu.stations} />
</Tabs.Content>
)}
</>
))}
</ScrollView>
</RestaurantTabs>
);
}



function CategorySection() {

}
77 changes: 77 additions & 0 deletions apps/expo/src/components/menu/category-card.tsx

Large diffs are not rendered by default.

Empty file.
Empty file.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion apps/expo/src/components/navigation/HamburgerMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from "@tamagui/lucide-icons";
import { Adapt, Button, ListItem, Popover, Separator, YGroup } from "tamagui";

export default function HamburgerMenu() {
export function HamburgerMenu() {
const currentSegment = useSegments()[0] ?? "";
const screens: Record<
string,
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/src/components/navigation/RestaurantTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getCurrentPeriodName } from "@zotmeal/utils";

import useMenuStore from "~/utils/useMenuStore";

export default function RestaurantTabs({
export function RestaurantTabs({
children,
}: Readonly<{
children: React.ReactNode;
Expand Down
6 changes: 5 additions & 1 deletion apps/expo/src/utils/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import superjson from "superjson";

import type { AppRouter } from "@zotmeal/api";

import { env } from "./env";

/**
* A set of typesafe hooks for consuming your API.
*/
Expand All @@ -29,7 +31,9 @@ const getBaseUrl = () => {
*/
const debuggerHost = Constants.expoConfig?.hostUri;
const localhost = debuggerHost?.split(":")[0];

if (env.NODE_ENV === "production") {
return env.API_URL;
}
if (!localhost) {
// return "https://turbo.t3.gg";
throw new Error(
Expand Down
2 changes: 2 additions & 0 deletions apps/expo/src/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { z } from "zod";
const envSchema = z.object({
API_URL: z.string(),
CLERK_PUBLISHABLE_KEY: z.string(),
NODE_ENV: z.string(),
});
const env = envSchema.parse({
API_URL: process.env.EXPO_PUBLIC_API_URL,
CLERK_PUBLISHABLE_KEY: process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY,
NODE_ENV: process.env.NODE_ENV,
});

export { env };
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
POSTGRES_PASSWORD: admin
POSTGRES_DB: zotmeal
volumes:
- ./docker/db/zotmeal.sql:/docker-entrypoint-initdb.d/init.sql
- db_data:/var/lib/postgresql/data
ports:
- 5433:5432
Expand Down
3 changes: 3 additions & 0 deletions docker/bin/connect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

psql "postgresql://admin:admin@localhost:5433/zotmeal"
Loading

0 comments on commit 25663db

Please sign in to comment.