From 1f802fa9b6542e3f7b7e3d1af9307aeb2e5e7875 Mon Sep 17 00:00:00 2001 From: philipye314 Date: Wed, 11 Oct 2023 22:45:18 -0700 Subject: [PATCH] BRUH --- .../Cases/QRCodeScanner/AddCase/index.tsx | 28 +++++++++++++++---- .../Cases/QRCodeScanner/index.tsx | 8 ++---- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index d0eaf82d..6924ffbd 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -1,20 +1,38 @@ import { router, useLocalSearchParams } from 'expo-router'; -import React from 'react'; +import React, { useEffect } from 'react'; import { Image, Text, View } from 'react-native'; import { TouchableOpacity } from 'react-native-gesture-handler'; +import supabase from '../../../../../../lib/supabase'; import styles from './styles'; function AddCase() { const local = useLocalSearchParams(); + console.log(local); const { caseId } = local; - // const { data, error } = await supabase.from('Cases').select().eq('id', caseId) + useEffect(() => { + const getData = async () => { + const { data, error } = await supabase + .from('Cases') + .select() + .filter('id', 'is', caseId); + // .eq('id', caseId); + }; + // getData(); + }, []); + // error handling - // const { image, title, blurb } = data + // if (error) { + // console.log('UH OH!'); + // router.back(); + // } + + // console.log(data); + const dummyData = { image: 'https://lastfm.freetls.fastly.net/i/u/ar0/a264ce4e962048cac811215a384ecba7.jpg', title: 'HELLO WORLD', - blurb: + summary: 'This is a little dumb blurb. Will be replaced once I do supabase fetches later yadyadyadyadaydaydadayddyahemorraghagedookiefart', }; const addToCases = () => { @@ -25,7 +43,7 @@ function AddCase() { {dummyData.title} - {dummyData.blurb} + {dummyData.summary} ADD TO CASES {caseId} diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 114aab91..05997dc2 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -26,20 +26,18 @@ function QRCodeScannerScreen() { getBarCodeScannerPermissions(); }, []); - const isValidBarcode = (caseId: string) => - caseId === 'NOTHING' || caseId === 'NOT A VALID BARCODE'; + const isValidBarcode = (caseId: string) => true; const handleBarCodeScanned = async (result: BarCodeScannerResult) => { if (!scanned) { setData(result.data); + if (isValidBarcode(data)) { setScanned(true); router.push({ - pathname: '/Cases/QRCodeScanner/AddCase', + pathname: '/Cases/QRCodeScanner/AddCase', // theres actually no mf way its this hard to pass some information to a page bruh params: { caseId: data }, }); - setData('NOTHING'); - setScanned(false); // Allow for more scanning } else { setData('NOT A VALID BARCODE'); }