Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5f1a4d2
feat: :bug: build js files as well as .d.ts
Jul 21, 2024
6f5a2ac
fix: point start script to correct location
Jul 21, 2024
e77aa57
chore: :package: update lock file
Jul 21, 2024
fba0b59
fix: :bug: fix typo in start script
Jul 21, 2024
85dab76
feat: :bug: explicitly point at root.js for render deploy
Jul 21, 2024
8c96480
fix: :bug:
Jul 21, 2024
6c3c112
fix: :bug: point to compiled files for render
Jul 21, 2024
ffe731b
fix: :bug: point at compiled files in router as well
Jul 21, 2024
9747048
fix: :bug: point to compiled file in auth as well
Jul 21, 2024
e58e4cd
fix: :bug: don't point explicitly at compiled files
Jul 21, 2024
d78a640
fix: :bug: don't point at compiled files
Jul 21, 2024
81794c3
fix: :bug: point at .js files again
Jul 21, 2024
6fcde74
feat: :sparkles: add backend only build cmd
Jul 21, 2024
9672671
fix: :bug: don't point at compiled files explicitly
Jul 21, 2024
514c3c0
fix: :bug: try pointing at compiled files again
Jul 21, 2024
a311be3
fix: :bug: point to compiled files in db as well
Jul 21, 2024
f06a5c9
feat: :sparkles: add build script to db
Jul 21, 2024
dae0be0
fix: :bug: point at dist folder for compiled files
Jul 21, 2024
1bb48c4
Revert "fix: :bug: point at dist folder for compiled files"
Jul 21, 2024
7d7acfc
Revert "fix: :bug: try pointing at compiled files again"
Jul 21, 2024
2ff1cf2
Revert "fix: :bug: point to compiled files in db as well"
Jul 21, 2024
993376e
feat: :sparkles: refactor to build next not package
Jul 21, 2024
a057773
fix: :bug: rm db start added in error
Jul 21, 2024
5ee646b
fix: :bug: fix ignore syntax
Jul 21, 2024
e5b17c6
feat: :sparkles: add prod baseUrl
Jul 21, 2024
a1a45bc
feat: :fire: rm unused summary route
Jul 25, 2024
b018fe4
feat: :sparkles: handle loading states etc
Jul 25, 2024
acc1cc8
fix: :fire: rm unused throw
Jul 25, 2024
d5f9359
feat: :rocket: add dev sim build for screen shots
Sep 29, 2024
3d810e4
fix: :lipstick: update styles for more screen sizes
Sep 29, 2024
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 app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
}
},
"android": {
"package": "com.fss"
"package": "fss.bundle.co2"
},
"ios": {
"bundleIdentifier": "com.fss"
"bundleIdentifier": "fss.bundle.co2"
}
}
}
10 changes: 5 additions & 5 deletions apps/expo/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ConfigContext, ExpoConfig } from "expo/config";

