From 05d0ff71341dd41793a3d6f35e6bb25b8908793f Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Wed, 8 May 2024 23:39:49 +0200 Subject: [PATCH] Added: beer add page; all beers page --- frontend/app/(app)/(tabs)/_layout.js | 7 ++- frontend/app/(app)/(tabs)/beer/add.js | 84 +++++++++++++++++++++++-- frontend/app/(app)/(tabs)/beer/index.js | 63 +++++++++++++++++-- frontend/app/(app)/_layout.js | 3 +- 4 files changed, 145 insertions(+), 12 deletions(-) diff --git a/frontend/app/(app)/(tabs)/_layout.js b/frontend/app/(app)/(tabs)/_layout.js index 43cdec3..be70c82 100644 --- a/frontend/app/(app)/(tabs)/_layout.js +++ b/frontend/app/(app)/(tabs)/_layout.js @@ -20,7 +20,7 @@ export default function TabLayout() { backgroundColor: colors.darkSecondary, }, tabBarActiveTintColor: colors.gold, - headerShown: false, + headerShown: true, }} sceneContainerStyle={{ backgroundColor: colors.dark }} > @@ -62,7 +62,10 @@ export default function TabLayout() { /> {/* Hide following routes from bottom bar */} - + ); diff --git a/frontend/app/(app)/(tabs)/beer/add.js b/frontend/app/(app)/(tabs)/beer/add.js index 85a6822..5fcb041 100644 --- a/frontend/app/(app)/(tabs)/beer/add.js +++ b/frontend/app/(app)/(tabs)/beer/add.js @@ -1,10 +1,86 @@ -import { View } from "react-native"; -import Text from "@components/Text"; +import { StyleSheet, TextInput, View } from "react-native"; +import { useState } from "react"; +import Button from "@components/Button"; +import { colors } from "@components/style"; export default function BeerAdd() { + const [b_name, setBName] = useState(""); + const [b_degree, setBDegree] = useState(""); + const [b_packaging, setBPackaging] = useState(""); + const [b_brand, setBBrand] = useState(""); + + async function addBeer() { + // TODO: after the request - redirect to /beer/{new_beer_id}?; plus some modal about successful state + const req = await fetch(`${process.env.EXPO_PUBLIC_API_URL}/beer/add`, { + method: "POST", + credentials: "include", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + brand: b_brand, + name: b_name, + degree: b_degree, + packaging: b_packaging, + photos: null, + }), + }); + const res = await req.json(); + } + return ( - - Beer Add + + + setBName(text)} + placeholderTextColor="#aaaaaa" + /> + setBBrand(text)} + placeholderTextColor="#aaaaaa" + /> + setBDegree(text)} + placeholderTextColor="#aaaaaa" + /> + setBPackaging(text)} + placeholderTextColor="#aaaaaa" + /> +