From b7dc6af2e49c6f3d247d5c6db6758234f2354adb Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Wed, 15 May 2024 00:42:18 +0200 Subject: [PATCH] Added: images and review button on beer/get Fixes: #12 --- frontend/app/(app)/(tabs)/beer/add.js | 13 +++++--- frontend/app/(app)/(tabs)/beer/index.js | 43 ++++++++++++++++++++++--- frontend/app/(app)/(tabs)/review/add.js | 1 - 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/frontend/app/(app)/(tabs)/beer/add.js b/frontend/app/(app)/(tabs)/beer/add.js index e124b03..1b64cc0 100644 --- a/frontend/app/(app)/(tabs)/beer/add.js +++ b/frontend/app/(app)/(tabs)/beer/add.js @@ -108,8 +108,12 @@ export default function BeerAdd() { async function addBeer() { // TODO: after the request - redirect to /beer/{new_beer_id}?; plus some modal about successful state + const data = new FormData(); - data.append("photos", dataURItoBlob(image.uri)); + if (Platform.OS == "web") { + // TODO: On phone its imposibble to upload an image + data.append("photos", dataURItoBlob(image.uri)); + } data.append("brand", b_brand); data.append("name", b_name); data.append("degree", b_degree); @@ -124,7 +128,9 @@ export default function BeerAdd() { const res = await req.json(); if (res.code == 201 && res.data._id) { - window.location.href = `/beer/${res.data._id}`; + // TODO: reditect using expo router + // window.location.href = `/beer/${res.data._id}`; + alert("Added"); } else { alert( "Beer was not added successfully. Please check your data and try again.", @@ -198,9 +204,8 @@ export default function BeerAdd() { ) : ( false )} - - {image && } + {image && }