export default ({ config }: ConfigContext): ExpoConfig => ({
...config,
name: "expo",
name: "Fresh Seasonal Sustainable",
slug: "expo",
scheme: "expo",
version: "0.1.0",
Expand All @@ -19,11 +19,11 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
},
assetBundlePatterns: ["**/*"],
ios: {
bundleIdentifier: "your.bundle.identifier",
bundleIdentifier: "fss.bundle.co2",
supportsTablet: true,
},
android: {
package: "your.bundle.identifier",
package: "fss.bundle.co2",
adaptiveIcon: {
foregroundImage: "./assets/fss.png",
backgroundColor: "#ffffff",
Expand All @@ -43,8 +43,8 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
[
"expo-camera",
{
cameraPermission: `Allow ${process.env.CUSTOMER_FACCING_PRODUCT_NAME} to access your camera`,
microphonePermission: `Allow ${process.env.CUSTOMER_FACCING_PRODUCT_NAME} to access your microphone`,
cameraPermission: `Allow ${process.env.CUSTOMER_FACING_PRODUCT_NAME} to access your camera`,
microphonePermission: `Allow ${process.env.CUSTOMER_FACING_PRODUCT_NAME} to access your microphone`,
recordAudioAndroid: true,
},
],
Expand Down
8 changes: 7 additions & 1 deletion apps/expo/eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
}
},
"development": {
"extends": "base",
"developmentClient": true
},
"development-simulator": {
"extends": "base",
"developmentClient": true,
"distribution": "internal"
"ios": {
"simulator": true
}
},
"preview": {
"extends": "base",
Expand Down
31 changes: 16 additions & 15 deletions apps/expo/src/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
import React from "react";
import { Dimensions, StyleSheet } from "react-native";
import { Tabs } from "expo-router";
import { BarChart3, House, Info } from "lucide-react-native";
import { House, Info } from "lucide-react-native";

import Header from "~/components/Header";

const primary = "#4caf50";
const secondary = "#ffffff";
const tertiary = "#008134";

const { width, height } = Dimensions.get("window");

const tabBarHeight = height > 700 ? 64 : 56;
const tabBarFontSize = width > 350 ? 12 : 10;

export default function TabLayout() {
return (
<Tabs
screenOptions={() => ({
tabBarActiveTintColor: tertiary,
tabBarInactiveTintColor: secondary,
tabBarStyle: {
height: 64,
position: "relative",
height: tabBarHeight,
borderColor: secondary,
borderTopColor: secondary,
backgroundColor: primary,
borderTopColor: secondary,
},
tabBarIconStyle: {
marginTop: 8,
position: "absolute",
top: 25,
color: secondary,
},
tabBarLabelStyle: {
fontSize: 12,
position: "absolute",
top: 40,
fontSize: tabBarFontSize,
color: secondary,
fontWeight: "medium",
marginBottom: 8,
},
tabBarAccessibilityLabel: "hello world",
header: () => <Header />,
})}
>
Expand All @@ -51,15 +61,6 @@ export default function TabLayout() {
),
}}
/>
<Tabs.Screen
name="summary"
options={{
title: "Summary",
tabBarIcon: ({ color, focused }) => (
<BarChart3 size={28} color={focused ? tertiary : color} />
),
}}
/>
</Tabs>
);
}
16 changes: 0 additions & 16 deletions apps/expo/src/app/(tabs)/summary.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/expo/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Image, Text, View } from "react-native";

import FssLogoCircle from "../../assets/fssCircle.png";

