Skip to content

Commit

Permalink
BRUH
Browse files Browse the repository at this point in the history
  • Loading branch information
philipye314 committed Oct 12, 2023
1 parent 34fae7e commit 1f802fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand All @@ -25,7 +43,7 @@ function AddCase() {
<View style={styles.container}>
<Text style={styles.title}>{dummyData.title}</Text>
<Image style={styles.image} source={{ uri: dummyData.image }} />
<Text style={styles.blurb}>{dummyData.blurb}</Text>
<Text style={styles.blurb}>{dummyData.summary}</Text>
<TouchableOpacity onPress={addToCases} style={styles.button}>
<Text>ADD TO CASES {caseId}</Text>
</TouchableOpacity>
Expand Down
8 changes: 3 additions & 5 deletions src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit 1f802fa

Please sign in to comment.