const Header = () => {
export const Header = () => {
return (
<View className="h-16 w-full flex-row items-center justify-start bg-primary pl-2">
<Image source={FssLogoCircle} className="h-12 w-12" />
Expand Down
44 changes: 34 additions & 10 deletions apps/expo/src/components/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import { Button, Text, TouchableOpacity, View } from "react-native";
import { CameraView, useCameraPermissions } from "expo-camera";

import EcoScoreIcon from "~/components/icons/EcoScoreIcon";
import Loading from "~/components/Loading";
import { api } from "~/utils/api";

export function HomePage() {
export const HomePage = () => {
const [facing, setFacing] = useState<CameraType>("back");
const [permission, requestPermission] = useCameraPermissions();
const [scannedData, setScannedData] = useState<string | null>(null);
const [scanned, setScanned] = useState(false);

const { isError, data, error, refetch } =
const { isError, isLoading, data, error, isFetched, refetch } =
api.getEstimate.getEstimate.useQuery(
{ barCodeUniqueId: scannedData ?? "" },
{
Expand All @@ -31,9 +32,7 @@ export function HomePage() {
setFacing((current) => (current === "back" ? "front" : "back"));
}

const productName =
data?.WorldFoodFactsProductInfo?.product.product_name ??
"Sorry, we couldn't find that product";
const productName = data?.WorldFoodFactsProductInfo?.product.product_name;
const productGrade =
data?.WorldFoodFactsProductInfo?.product.ecoscore_data?.grade;
const productTotalCO2: string | number =
Expand All @@ -51,8 +50,31 @@ export function HomePage() {
);
}

if (isLoading) {
return <Loading />;
}

if (scanned && isFetched && !productName) {
return (
<View>
<Text>Sorry! We couldn't find that product.</Text>
<View className="ml-0 w-full flex-row justify-center">
<Button
title={"Tap to Scan Another Product"}
onPress={() => setScanned(false)}
color="green"
/>
</View>
</View>
);
}

if (!permission) {
return <View />;
return (
<View>
<Text>Sorry! We need camera permissions to scan products.</Text>
</View>
);
}

if (!permission.granted) {
Expand All @@ -68,13 +90,13 @@ export function HomePage() {

return (
<>
{data && scanned ? (
{isFetched && scanned ? (
<View className="relative h-full flex-col justify-start">
<Text className="mb-4 text-3xl font-bold">{productName}</Text>
{productGrade ? (
<EcoScoreIcon grade={productGrade} />
) : (
<Text>"Sorry we can't seem to find that item "</Text>
<Text>"Sorry! We can't find the grade for that product."</Text>
)}
<Text className="mb-4 mt-4">
The EcoScore for this product is an {productGrade?.toUpperCase()}{" "}
Expand All @@ -89,7 +111,9 @@ export function HomePage() {
That's equivalent to driving a car for 5 miles...
</Text>
<Text className="mb-4 text-3xl font-bold">Seasonality </Text>
<Text>Sorry, we can't tell if this product is in season for you</Text>
<Text>
Sorry, we can't tell if this product is in season for you.
</Text>
<View className="absolute bottom-0 ml-0 w-full flex-row justify-center">
<Button
title={"Tap to Scan Another Product"}
Expand Down Expand Up @@ -135,6 +159,6 @@ export function HomePage() {
)}
</>
);
}
};

export default HomePage;
14 changes: 14 additions & 0 deletions apps/expo/src/components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import { Text, View } from "react-native";
import { Loader2 } from "lucide-react-native";

export const Loading = () => {
return (
<View className="align-center m-auto flex justify-center">
<Text>Loading...</Text>
<Loader2 />
</View>
);
};

export default Loading;
5 changes: 1 addition & 4 deletions apps/expo/src/utils/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ const getBaseUrl = () => {
const localhost = debuggerHost?.split(":")[0];

if (!localhost) {
// return "https://turbo.t3.gg";
throw new Error(
"Failed to get localhost. Please point to your production server.",
);
return "https://fssmono.onrender.com";
}
return `http://${localhost}:3000`;
};
Expand Down
28 changes: 28 additions & 0 deletions apps/nextjs/src/app/api/trpc/[trpc]/getEstimate/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { initTRPC } from "@trpc/server";
import { z } from "zod";

const t = initTRPC.create();

export const appRouter = t.router({
getEstimate: t.procedure
.input(
z.object({
barCodeUniqueId: z.string(),
}),
)
.query(async ({ input }) => {
// Fetch data from the first API
const productRes = await fetch(
`${process.env.WORLD_OPEN_FOOD_FACTS_BASE_URL}/api/v0/product/${input.barCodeUniqueId}.json`,
).then((res) => res.json());

// Fetch data from the second API
const data2 = await fetch(
`https://api2.example.com/data?param=${productRes.productName}`,
).then((res) => res.json());

return { productRes, data2 };
}),
});

export type AppRouter = typeof appRouter;
12 changes: 11 additions & 1 deletion eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
"developmentClient": true,
"distribution": "internal"
},
"development-simulator": {
"developmentClient": true,
"ios": {
"simulator": true
}
},
"preview": {
"distribution": "internal"
},
"production": {}
"production": {
"env": {
"CUSTOMER_FACING_PRODUCT_NAME": "Fresh Seasonal Sustainable"
}
}
},
"submit": {
"production": {}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"packageManager": "pnpm@9.1.0",
"scripts": {
"build": "turbo build",
"build:backend": "turbo run build --ignore apps/expo",
"clean": "git clean -xdf node_modules",
"clean:workspaces": "turbo clean",
"db:push": "pnpm -F db push",
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"with-env": "dotenv -e ../../.env --"
},
"dependencies": {
"@vercel/postgres": "^0.8.0",
"@t3-oss/env-core": "^0.10.1",
"@vercel/postgres": "^0.8.0",
"drizzle-orm": "^0.30.10",
"drizzle-zod": "^0.5.1",
"zod": "^3.23.8"
Expand Down
Loading