From 7028adab68d6bc82ed58b9678735f83d9c2bf2bf Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:35:19 -0700 Subject: [PATCH 01/36] fixinggggg --- .../Cases/QRCodeScanner/AddCase/index.tsx | 78 +++++++++++++++++++ .../Cases/QRCodeScanner/AddCase/styles.ts | 40 ++++++++++ src/supabase/queries/case.ts | 28 +++++++ 3 files changed, 146 insertions(+) create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts create mode 100644 src/supabase/queries/case.ts diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx new file mode 100644 index 00000000..fd68110f --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -0,0 +1,78 @@ +import { useLocalSearchParams, useRouter } from 'expo-router'; +import React, { useEffect, useState } from 'react'; +import { Image, Text, TouchableOpacity, View } from 'react-native'; +import { getCase, uploadCase } from '../../../../../supabase/queries/case'; +import styles from './styles'; + +enum caseStatus { + NotStarted, + InProgress, + Settled, + Cancelled, +} + +export interface Case { + id: number; + approved: boolean; + title: string; + summary: string; + image: string; + caseStatus: caseStatus; +} + +function AddCase() { + const local = useLocalSearchParams(); + const { caseId } = local; + const router = useRouter(); + + const [dataImage, setDataImage] = useState(''); + const [dataTitle, setDataTitle] = useState(''); + const [dataSummary, setDataSummary] = useState(''); + + const parseData = (data: any) => { + const myData = { + ...(data[0] as Partial), + }; + return myData as Case; + }; + + useEffect(() => { + const getData = async () => { + const { data, error } = await getCase(caseId); + if (error) { + console.log('error'); + } + + const myData = parseData(data); + const { image, title, summary } = myData; + + setDataImage(image); + setDataTitle(title); + setDataSummary(summary); + console.log(data); + }; + getData(); + }, []); + + const addToCases = async () => { + const { error } = uploadCase(caseId); + if (error) { + console.log(error); + } + }; + return ( + + {dataTitle} + + {dataSummary} + + ADD TO CASES + + router.back()} style={styles.button}> + CANCEL + + + ); +} + +export default AddCase; diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts new file mode 100644 index 00000000..516fe7b5 --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts @@ -0,0 +1,40 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + margin: 40, + }, + + title: { + fontSize: 30, + fontWeight: 'bold', + }, + + image: { + height: 200, + width: 334, + marginTop: 10, + marginBottom: 10, + }, + + blurb: { + fontSize: 17, + marginTop: 10, + marginBottom: 50, + }, + + button: { + border: 'solid', + borderWidth: 2, + marginTop: 10, + marginBottom: 10, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: '#339FFF', + height: 75, + width: 334, + borderRadius: 20, + }, +}); diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts new file mode 100644 index 00000000..280c422a --- /dev/null +++ b/src/supabase/queries/case.ts @@ -0,0 +1,28 @@ +import supabase from '../createClient'; + +export const getCase = async (caseId: any) => { + const { data, error } = await supabase + .from('Cases') + .select() + .eq('id', caseId); + return { data, error }; +}; + +export const uploadCase = async (caseId: any) => { + // temporary signin + await supabase.auth.signInWithPassword({ + email: 'example@email.com', + password: 'example-password', + }); + + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.identities[0].user_id; + const { error } = await supabase.from('status').insert({ caseId, userId }); + + // temporary sign out + await supabase.auth.signOut(); + console.log(error); + return { error }; +}; From 598f9e0b20dc9c19ceb4f90190c8b7b2923de705 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:48:50 -0700 Subject: [PATCH 02/36] i'm so goated --- .../Cases/QRCodeScanner/AddCase/index.tsx | 5 +---- .../Cases/QRCodeScanner/index.tsx | 22 +++++++++---------- src/supabase/queries/case.ts | 10 +-------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index fd68110f..89cfd225 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -55,10 +55,7 @@ function AddCase() { }, []); const addToCases = async () => { - const { error } = uploadCase(caseId); - if (error) { - console.log(error); - } + uploadCase(caseId); }; return ( diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 07fe6b4e..d9a7a1b4 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -2,9 +2,7 @@ import { BarCodeScanner, BarCodeScannerResult } from 'expo-barcode-scanner'; import { router } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; - import styles from './styles'; -import { signOutUser } from '../../../../supabase/queries/auth'; enum permissions { UNDETERMINED, @@ -14,8 +12,7 @@ enum permissions { function QRCodeScannerScreen() { const [hasPermission, setHasPermission] = useState(permissions.UNDETERMINED); - const [scanned, setScanned] = useState(false); - const [data, setData] = useState('NOTHING'); + const [message, setMessage] = useState(''); useEffect(() => { const getBarCodeScannerPermissions = async () => { @@ -27,10 +24,16 @@ function QRCodeScannerScreen() { getBarCodeScannerPermissions(); }, []); + const isValidBarcode = (caseId: string) => true; + const handleBarCodeScanned = async (result: BarCodeScannerResult) => { - if (!scanned) { - setScanned(true); - setData(result.data); + if (isValidBarcode(result.data)) { + router.push({ + pathname: '/Cases/QRCodeScanner/AddCase', + params: { caseId: result.data }, + }); + } else { + setMessage('INVALID QR CODE!'); } }; @@ -45,13 +48,10 @@ function QRCodeScannerScreen() { onBarCodeScanned={handleBarCodeScanned} style={[styles.scanner]} /> - Current Scanning: {data} + Current Scanning: {message} router.back()} style={styles.button}> Go Back - signOutUser()} style={styles.button}> - Sign out - ); } diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts index 280c422a..45b8090e 100644 --- a/src/supabase/queries/case.ts +++ b/src/supabase/queries/case.ts @@ -9,20 +9,12 @@ export const getCase = async (caseId: any) => { }; export const uploadCase = async (caseId: any) => { - // temporary signin - await supabase.auth.signInWithPassword({ - email: 'example@email.com', - password: 'example-password', - }); - const { data: { user }, } = await supabase.auth.getUser(); - const userId = user?.identities[0].user_id; + const userId = user?.id; const { error } = await supabase.from('status').insert({ caseId, userId }); - // temporary sign out - await supabase.auth.signOut(); console.log(error); return { error }; }; From 1a6394cea5389c96535891340a6a71cc03cb0029 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:35:19 -0700 Subject: [PATCH 03/36] fixinggggg --- .../Cases/QRCodeScanner/AddCase/index.tsx | 78 +++++++++++++++++++ .../Cases/QRCodeScanner/AddCase/styles.ts | 40 ++++++++++ src/supabase/queries/case.ts | 28 +++++++ 3 files changed, 146 insertions(+) create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts create mode 100644 src/supabase/queries/case.ts diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx new file mode 100644 index 00000000..fd68110f --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -0,0 +1,78 @@ +import { useLocalSearchParams, useRouter } from 'expo-router'; +import React, { useEffect, useState } from 'react'; +import { Image, Text, TouchableOpacity, View } from 'react-native'; +import { getCase, uploadCase } from '../../../../../supabase/queries/case'; +import styles from './styles'; + +enum caseStatus { + NotStarted, + InProgress, + Settled, + Cancelled, +} + +export interface Case { + id: number; + approved: boolean; + title: string; + summary: string; + image: string; + caseStatus: caseStatus; +} + +function AddCase() { + const local = useLocalSearchParams(); + const { caseId } = local; + const router = useRouter(); + + const [dataImage, setDataImage] = useState(''); + const [dataTitle, setDataTitle] = useState(''); + const [dataSummary, setDataSummary] = useState(''); + + const parseData = (data: any) => { + const myData = { + ...(data[0] as Partial), + }; + return myData as Case; + }; + + useEffect(() => { + const getData = async () => { + const { data, error } = await getCase(caseId); + if (error) { + console.log('error'); + } + + const myData = parseData(data); + const { image, title, summary } = myData; + + setDataImage(image); + setDataTitle(title); + setDataSummary(summary); + console.log(data); + }; + getData(); + }, []); + + const addToCases = async () => { + const { error } = uploadCase(caseId); + if (error) { + console.log(error); + } + }; + return ( + + {dataTitle} + + {dataSummary} + + ADD TO CASES + + router.back()} style={styles.button}> + CANCEL + + + ); +} + +export default AddCase; diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts new file mode 100644 index 00000000..516fe7b5 --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts @@ -0,0 +1,40 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + margin: 40, + }, + + title: { + fontSize: 30, + fontWeight: 'bold', + }, + + image: { + height: 200, + width: 334, + marginTop: 10, + marginBottom: 10, + }, + + blurb: { + fontSize: 17, + marginTop: 10, + marginBottom: 50, + }, + + button: { + border: 'solid', + borderWidth: 2, + marginTop: 10, + marginBottom: 10, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: '#339FFF', + height: 75, + width: 334, + borderRadius: 20, + }, +}); diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts new file mode 100644 index 00000000..280c422a --- /dev/null +++ b/src/supabase/queries/case.ts @@ -0,0 +1,28 @@ +import supabase from '../createClient'; + +export const getCase = async (caseId: any) => { + const { data, error } = await supabase + .from('Cases') + .select() + .eq('id', caseId); + return { data, error }; +}; + +export const uploadCase = async (caseId: any) => { + // temporary signin + await supabase.auth.signInWithPassword({ + email: 'example@email.com', + password: 'example-password', + }); + + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.identities[0].user_id; + const { error } = await supabase.from('status').insert({ caseId, userId }); + + // temporary sign out + await supabase.auth.signOut(); + console.log(error); + return { error }; +}; From 9cd8681f8c555926ebc67f88a68062d53eb2788f Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:48:50 -0700 Subject: [PATCH 04/36] i'm so goated --- .../Cases/QRCodeScanner/AddCase/index.tsx | 5 +---- .../Cases/QRCodeScanner/index.tsx | 22 +++++++++---------- src/supabase/queries/case.ts | 10 +-------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index fd68110f..89cfd225 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -55,10 +55,7 @@ function AddCase() { }, []); const addToCases = async () => { - const { error } = uploadCase(caseId); - if (error) { - console.log(error); - } + uploadCase(caseId); }; return ( diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 07fe6b4e..d9a7a1b4 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -2,9 +2,7 @@ import { BarCodeScanner, BarCodeScannerResult } from 'expo-barcode-scanner'; import { router } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; - import styles from './styles'; -import { signOutUser } from '../../../../supabase/queries/auth'; enum permissions { UNDETERMINED, @@ -14,8 +12,7 @@ enum permissions { function QRCodeScannerScreen() { const [hasPermission, setHasPermission] = useState(permissions.UNDETERMINED); - const [scanned, setScanned] = useState(false); - const [data, setData] = useState('NOTHING'); + const [message, setMessage] = useState(''); useEffect(() => { const getBarCodeScannerPermissions = async () => { @@ -27,10 +24,16 @@ function QRCodeScannerScreen() { getBarCodeScannerPermissions(); }, []); + const isValidBarcode = (caseId: string) => true; + const handleBarCodeScanned = async (result: BarCodeScannerResult) => { - if (!scanned) { - setScanned(true); - setData(result.data); + if (isValidBarcode(result.data)) { + router.push({ + pathname: '/Cases/QRCodeScanner/AddCase', + params: { caseId: result.data }, + }); + } else { + setMessage('INVALID QR CODE!'); } }; @@ -45,13 +48,10 @@ function QRCodeScannerScreen() { onBarCodeScanned={handleBarCodeScanned} style={[styles.scanner]} /> - Current Scanning: {data} + Current Scanning: {message} router.back()} style={styles.button}> Go Back - signOutUser()} style={styles.button}> - Sign out - ); } diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts index 280c422a..45b8090e 100644 --- a/src/supabase/queries/case.ts +++ b/src/supabase/queries/case.ts @@ -9,20 +9,12 @@ export const getCase = async (caseId: any) => { }; export const uploadCase = async (caseId: any) => { - // temporary signin - await supabase.auth.signInWithPassword({ - email: 'example@email.com', - password: 'example-password', - }); - const { data: { user }, } = await supabase.auth.getUser(); - const userId = user?.identities[0].user_id; + const userId = user?.id; const { error } = await supabase.from('status').insert({ caseId, userId }); - // temporary sign out - await supabase.auth.signOut(); console.log(error); return { error }; }; From 47ae70d23b0ab22a034ea0131574d215fc6bf2e1 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:35:19 -0700 Subject: [PATCH 05/36] fixinggggg --- .../Cases/QRCodeScanner/AddCase/index.tsx | 78 +++++++++++++++++++ .../Cases/QRCodeScanner/AddCase/styles.ts | 40 ++++++++++ src/supabase/queries/case.ts | 28 +++++++ 3 files changed, 146 insertions(+) create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts create mode 100644 src/supabase/queries/case.ts diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx new file mode 100644 index 00000000..fd68110f --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -0,0 +1,78 @@ +import { useLocalSearchParams, useRouter } from 'expo-router'; +import React, { useEffect, useState } from 'react'; +import { Image, Text, TouchableOpacity, View } from 'react-native'; +import { getCase, uploadCase } from '../../../../../supabase/queries/case'; +import styles from './styles'; + +enum caseStatus { + NotStarted, + InProgress, + Settled, + Cancelled, +} + +export interface Case { + id: number; + approved: boolean; + title: string; + summary: string; + image: string; + caseStatus: caseStatus; +} + +function AddCase() { + const local = useLocalSearchParams(); + const { caseId } = local; + const router = useRouter(); + + const [dataImage, setDataImage] = useState(''); + const [dataTitle, setDataTitle] = useState(''); + const [dataSummary, setDataSummary] = useState(''); + + const parseData = (data: any) => { + const myData = { + ...(data[0] as Partial), + }; + return myData as Case; + }; + + useEffect(() => { + const getData = async () => { + const { data, error } = await getCase(caseId); + if (error) { + console.log('error'); + } + + const myData = parseData(data); + const { image, title, summary } = myData; + + setDataImage(image); + setDataTitle(title); + setDataSummary(summary); + console.log(data); + }; + getData(); + }, []); + + const addToCases = async () => { + const { error } = uploadCase(caseId); + if (error) { + console.log(error); + } + }; + return ( + + {dataTitle} + + {dataSummary} + + ADD TO CASES + + router.back()} style={styles.button}> + CANCEL + + + ); +} + +export default AddCase; diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts new file mode 100644 index 00000000..516fe7b5 --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts @@ -0,0 +1,40 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + margin: 40, + }, + + title: { + fontSize: 30, + fontWeight: 'bold', + }, + + image: { + height: 200, + width: 334, + marginTop: 10, + marginBottom: 10, + }, + + blurb: { + fontSize: 17, + marginTop: 10, + marginBottom: 50, + }, + + button: { + border: 'solid', + borderWidth: 2, + marginTop: 10, + marginBottom: 10, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: '#339FFF', + height: 75, + width: 334, + borderRadius: 20, + }, +}); diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts new file mode 100644 index 00000000..280c422a --- /dev/null +++ b/src/supabase/queries/case.ts @@ -0,0 +1,28 @@ +import supabase from '../createClient'; + +export const getCase = async (caseId: any) => { + const { data, error } = await supabase + .from('Cases') + .select() + .eq('id', caseId); + return { data, error }; +}; + +export const uploadCase = async (caseId: any) => { + // temporary signin + await supabase.auth.signInWithPassword({ + email: 'example@email.com', + password: 'example-password', + }); + + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.identities[0].user_id; + const { error } = await supabase.from('status').insert({ caseId, userId }); + + // temporary sign out + await supabase.auth.signOut(); + console.log(error); + return { error }; +}; From 843a069397c3dc845c3cdaf228ca272e1643a7bc Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:48:50 -0700 Subject: [PATCH 06/36] i'm so goated --- .../Cases/QRCodeScanner/AddCase/index.tsx | 5 +---- .../Cases/QRCodeScanner/index.tsx | 22 +++++++++---------- src/supabase/queries/case.ts | 10 +-------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index fd68110f..89cfd225 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -55,10 +55,7 @@ function AddCase() { }, []); const addToCases = async () => { - const { error } = uploadCase(caseId); - if (error) { - console.log(error); - } + uploadCase(caseId); }; return ( diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 07fe6b4e..d9a7a1b4 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -2,9 +2,7 @@ import { BarCodeScanner, BarCodeScannerResult } from 'expo-barcode-scanner'; import { router } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; - import styles from './styles'; -import { signOutUser } from '../../../../supabase/queries/auth'; enum permissions { UNDETERMINED, @@ -14,8 +12,7 @@ enum permissions { function QRCodeScannerScreen() { const [hasPermission, setHasPermission] = useState(permissions.UNDETERMINED); - const [scanned, setScanned] = useState(false); - const [data, setData] = useState('NOTHING'); + const [message, setMessage] = useState(''); useEffect(() => { const getBarCodeScannerPermissions = async () => { @@ -27,10 +24,16 @@ function QRCodeScannerScreen() { getBarCodeScannerPermissions(); }, []); + const isValidBarcode = (caseId: string) => true; + const handleBarCodeScanned = async (result: BarCodeScannerResult) => { - if (!scanned) { - setScanned(true); - setData(result.data); + if (isValidBarcode(result.data)) { + router.push({ + pathname: '/Cases/QRCodeScanner/AddCase', + params: { caseId: result.data }, + }); + } else { + setMessage('INVALID QR CODE!'); } }; @@ -45,13 +48,10 @@ function QRCodeScannerScreen() { onBarCodeScanned={handleBarCodeScanned} style={[styles.scanner]} /> - Current Scanning: {data} + Current Scanning: {message} router.back()} style={styles.button}> Go Back - signOutUser()} style={styles.button}> - Sign out - ); } diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts index 280c422a..45b8090e 100644 --- a/src/supabase/queries/case.ts +++ b/src/supabase/queries/case.ts @@ -9,20 +9,12 @@ export const getCase = async (caseId: any) => { }; export const uploadCase = async (caseId: any) => { - // temporary signin - await supabase.auth.signInWithPassword({ - email: 'example@email.com', - password: 'example-password', - }); - const { data: { user }, } = await supabase.auth.getUser(); - const userId = user?.identities[0].user_id; + const userId = user?.id; const { error } = await supabase.from('status').insert({ caseId, userId }); - // temporary sign out - await supabase.auth.signOut(); console.log(error); return { error }; }; From 2b611dacaa5376503adb5a7a659ec21ba401493f Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 10:48:59 -0700 Subject: [PATCH 07/36] hi --- .eslintignore 2 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .eslintignore 2 diff --git a/.eslintignore 2 b/.eslintignore 2 new file mode 100644 index 00000000..4cf897b0 --- /dev/null +++ b/.eslintignore 2 @@ -0,0 +1,2 @@ +/.expo +node_modules \ No newline at end of file From e83fd77e30bee9e5028cdaf8b6129c57b0fa321f Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:32:37 -0700 Subject: [PATCH 08/36] fixed some supabase issues --- .../Cases/QRCodeScanner/AddCase/index.tsx | 64 ++++--------------- .../Cases/QRCodeScanner/index.tsx | 4 +- src/supabase/queries/cases.ts | 2 +- 3 files changed, 17 insertions(+), 53 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index 89cfd225..35c7e333 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -2,66 +2,28 @@ import { useLocalSearchParams, useRouter } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Image, Text, TouchableOpacity, View } from 'react-native'; import { getCase, uploadCase } from '../../../../../supabase/queries/case'; +import { CaseUid } from '../../../../../types/types'; import styles from './styles'; -enum caseStatus { - NotStarted, - InProgress, - Settled, - Cancelled, -} - -export interface Case { - id: number; - approved: boolean; - title: string; - summary: string; - image: string; - caseStatus: caseStatus; -} - function AddCase() { - const local = useLocalSearchParams(); - const { caseId } = local; + const { id, title, summary, image } = useLocalSearchParams<{ + id: CaseUid; + title: string; + summary: string; + image: string; + }>(); + console.log(id, title, summary, image); const router = useRouter(); - const [dataImage, setDataImage] = useState(''); - const [dataTitle, setDataTitle] = useState(''); - const [dataSummary, setDataSummary] = useState(''); - - const parseData = (data: any) => { - const myData = { - ...(data[0] as Partial), - }; - return myData as Case; - }; - - useEffect(() => { - const getData = async () => { - const { data, error } = await getCase(caseId); - if (error) { - console.log('error'); - } - - const myData = parseData(data); - const { image, title, summary } = myData; - - setDataImage(image); - setDataTitle(title); - setDataSummary(summary); - console.log(data); - }; - getData(); - }, []); - const addToCases = async () => { - uploadCase(caseId); + uploadCase(id); + router.push('/Cases'); }; return ( - {dataTitle} - - {dataSummary} + {title} + + {summary} ADD TO CASES diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index d9a7a1b4..546a42b2 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -2,6 +2,7 @@ import { BarCodeScanner, BarCodeScannerResult } from 'expo-barcode-scanner'; import { router } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; +import { getCaseById } from '../../../../supabase/queries/cases'; import styles from './styles'; enum permissions { @@ -28,9 +29,10 @@ function QRCodeScannerScreen() { const handleBarCodeScanned = async (result: BarCodeScannerResult) => { if (isValidBarcode(result.data)) { + const { id, title, summary, image } = await getCaseById(result.data); router.push({ pathname: '/Cases/QRCodeScanner/AddCase', - params: { caseId: result.data }, + params: { id, title, summary, image }, }); } else { setMessage('INVALID QR CODE!'); diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index c4ad8dd4..72e2b937 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -79,7 +79,7 @@ export async function getCasesByIds(caseIds: CaseUid[]): Promise { */ export function parseCase(item: any): Case { const formattedCase: Case = { - id: item.id, + id: item.caseId, approved: item.approved, title: item.title, blurb: item.blurb, From df2329c66dcea0947ef584874d263981f1d510a8 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:39:45 -0700 Subject: [PATCH 09/36] hello --- .../Cases/QRCodeScanner/AddCase/styles.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts index 516fe7b5..b6b6f8c9 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts @@ -13,8 +13,8 @@ export default StyleSheet.create({ }, image: { - height: 200, - width: 334, + height: '35%', + width: '100%', marginTop: 10, marginBottom: 10, }, @@ -33,8 +33,8 @@ export default StyleSheet.create({ alignItems: 'center', justifyContent: 'center', backgroundColor: '#339FFF', - height: 75, - width: 334, + height: '10%', + width: '100%', borderRadius: 20, }, }); From 2ebf1e7634e4a95037b75c4451965b12145799bb Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:44:28 -0700 Subject: [PATCH 10/36] fixed the query doubled file --- .../Cases/QRCodeScanner/AddCase/index.tsx | 3 +-- src/supabase/queries/case.ts | 20 ------------------- src/supabase/queries/cases.ts | 11 ++++++++++ 3 files changed, 12 insertions(+), 22 deletions(-) delete mode 100644 src/supabase/queries/case.ts diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index 35c7e333..d7c9324f 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -1,7 +1,6 @@ import { useLocalSearchParams, useRouter } from 'expo-router'; -import React, { useEffect, useState } from 'react'; import { Image, Text, TouchableOpacity, View } from 'react-native'; -import { getCase, uploadCase } from '../../../../../supabase/queries/case'; +import { uploadCase } from '../../../../../supabase/queries/cases'; import { CaseUid } from '../../../../../types/types'; import styles from './styles'; diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts deleted file mode 100644 index 45b8090e..00000000 --- a/src/supabase/queries/case.ts +++ /dev/null @@ -1,20 +0,0 @@ -import supabase from '../createClient'; - -export const getCase = async (caseId: any) => { - const { data, error } = await supabase - .from('Cases') - .select() - .eq('id', caseId); - return { data, error }; -}; - -export const uploadCase = async (caseId: any) => { - const { - data: { user }, - } = await supabase.auth.getUser(); - const userId = user?.id; - const { error } = await supabase.from('status').insert({ caseId, userId }); - - console.log(error); - return { error }; -}; diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index 72e2b937..002bbafb 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -71,6 +71,17 @@ export async function getCasesByIds(caseIds: CaseUid[]): Promise { } } +export const uploadCase = async (caseId: any) => { + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.id; + const { error } = await supabase.from('status').insert({ caseId, userId }); + + console.log(error); + return { error }; +}; + /** * Parse supabase case query and return Case object. * From c0b0181a82d65aec5dca4790d3e8f2e2e49a8bb0 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:35:19 -0700 Subject: [PATCH 11/36] fixinggggg --- .../Cases/QRCodeScanner/AddCase/index.tsx | 78 +++++++++++++++++++ .../Cases/QRCodeScanner/AddCase/styles.ts | 40 ++++++++++ src/supabase/queries/case.ts | 28 +++++++ 3 files changed, 146 insertions(+) create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts create mode 100644 src/supabase/queries/case.ts diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx new file mode 100644 index 00000000..fd68110f --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -0,0 +1,78 @@ +import { useLocalSearchParams, useRouter } from 'expo-router'; +import React, { useEffect, useState } from 'react'; +import { Image, Text, TouchableOpacity, View } from 'react-native'; +import { getCase, uploadCase } from '../../../../../supabase/queries/case'; +import styles from './styles'; + +enum caseStatus { + NotStarted, + InProgress, + Settled, + Cancelled, +} + +export interface Case { + id: number; + approved: boolean; + title: string; + summary: string; + image: string; + caseStatus: caseStatus; +} + +function AddCase() { + const local = useLocalSearchParams(); + const { caseId } = local; + const router = useRouter(); + + const [dataImage, setDataImage] = useState(''); + const [dataTitle, setDataTitle] = useState(''); + const [dataSummary, setDataSummary] = useState(''); + + const parseData = (data: any) => { + const myData = { + ...(data[0] as Partial), + }; + return myData as Case; + }; + + useEffect(() => { + const getData = async () => { + const { data, error } = await getCase(caseId); + if (error) { + console.log('error'); + } + + const myData = parseData(data); + const { image, title, summary } = myData; + + setDataImage(image); + setDataTitle(title); + setDataSummary(summary); + console.log(data); + }; + getData(); + }, []); + + const addToCases = async () => { + const { error } = uploadCase(caseId); + if (error) { + console.log(error); + } + }; + return ( + + {dataTitle} + + {dataSummary} + + ADD TO CASES + + router.back()} style={styles.button}> + CANCEL + + + ); +} + +export default AddCase; diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts new file mode 100644 index 00000000..516fe7b5 --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts @@ -0,0 +1,40 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + margin: 40, + }, + + title: { + fontSize: 30, + fontWeight: 'bold', + }, + + image: { + height: 200, + width: 334, + marginTop: 10, + marginBottom: 10, + }, + + blurb: { + fontSize: 17, + marginTop: 10, + marginBottom: 50, + }, + + button: { + border: 'solid', + borderWidth: 2, + marginTop: 10, + marginBottom: 10, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: '#339FFF', + height: 75, + width: 334, + borderRadius: 20, + }, +}); diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts new file mode 100644 index 00000000..280c422a --- /dev/null +++ b/src/supabase/queries/case.ts @@ -0,0 +1,28 @@ +import supabase from '../createClient'; + +export const getCase = async (caseId: any) => { + const { data, error } = await supabase + .from('Cases') + .select() + .eq('id', caseId); + return { data, error }; +}; + +export const uploadCase = async (caseId: any) => { + // temporary signin + await supabase.auth.signInWithPassword({ + email: 'example@email.com', + password: 'example-password', + }); + + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.identities[0].user_id; + const { error } = await supabase.from('status').insert({ caseId, userId }); + + // temporary sign out + await supabase.auth.signOut(); + console.log(error); + return { error }; +}; From c5f412fa3f37826714b2d88439220c793d0a5714 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:48:50 -0700 Subject: [PATCH 12/36] i'm so goated --- .../Cases/QRCodeScanner/AddCase/index.tsx | 5 +---- .../Cases/QRCodeScanner/index.tsx | 22 +++++++++---------- src/supabase/queries/case.ts | 10 +-------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index fd68110f..89cfd225 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -55,10 +55,7 @@ function AddCase() { }, []); const addToCases = async () => { - const { error } = uploadCase(caseId); - if (error) { - console.log(error); - } + uploadCase(caseId); }; return ( diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 07fe6b4e..d9a7a1b4 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -2,9 +2,7 @@ import { BarCodeScanner, BarCodeScannerResult } from 'expo-barcode-scanner'; import { router } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; - import styles from './styles'; -import { signOutUser } from '../../../../supabase/queries/auth'; enum permissions { UNDETERMINED, @@ -14,8 +12,7 @@ enum permissions { function QRCodeScannerScreen() { const [hasPermission, setHasPermission] = useState(permissions.UNDETERMINED); - const [scanned, setScanned] = useState(false); - const [data, setData] = useState('NOTHING'); + const [message, setMessage] = useState(''); useEffect(() => { const getBarCodeScannerPermissions = async () => { @@ -27,10 +24,16 @@ function QRCodeScannerScreen() { getBarCodeScannerPermissions(); }, []); + const isValidBarcode = (caseId: string) => true; + const handleBarCodeScanned = async (result: BarCodeScannerResult) => { - if (!scanned) { - setScanned(true); - setData(result.data); + if (isValidBarcode(result.data)) { + router.push({ + pathname: '/Cases/QRCodeScanner/AddCase', + params: { caseId: result.data }, + }); + } else { + setMessage('INVALID QR CODE!'); } }; @@ -45,13 +48,10 @@ function QRCodeScannerScreen() { onBarCodeScanned={handleBarCodeScanned} style={[styles.scanner]} /> - Current Scanning: {data} + Current Scanning: {message} router.back()} style={styles.button}> Go Back - signOutUser()} style={styles.button}> - Sign out - ); } diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts index 280c422a..45b8090e 100644 --- a/src/supabase/queries/case.ts +++ b/src/supabase/queries/case.ts @@ -9,20 +9,12 @@ export const getCase = async (caseId: any) => { }; export const uploadCase = async (caseId: any) => { - // temporary signin - await supabase.auth.signInWithPassword({ - email: 'example@email.com', - password: 'example-password', - }); - const { data: { user }, } = await supabase.auth.getUser(); - const userId = user?.identities[0].user_id; + const userId = user?.id; const { error } = await supabase.from('status').insert({ caseId, userId }); - // temporary sign out - await supabase.auth.signOut(); console.log(error); return { error }; }; From 29cb908480516f9d5e28642a786e4aef320595ed Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 10:48:59 -0700 Subject: [PATCH 13/36] hi --- .eslintignore 2 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .eslintignore 2 diff --git a/.eslintignore 2 b/.eslintignore 2 new file mode 100644 index 00000000..4cf897b0 --- /dev/null +++ b/.eslintignore 2 @@ -0,0 +1,2 @@ +/.expo +node_modules \ No newline at end of file From f14568ca16a38adc25b126b7c72f9a6018f364a7 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:32:37 -0700 Subject: [PATCH 14/36] fixed some supabase issues --- .../Cases/QRCodeScanner/AddCase/index.tsx | 64 ++++--------------- .../Cases/QRCodeScanner/index.tsx | 4 +- 2 files changed, 16 insertions(+), 52 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index 89cfd225..35c7e333 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -2,66 +2,28 @@ import { useLocalSearchParams, useRouter } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Image, Text, TouchableOpacity, View } from 'react-native'; import { getCase, uploadCase } from '../../../../../supabase/queries/case'; +import { CaseUid } from '../../../../../types/types'; import styles from './styles'; -enum caseStatus { - NotStarted, - InProgress, - Settled, - Cancelled, -} - -export interface Case { - id: number; - approved: boolean; - title: string; - summary: string; - image: string; - caseStatus: caseStatus; -} - function AddCase() { - const local = useLocalSearchParams(); - const { caseId } = local; + const { id, title, summary, image } = useLocalSearchParams<{ + id: CaseUid; + title: string; + summary: string; + image: string; + }>(); + console.log(id, title, summary, image); const router = useRouter(); - const [dataImage, setDataImage] = useState(''); - const [dataTitle, setDataTitle] = useState(''); - const [dataSummary, setDataSummary] = useState(''); - - const parseData = (data: any) => { - const myData = { - ...(data[0] as Partial), - }; - return myData as Case; - }; - - useEffect(() => { - const getData = async () => { - const { data, error } = await getCase(caseId); - if (error) { - console.log('error'); - } - - const myData = parseData(data); - const { image, title, summary } = myData; - - setDataImage(image); - setDataTitle(title); - setDataSummary(summary); - console.log(data); - }; - getData(); - }, []); - const addToCases = async () => { - uploadCase(caseId); + uploadCase(id); + router.push('/Cases'); }; return ( - {dataTitle} - - {dataSummary} + {title} + + {summary} ADD TO CASES diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index d9a7a1b4..546a42b2 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -2,6 +2,7 @@ import { BarCodeScanner, BarCodeScannerResult } from 'expo-barcode-scanner'; import { router } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; +import { getCaseById } from '../../../../supabase/queries/cases'; import styles from './styles'; enum permissions { @@ -28,9 +29,10 @@ function QRCodeScannerScreen() { const handleBarCodeScanned = async (result: BarCodeScannerResult) => { if (isValidBarcode(result.data)) { + const { id, title, summary, image } = await getCaseById(result.data); router.push({ pathname: '/Cases/QRCodeScanner/AddCase', - params: { caseId: result.data }, + params: { id, title, summary, image }, }); } else { setMessage('INVALID QR CODE!'); From f8af844429e604fe6d81ab218ea83d95a9b5105d Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:39:45 -0700 Subject: [PATCH 15/36] hello --- .../Cases/QRCodeScanner/AddCase/styles.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts index 516fe7b5..b6b6f8c9 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles.ts @@ -13,8 +13,8 @@ export default StyleSheet.create({ }, image: { - height: 200, - width: 334, + height: '35%', + width: '100%', marginTop: 10, marginBottom: 10, }, @@ -33,8 +33,8 @@ export default StyleSheet.create({ alignItems: 'center', justifyContent: 'center', backgroundColor: '#339FFF', - height: 75, - width: 334, + height: '10%', + width: '100%', borderRadius: 20, }, }); From 817667197d72829d5468fd087a999fd1e54bc975 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:44:28 -0700 Subject: [PATCH 16/36] fixed the query doubled file --- .../Cases/QRCodeScanner/AddCase/index.tsx | 3 +-- src/supabase/queries/case.ts | 20 ------------------- src/supabase/queries/cases.ts | 11 ++++++++++ 3 files changed, 12 insertions(+), 22 deletions(-) delete mode 100644 src/supabase/queries/case.ts diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index 35c7e333..d7c9324f 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -1,7 +1,6 @@ import { useLocalSearchParams, useRouter } from 'expo-router'; -import React, { useEffect, useState } from 'react'; import { Image, Text, TouchableOpacity, View } from 'react-native'; -import { getCase, uploadCase } from '../../../../../supabase/queries/case'; +import { uploadCase } from '../../../../../supabase/queries/cases'; import { CaseUid } from '../../../../../types/types'; import styles from './styles'; diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts deleted file mode 100644 index 45b8090e..00000000 --- a/src/supabase/queries/case.ts +++ /dev/null @@ -1,20 +0,0 @@ -import supabase from '../createClient'; - -export const getCase = async (caseId: any) => { - const { data, error } = await supabase - .from('Cases') - .select() - .eq('id', caseId); - return { data, error }; -}; - -export const uploadCase = async (caseId: any) => { - const { - data: { user }, - } = await supabase.auth.getUser(); - const userId = user?.id; - const { error } = await supabase.from('status').insert({ caseId, userId }); - - console.log(error); - return { error }; -}; diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index 72e2b937..002bbafb 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -71,6 +71,17 @@ export async function getCasesByIds(caseIds: CaseUid[]): Promise { } } +export const uploadCase = async (caseId: any) => { + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.id; + const { error } = await supabase.from('status').insert({ caseId, userId }); + + console.log(error); + return { error }; +}; + /** * Parse supabase case query and return Case object. * From a341333f9d9cc9d889912eb3a23f5902c6fdc664 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:15:41 -0700 Subject: [PATCH 17/36] heeehaw --- .../Cases/QRCodeScanner/AddCase/index.tsx | 2 +- .../Cases/QRCodeScanner/index.tsx | 19 ++++++++++++++----- src/supabase/queries/cases.ts | 4 ++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index d7c9324f..70a75de8 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -11,7 +11,7 @@ function AddCase() { summary: string; image: string; }>(); - console.log(id, title, summary, image); + const router = useRouter(); const addToCases = async () => { diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 546a42b2..5f4695e4 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -2,7 +2,11 @@ import { BarCodeScanner, BarCodeScannerResult } from 'expo-barcode-scanner'; import { router } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Text, TouchableOpacity, View } from 'react-native'; -import { getCaseById } from '../../../../supabase/queries/cases'; +import supabase from '../../../../supabase/createClient'; +import { + containsDuplicateCase, + getCaseById, +} from '../../../../supabase/queries/cases'; import styles from './styles'; enum permissions { @@ -30,10 +34,15 @@ function QRCodeScannerScreen() { const handleBarCodeScanned = async (result: BarCodeScannerResult) => { if (isValidBarcode(result.data)) { const { id, title, summary, image } = await getCaseById(result.data); - router.push({ - pathname: '/Cases/QRCodeScanner/AddCase', - params: { id, title, summary, image }, - }); + const duplicate = await containsDuplicateCase(id); + if (duplicate) { + console.log('YOU ALREADY HAVE THIS CASE!'); + } else { + router.push({ + pathname: '/Cases/QRCodeScanner/AddCase', + params: { id, title, summary, image }, + }); + } } else { setMessage('INVALID QR CODE!'); } diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index 002bbafb..f5ea9537 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -82,6 +82,10 @@ export const uploadCase = async (caseId: any) => { return { error }; }; +export const containsDuplicateCase = async (caseId: any) => { + return false; +}; + /** * Parse supabase case query and return Case object. * From e7d8c66b1c37b957a24b75126cb1e9bdad06d994 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:38:13 -0700 Subject: [PATCH 18/36] did error handling --- src/supabase/queries/cases.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index f5ea9537..25f1de4a 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -71,7 +71,7 @@ export async function getCasesByIds(caseIds: CaseUid[]): Promise { } } -export const uploadCase = async (caseId: any) => { +export async function uploadCase(caseId: CaseUid) { const { data: { user }, } = await supabase.auth.getUser(); @@ -80,11 +80,24 @@ export const uploadCase = async (caseId: any) => { console.log(error); return { error }; -}; +} -export const containsDuplicateCase = async (caseId: any) => { - return false; -}; +export async function containsDuplicateCase(caseId: CaseUid) { + try { + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.id; + const { data, error } = await supabase + .from('status') + .select() + .eq('userId', userId) + .eq('caseId', caseId); + return data?.length === 0; + } catch (error) { + throw error; + } +} /** * Parse supabase case query and return Case object. From 782ccaff1a7c9151f7d37437df198a307a545d5a Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:46:17 -0700 Subject: [PATCH 19/36] fixing types --- src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx | 1 + src/supabase/queries/cases.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 5f4695e4..625cbe35 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -18,6 +18,7 @@ enum permissions { function QRCodeScannerScreen() { const [hasPermission, setHasPermission] = useState(permissions.UNDETERMINED); const [message, setMessage] = useState(''); + const [scanned, setScanned] = useState(false); useEffect(() => { const getBarCodeScannerPermissions = async () => { diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index 25f1de4a..82a93d1f 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -71,7 +71,7 @@ export async function getCasesByIds(caseIds: CaseUid[]): Promise { } } -export async function uploadCase(caseId: CaseUid) { +export async function uploadCase(caseId: CaseUid | undefined) { const { data: { user }, } = await supabase.auth.getUser(); From 8fe906f1ad68c145ae2986989cb1edf2f7d6b231 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:02:54 -0700 Subject: [PATCH 20/36] hello --- .eslintignore 3 | 2 + .../Cases/QRCodeScanner/AddCase/index 2.tsx | 36 +++++++++++++++++ .../Cases/QRCodeScanner/AddCase/styles 2.ts | 40 +++++++++++++++++++ .../Cases/QRCodeScanner/index.tsx | 1 - 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 .eslintignore 3 create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts diff --git a/.eslintignore 3 b/.eslintignore 3 new file mode 100644 index 00000000..4cf897b0 --- /dev/null +++ b/.eslintignore 3 @@ -0,0 +1,2 @@ +/.expo +node_modules \ No newline at end of file diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx new file mode 100644 index 00000000..c734f9bc --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx @@ -0,0 +1,36 @@ +import { useLocalSearchParams, useRouter } from 'expo-router'; +import { Image, Text, TouchableOpacity, View } from 'react-native'; +import { uploadCase } from '../../../../supabase/queries/cases'; +import { CaseUid } from '../../../../../types/types'; +import styles from './styles'; + +function AddCase() { + const { id, title, summary, image } = useLocalSearchParams<{ + id: CaseUid; + title: string; + summary: string; + image: string; + }>(); + + const router = useRouter(); + + const addToCases = async () => { + uploadCase(id); + router.push('/Cases'); + }; + return ( + + {title} + + {summary} + + ADD TO CASES + + router.back()} style={styles.button}> + CANCEL + + + ); +} + +export default AddCase; diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts new file mode 100644 index 00000000..b6b6f8c9 --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts @@ -0,0 +1,40 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + margin: 40, + }, + + title: { + fontSize: 30, + fontWeight: 'bold', + }, + + image: { + height: '35%', + width: '100%', + marginTop: 10, + marginBottom: 10, + }, + + blurb: { + fontSize: 17, + marginTop: 10, + marginBottom: 50, + }, + + button: { + border: 'solid', + borderWidth: 2, + marginTop: 10, + marginBottom: 10, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: '#339FFF', + height: '10%', + width: '100%', + borderRadius: 20, + }, +}); diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 625cbe35..5f4695e4 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -18,7 +18,6 @@ enum permissions { function QRCodeScannerScreen() { const [hasPermission, setHasPermission] = useState(permissions.UNDETERMINED); const [message, setMessage] = useState(''); - const [scanned, setScanned] = useState(false); useEffect(() => { const getBarCodeScannerPermissions = async () => { From bc59fdbf01d608d3fe1618c6385df9573ce5cc5a Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:04:02 -0700 Subject: [PATCH 21/36] fixing unused usestate --- .../Cases/QRCodeScanner/AddCase/index 2.tsx | 36 ----------------- .../Cases/QRCodeScanner/AddCase/styles 2.ts | 40 ------------------- 2 files changed, 76 deletions(-) delete mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx delete mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx deleted file mode 100644 index c734f9bc..00000000 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { useLocalSearchParams, useRouter } from 'expo-router'; -import { Image, Text, TouchableOpacity, View } from 'react-native'; -import { uploadCase } from '../../../../supabase/queries/cases'; -import { CaseUid } from '../../../../../types/types'; -import styles from './styles'; - -function AddCase() { - const { id, title, summary, image } = useLocalSearchParams<{ - id: CaseUid; - title: string; - summary: string; - image: string; - }>(); - - const router = useRouter(); - - const addToCases = async () => { - uploadCase(id); - router.push('/Cases'); - }; - return ( - - {title} - - {summary} - - ADD TO CASES - - router.back()} style={styles.button}> - CANCEL - - - ); -} - -export default AddCase; diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts deleted file mode 100644 index b6b6f8c9..00000000 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { StyleSheet } from 'react-native'; - -export default StyleSheet.create({ - container: { - flex: 1, - justifyContent: 'center', - margin: 40, - }, - - title: { - fontSize: 30, - fontWeight: 'bold', - }, - - image: { - height: '35%', - width: '100%', - marginTop: 10, - marginBottom: 10, - }, - - blurb: { - fontSize: 17, - marginTop: 10, - marginBottom: 50, - }, - - button: { - border: 'solid', - borderWidth: 2, - marginTop: 10, - marginBottom: 10, - alignItems: 'center', - justifyContent: 'center', - backgroundColor: '#339FFF', - height: '10%', - width: '100%', - borderRadius: 20, - }, -}); From 029e887cb18afc303b4f6576624cc4294b3eb7ad Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:27:34 -0700 Subject: [PATCH 22/36] hello --- src/Components/EligibilityCard/EligibilityCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/EligibilityCard/EligibilityCard.tsx b/src/Components/EligibilityCard/EligibilityCard.tsx index 2b9b7c7b..f23bf834 100644 --- a/src/Components/EligibilityCard/EligibilityCard.tsx +++ b/src/Components/EligibilityCard/EligibilityCard.tsx @@ -4,7 +4,7 @@ import { View, Text } from 'react-native'; export default function EligibilityCard() { return ( - EligibilityCard + EligibilityCar ); } From 2f79f9ac95ad7bb3a667990eb6ff51606e10f842 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:35:19 -0700 Subject: [PATCH 23/36] fixinggggg --- src/supabase/queries/case.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/supabase/queries/case.ts diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts new file mode 100644 index 00000000..280c422a --- /dev/null +++ b/src/supabase/queries/case.ts @@ -0,0 +1,28 @@ +import supabase from '../createClient'; + +export const getCase = async (caseId: any) => { + const { data, error } = await supabase + .from('Cases') + .select() + .eq('id', caseId); + return { data, error }; +}; + +export const uploadCase = async (caseId: any) => { + // temporary signin + await supabase.auth.signInWithPassword({ + email: 'example@email.com', + password: 'example-password', + }); + + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.identities[0].user_id; + const { error } = await supabase.from('status').insert({ caseId, userId }); + + // temporary sign out + await supabase.auth.signOut(); + console.log(error); + return { error }; +}; From 9c8603a7c1d88f6cbfa57e6e88a0dbd081a339fe Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:48:50 -0700 Subject: [PATCH 24/36] i'm so goated --- src/supabase/queries/case.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts index 280c422a..45b8090e 100644 --- a/src/supabase/queries/case.ts +++ b/src/supabase/queries/case.ts @@ -9,20 +9,12 @@ export const getCase = async (caseId: any) => { }; export const uploadCase = async (caseId: any) => { - // temporary signin - await supabase.auth.signInWithPassword({ - email: 'example@email.com', - password: 'example-password', - }); - const { data: { user }, } = await supabase.auth.getUser(); - const userId = user?.identities[0].user_id; + const userId = user?.id; const { error } = await supabase.from('status').insert({ caseId, userId }); - // temporary sign out - await supabase.auth.signOut(); console.log(error); return { error }; }; From 27631b2fc978e73f592fc5879f7865401c3b5206 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:32:37 -0700 Subject: [PATCH 25/36] fixed some supabase issues --- .../(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx index 70a75de8..a092c057 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index.tsx @@ -11,7 +11,6 @@ function AddCase() { summary: string; image: string; }>(); - const router = useRouter(); const addToCases = async () => { From dfa1106aeea311194c9402ebd73be185f14d8c36 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 11:44:28 -0700 Subject: [PATCH 26/36] fixed the query doubled file --- src/supabase/queries/case.ts | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 src/supabase/queries/case.ts diff --git a/src/supabase/queries/case.ts b/src/supabase/queries/case.ts deleted file mode 100644 index 45b8090e..00000000 --- a/src/supabase/queries/case.ts +++ /dev/null @@ -1,20 +0,0 @@ -import supabase from '../createClient'; - -export const getCase = async (caseId: any) => { - const { data, error } = await supabase - .from('Cases') - .select() - .eq('id', caseId); - return { data, error }; -}; - -export const uploadCase = async (caseId: any) => { - const { - data: { user }, - } = await supabase.auth.getUser(); - const userId = user?.id; - const { error } = await supabase.from('status').insert({ caseId, userId }); - - console.log(error); - return { error }; -}; From 3e8985c30990755404f0340be940c7fc882a9ff4 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:38:13 -0700 Subject: [PATCH 27/36] did error handling --- src/supabase/queries/cases.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index f5ea9537..25f1de4a 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -71,7 +71,7 @@ export async function getCasesByIds(caseIds: CaseUid[]): Promise { } } -export const uploadCase = async (caseId: any) => { +export async function uploadCase(caseId: CaseUid) { const { data: { user }, } = await supabase.auth.getUser(); @@ -80,11 +80,24 @@ export const uploadCase = async (caseId: any) => { console.log(error); return { error }; -}; +} -export const containsDuplicateCase = async (caseId: any) => { - return false; -}; +export async function containsDuplicateCase(caseId: CaseUid) { + try { + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.id; + const { data, error } = await supabase + .from('status') + .select() + .eq('userId', userId) + .eq('caseId', caseId); + return data?.length === 0; + } catch (error) { + throw error; + } +} /** * Parse supabase case query and return Case object. From 869ce6f19a267aed386be74e428afa2e2e84f264 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:46:17 -0700 Subject: [PATCH 28/36] fixing types --- src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx | 1 + src/supabase/queries/cases.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 5f4695e4..625cbe35 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -18,6 +18,7 @@ enum permissions { function QRCodeScannerScreen() { const [hasPermission, setHasPermission] = useState(permissions.UNDETERMINED); const [message, setMessage] = useState(''); + const [scanned, setScanned] = useState(false); useEffect(() => { const getBarCodeScannerPermissions = async () => { diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index 25f1de4a..82a93d1f 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -71,7 +71,7 @@ export async function getCasesByIds(caseIds: CaseUid[]): Promise { } } -export async function uploadCase(caseId: CaseUid) { +export async function uploadCase(caseId: CaseUid | undefined) { const { data: { user }, } = await supabase.auth.getUser(); From 046e42ae7b9f40abf7332022d2c2bc73f055952d Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:02:54 -0700 Subject: [PATCH 29/36] hello --- .eslintignore 3 | 2 + .../Cases/QRCodeScanner/AddCase/index 2.tsx | 36 +++++++++++++++++ .../Cases/QRCodeScanner/AddCase/styles 2.ts | 40 +++++++++++++++++++ .../Cases/QRCodeScanner/index.tsx | 1 - 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 .eslintignore 3 create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx create mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts diff --git a/.eslintignore 3 b/.eslintignore 3 new file mode 100644 index 00000000..4cf897b0 --- /dev/null +++ b/.eslintignore 3 @@ -0,0 +1,2 @@ +/.expo +node_modules \ No newline at end of file diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx new file mode 100644 index 00000000..c734f9bc --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx @@ -0,0 +1,36 @@ +import { useLocalSearchParams, useRouter } from 'expo-router'; +import { Image, Text, TouchableOpacity, View } from 'react-native'; +import { uploadCase } from '../../../../supabase/queries/cases'; +import { CaseUid } from '../../../../../types/types'; +import styles from './styles'; + +function AddCase() { + const { id, title, summary, image } = useLocalSearchParams<{ + id: CaseUid; + title: string; + summary: string; + image: string; + }>(); + + const router = useRouter(); + + const addToCases = async () => { + uploadCase(id); + router.push('/Cases'); + }; + return ( + + {title} + + {summary} + + ADD TO CASES + + router.back()} style={styles.button}> + CANCEL + + + ); +} + +export default AddCase; diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts new file mode 100644 index 00000000..b6b6f8c9 --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts @@ -0,0 +1,40 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + margin: 40, + }, + + title: { + fontSize: 30, + fontWeight: 'bold', + }, + + image: { + height: '35%', + width: '100%', + marginTop: 10, + marginBottom: 10, + }, + + blurb: { + fontSize: 17, + marginTop: 10, + marginBottom: 50, + }, + + button: { + border: 'solid', + borderWidth: 2, + marginTop: 10, + marginBottom: 10, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: '#339FFF', + height: '10%', + width: '100%', + borderRadius: 20, + }, +}); diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx index 625cbe35..5f4695e4 100644 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/index.tsx @@ -18,7 +18,6 @@ enum permissions { function QRCodeScannerScreen() { const [hasPermission, setHasPermission] = useState(permissions.UNDETERMINED); const [message, setMessage] = useState(''); - const [scanned, setScanned] = useState(false); useEffect(() => { const getBarCodeScannerPermissions = async () => { From 225d1ba530ffaec9bb3dd03568655752e391fba6 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:04:02 -0700 Subject: [PATCH 30/36] fixing unused usestate --- .../Cases/QRCodeScanner/AddCase/index 2.tsx | 36 ----------------- .../Cases/QRCodeScanner/AddCase/styles 2.ts | 40 ------------------- 2 files changed, 76 deletions(-) delete mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx delete mode 100644 src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx deleted file mode 100644 index c734f9bc..00000000 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/index 2.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { useLocalSearchParams, useRouter } from 'expo-router'; -import { Image, Text, TouchableOpacity, View } from 'react-native'; -import { uploadCase } from '../../../../supabase/queries/cases'; -import { CaseUid } from '../../../../../types/types'; -import styles from './styles'; - -function AddCase() { - const { id, title, summary, image } = useLocalSearchParams<{ - id: CaseUid; - title: string; - summary: string; - image: string; - }>(); - - const router = useRouter(); - - const addToCases = async () => { - uploadCase(id); - router.push('/Cases'); - }; - return ( - - {title} - - {summary} - - ADD TO CASES - - router.back()} style={styles.button}> - CANCEL - - - ); -} - -export default AddCase; diff --git a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts b/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts deleted file mode 100644 index b6b6f8c9..00000000 --- a/src/app/(BottomTabNavigation)/Cases/QRCodeScanner/AddCase/styles 2.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { StyleSheet } from 'react-native'; - -export default StyleSheet.create({ - container: { - flex: 1, - justifyContent: 'center', - margin: 40, - }, - - title: { - fontSize: 30, - fontWeight: 'bold', - }, - - image: { - height: '35%', - width: '100%', - marginTop: 10, - marginBottom: 10, - }, - - blurb: { - fontSize: 17, - marginTop: 10, - marginBottom: 50, - }, - - button: { - border: 'solid', - borderWidth: 2, - marginTop: 10, - marginBottom: 10, - alignItems: 'center', - justifyContent: 'center', - backgroundColor: '#339FFF', - height: '10%', - width: '100%', - borderRadius: 20, - }, -}); From d2c0ddeb1d77c76212ac927ec7c1797f4b5b20e6 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:27:34 -0700 Subject: [PATCH 31/36] hello --- src/Components/EligibilityCard/EligibilityCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/EligibilityCard/EligibilityCard.tsx b/src/Components/EligibilityCard/EligibilityCard.tsx index 2b9b7c7b..f23bf834 100644 --- a/src/Components/EligibilityCard/EligibilityCard.tsx +++ b/src/Components/EligibilityCard/EligibilityCard.tsx @@ -4,7 +4,7 @@ import { View, Text } from 'react-native'; export default function EligibilityCard() { return ( - EligibilityCard + EligibilityCar ); } From 592c3ec29abf3b19fae82866faf9d8029865288e Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:43:27 -0700 Subject: [PATCH 32/36] rebasing now --- src/Components/EligibilityCard/EligibilityCard.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Components/EligibilityCard/EligibilityCard.tsx b/src/Components/EligibilityCard/EligibilityCard.tsx index f23bf834..96a5fe7d 100644 --- a/src/Components/EligibilityCard/EligibilityCard.tsx +++ b/src/Components/EligibilityCard/EligibilityCard.tsx @@ -2,9 +2,16 @@ import React from 'react'; import { View, Text } from 'react-native'; export default function EligibilityCard() { + const eligible = false; return ( - EligibilityCar + {eligible && EligibilityCar} + {!eligible && ( + + Not Eligible + Opt out + + )} ); } From 399d01ff5bde6342ebfc47da73ffeb8086f9403d Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:20:21 -0700 Subject: [PATCH 33/36] please --- .../EligibilityCard/EligibilityCard.tsx | 52 ++++++++++++++----- src/Components/EligibilityCard/styles.ts | 33 ++++++++++++ .../CaseScreen/EligibilityForm/index.tsx | 43 +++++++++++++++ .../CaseScreen/EligibilityForm/styles.ts | 49 +++++++++++++++++ src/types/types.tsx | 19 +++++-- 5 files changed, 180 insertions(+), 16 deletions(-) create mode 100644 src/Components/EligibilityCard/styles.ts create mode 100644 src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/index.tsx create mode 100644 src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/styles.ts diff --git a/src/Components/EligibilityCard/EligibilityCard.tsx b/src/Components/EligibilityCard/EligibilityCard.tsx index 96a5fe7d..7b2cc27b 100644 --- a/src/Components/EligibilityCard/EligibilityCard.tsx +++ b/src/Components/EligibilityCard/EligibilityCard.tsx @@ -1,17 +1,43 @@ import React from 'react'; -import { View, Text } from 'react-native'; +import { View, Text, Image } from 'react-native'; +import { TouchableOpacity } from 'react-native-gesture-handler'; +import styles from './styles'; +import { Eligibility } from '../../types/types'; +import { useRouter } from 'expo-router'; export default function EligibilityCard() { - const eligible = false; - return ( - - {eligible && EligibilityCar} - {!eligible && ( - - Not Eligible - Opt out - - )} - - ); + const eligible = Eligibility.ELIGIBLE; + const router = useRouter(); + if (eligible === Eligibility.ELIGIBLE) { + return ( + + router.push('/Cases/CaseScreen/EligibilityForm')} + > + CHECK ELEGIBILITY + + + + ); + } else if (eligible === Eligibility.INELIGIBLE) { + return ( + + + + + OPT OUT + + + + + + FILE CLAIM + + + + ); + } else { + return ; + } } diff --git a/src/Components/EligibilityCard/styles.ts b/src/Components/EligibilityCard/styles.ts new file mode 100644 index 00000000..15dc3b04 --- /dev/null +++ b/src/Components/EligibilityCard/styles.ts @@ -0,0 +1,33 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + eligible: { + height: '20%', + }, + ineligible: { + height: '40%', + }, + container: { + flex: 0, + width: '100%', + justifyContent: 'center', + alignContent: 'center', + }, + button: { + alignSelf: 'center', + height: '90%', + width: '90%', + border: 'solid', + borderColor: 'rgba(0, 0, 0, 0.5)', + borderWidth: 1, + borderRadius: 5, + margin: 5, + }, + inner: { + height: '50%', + }, + arrow: { + height: '20%', + width: '20%', + }, +}); diff --git a/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/index.tsx b/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/index.tsx new file mode 100644 index 00000000..ad9c6b6f --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/index.tsx @@ -0,0 +1,43 @@ +import React from 'react'; +import { View, Text, Image } from 'react-native'; +import { TouchableOpacity } from 'react-native-gesture-handler'; +import { useRouter } from 'expo-router'; +import styles from './styles'; + +export default function EligibilityForm() { + const router = useRouter(); + return ( + + + + The eligibility requirements are as follows: + + + Sexy + Tall + Handsome + + + Do you meet the following requirements? + + + + + console.log('hi')} + > + Yes, I am Eligible + {'->'} + + + + + No, I'm not Eligible + X + + + + + ); +} diff --git a/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/styles.ts b/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/styles.ts new file mode 100644 index 00000000..91962505 --- /dev/null +++ b/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/styles.ts @@ -0,0 +1,49 @@ +import { StyleSheet } from 'react-native'; + +export default StyleSheet.create({ + container: { + flex: 1, + alignItems: 'center', + justifyContent: 'center', + }, + textContainer: { + flex: 0.7, + width: '100%', + justifyContent: 'space-evenly', + paddingHorizontal: 40, + paddingTop: 50, + }, + buttonsContainer: { + flex: 0.3, + width: '100%', + justifyContent: 'center', + padding: 40, + }, + buttonWrapperTop: { + flex: 0.5, + justifyContent: 'flex-end', + }, + buttonWrapperBottom: { + flex: 0.5, + justifyContent: 'flex-start', + }, + button: { + width: '100%', + height: '70%', + borderRadius: 4, + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + paddingHorizontal: 20, + }, + buttonBottom: { + backgroundColor: 'black', + }, + buttonTop: { + borderColor: 'black', + borderWidth: 1, + }, + buttonBottomText: { + color: '#fff', + }, +}); diff --git a/src/types/types.tsx b/src/types/types.tsx index 2eaa35bb..80c2e456 100644 --- a/src/types/types.tsx +++ b/src/types/types.tsx @@ -1,7 +1,7 @@ export type CaseUid = string; export type UserUid = string; -export interface Case { +export type Case = { id: CaseUid; approved: boolean; title: string; @@ -14,13 +14,26 @@ export interface Case { caseStatus: string; date: Date; lawFirm: string; -} +}; -export interface User { +export type User = { id: UserUid; firstName: string; middleName: string | null; lastName: string; email: string; addresss: string; +}; + +export type Status = { + id: CaseUid; + userId: UserUid; + eligible: Eligibility; + excluded: boolean; +}; + +export enum Eligibility { + ELIGIBLE, + INELIGIBLE, + UNDETERMINED, } From 70d808ca2aadfa645e19346bfee0202a08f2aa78 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Mon, 30 Oct 2023 15:09:56 -0700 Subject: [PATCH 34/36] wip, did bit of styling --- .../EligibilityCard/EligibilityCard.tsx | 64 +++++++++++++++---- src/Components/EligibilityCard/styles.ts | 27 ++++++-- .../CaseScreen/EligibilityForm/index.tsx | 39 +++++++---- .../CaseScreen/EligibilityForm/styles.ts | 15 +++-- .../Cases/CaseScreen/index.tsx | 13 ++-- src/supabase/queries/cases.ts | 27 +++++++- 6 files changed, 145 insertions(+), 40 deletions(-) diff --git a/src/Components/EligibilityCard/EligibilityCard.tsx b/src/Components/EligibilityCard/EligibilityCard.tsx index 7b2cc27b..dcb1589d 100644 --- a/src/Components/EligibilityCard/EligibilityCard.tsx +++ b/src/Components/EligibilityCard/EligibilityCard.tsx @@ -2,37 +2,79 @@ import React from 'react'; import { View, Text, Image } from 'react-native'; import { TouchableOpacity } from 'react-native-gesture-handler'; import styles from './styles'; -import { Eligibility } from '../../types/types'; +import { Case, Eligibility } from '../../types/types'; import { useRouter } from 'expo-router'; -export default function EligibilityCard() { - const eligible = Eligibility.ELIGIBLE; +interface EligibilityCardProps { + caseData: Case; + status: Eligibility; +} + +export default function EligibilityCard({ + caseData, + status, +}: EligibilityCardProps) { const router = useRouter(); - if (eligible === Eligibility.ELIGIBLE) { + if (status === Eligibility.ELIGIBLE) { return ( router.push('/Cases/CaseScreen/EligibilityForm')} + onPress={() => { + router.push({ + pathname: '/Cases/CaseScreen/EligibilityForm', + params: { caseId: caseData.id }, + }); + }} > - CHECK ELEGIBILITY + + v + + Check Eligibility + + {'->'} + + + + Check your eligibility for this class action if you would like to + file a claim or opt out. + - ); - } else if (eligible === Eligibility.INELIGIBLE) { + } else if (status === Eligibility.INELIGIBLE) { return ( - - OPT OUT + + {'->'} + + File a Claim + + {'->'} + + + Eligible class members who wish to receive payment can submit a + claim electronically. + - FILE CLAIM + + {'->'} + + Opt Out + + {'->'} + + + + Submit a claim by July 14, 2023 if you wish to receive a payment + from the settlement. + diff --git a/src/Components/EligibilityCard/styles.ts b/src/Components/EligibilityCard/styles.ts index 15dc3b04..68c07ca7 100644 --- a/src/Components/EligibilityCard/styles.ts +++ b/src/Components/EligibilityCard/styles.ts @@ -1,4 +1,5 @@ import { StyleSheet } from 'react-native'; +import { normalize } from 'yargs'; export default StyleSheet.create({ eligible: { @@ -14,20 +15,34 @@ export default StyleSheet.create({ alignContent: 'center', }, button: { + paddingHorizontal: 20, alignSelf: 'center', height: '90%', width: '90%', border: 'solid', - borderColor: 'rgba(0, 0, 0, 0.5)', - borderWidth: 1, + borderColor: '#767676', + borderWidth: 0.5, borderRadius: 5, + background: '#FFF', margin: 5, + flexDirection: 'column', + justifyContent: 'space-evenly', + }, + topText: { + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + }, + center: { + flex: 0.9, + }, + text: { + color: '#2C2C2C', + fontSize: 20, + fontStyle: 'normal', + fontWeight: '700', }, inner: { height: '50%', }, - arrow: { - height: '20%', - width: '20%', - }, }); diff --git a/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/index.tsx b/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/index.tsx index ad9c6b6f..e881c0fd 100644 --- a/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/index.tsx @@ -1,38 +1,51 @@ import React from 'react'; import { View, Text, Image } from 'react-native'; import { TouchableOpacity } from 'react-native-gesture-handler'; -import { useRouter } from 'expo-router'; +import { useLocalSearchParams, useRouter } from 'expo-router'; import styles from './styles'; +import { updateCaseStatus } from '../../../../../supabase/queries/cases'; +import { CaseUid, Eligibility } from '../../../../../types/types'; export default function EligibilityForm() { const router = useRouter(); + const { caseId } = useLocalSearchParams<{ + caseId: CaseUid; + }>(); return ( - - The eligibility requirements are as follows: - - - Sexy - Tall - Handsome - - - Do you meet the following requirements? + + + The eligibility requirements are as follows: + + + Sexy + Tall + Handsome + + + Do you meet the following requirements? + console.log('hi')} + onPress={() => { + // Not sure why this is happening + updateCaseStatus(caseId, Eligibility.ELIGIBLE); + }} > Yes, I am Eligible {'->'} - + router.back()} + > No, I'm not Eligible X diff --git a/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/styles.ts b/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/styles.ts index 91962505..f882dfc8 100644 --- a/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/styles.ts +++ b/src/app/(BottomTabNavigation)/Cases/CaseScreen/EligibilityForm/styles.ts @@ -6,11 +6,16 @@ export default StyleSheet.create({ alignItems: 'center', justifyContent: 'center', }, + insideContainer: { + justifyContent: 'space-evenly', + height: '70%', + width: '100%', + }, textContainer: { flex: 0.7, width: '100%', - justifyContent: 'space-evenly', - paddingHorizontal: 40, + justifyContent: 'flex-end', + paddingHorizontal: 50, paddingTop: 50, }, buttonsContainer: { @@ -30,18 +35,18 @@ export default StyleSheet.create({ button: { width: '100%', height: '70%', - borderRadius: 4, + borderRadius: 5, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: 20, }, buttonBottom: { - backgroundColor: 'black', + backgroundColor: '#2C2C2C', }, buttonTop: { borderColor: 'black', - borderWidth: 1, + borderWidth: 0.5, }, buttonBottomText: { color: '#fff', diff --git a/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx b/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx index 0dc808eb..4234b9d6 100644 --- a/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx @@ -1,5 +1,5 @@ import { router, useLocalSearchParams } from 'expo-router'; -import React from 'react'; +import React, { useState } from 'react'; import { View, Text, TouchableOpacity } from 'react-native'; import styles from './styles'; @@ -8,11 +8,11 @@ import CaseSummaryCard from '../../../../Components/CaseSummaryCard/CaseSummarCa import EducationalBar from '../../../../Components/EducationalBar/EducationalBar'; import EligibilityCard from '../../../../Components/EligibilityCard/EligibilityCard'; import FormsCard from '../../../../Components/FormsCard/FormsCard'; -import { Case } from '../../../../types/types'; +import { Case, Eligibility } from '../../../../types/types'; function CasesScreen() { const caseData = useLocalSearchParams() as unknown as Case; - + const [status, setStatus] = useState(Eligibility.INELIGIBLE); console.log(caseData); return ( @@ -22,9 +22,14 @@ function CasesScreen() { Go Back + {status === Eligibility.INELIGIBLE && ( + + )} - + {status === Eligibility.ELIGIBLE && ( + + )} diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index 82a93d1f..bbc431a8 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -1,4 +1,4 @@ -import { Case, CaseUid, UserUid } from '../../types/types'; +import { Case, CaseUid, Eligibility, UserUid } from '../../types/types'; import supabase from '../createClient'; /** @@ -122,6 +122,31 @@ export function parseCase(item: any): Case { }; return formattedCase; } +/** + * Update a specific User/Case status + * @param caseId specified caseId + * @param status status to be updated in the specific User/Case row + * @returns nothing + */ +export async function updateCaseStatus( + caseId: CaseUid, + status: Eligibility, +): Promise { + try { + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.id; + const { error } = await supabase + .from('status') + .update({ eligibility: status }) + .eq('userId', userId) + .eq('caseId', caseId); + console.log(error); + } catch (error) { + throw error; + } +} // export async function addCase() { // const dummyCase = { From 1b6955a0aa01893154dc05bac70150079fa33ec8 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:33:30 -0700 Subject: [PATCH 35/36] draft pr --- src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx b/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx index 4234b9d6..01462493 100644 --- a/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx @@ -12,7 +12,7 @@ import { Case, Eligibility } from '../../../../types/types'; function CasesScreen() { const caseData = useLocalSearchParams() as unknown as Case; - const [status, setStatus] = useState(Eligibility.INELIGIBLE); + const [status, setStatus] = useState(Eligibility.ELIGIBLE); console.log(caseData); return ( From 1482aa5f22c43da4793cb16d2c90c734dc0142a0 Mon Sep 17 00:00:00 2001 From: Philip Ye <97428041+philipye314@users.noreply.github.com> Date: Tue, 31 Oct 2023 22:21:22 -0700 Subject: [PATCH 36/36] [wip] + minor qrcodescanner fix --- .../EligibilityCard/EligibilityCard.tsx | 2 +- .../CaseScreen/EligibilityForm/index.tsx | 4 ++-- .../Cases/CaseScreen/index.tsx | 16 +++++++++++++--- src/supabase/queries/cases.ts | 19 ++++++++++++++++++- src/types/types.tsx | 6 +++--- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/Components/EligibilityCard/EligibilityCard.tsx b/src/Components/EligibilityCard/EligibilityCard.tsx index dcb1589d..856ad7d5 100644 --- a/src/Components/EligibilityCard/EligibilityCard.tsx +++ b/src/Components/EligibilityCard/EligibilityCard.tsx @@ -15,7 +15,7 @@ export default function EligibilityCard({ status, }: EligibilityCardProps) { const router = useRouter(); - if (status === Eligibility.ELIGIBLE) { + if (status === Eligibility.ELIGIBLE || status === Eligibility.UNDETERMINED) { return ( { // Not sure why this is happening - updateCaseStatus(caseId, Eligibility.ELIGIBLE); + updateCaseStatus(caseId, Eligibility.INELIGIBLE); }} > Yes, I am Eligible @@ -44,7 +44,7 @@ export default function EligibilityForm() { router.back()} + onPress={() => router.push('/Cases/CaseScreen/')} > No, I'm not Eligible X diff --git a/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx b/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx index 01462493..db87a5e6 100644 --- a/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx +++ b/src/app/(BottomTabNavigation)/Cases/CaseScreen/index.tsx @@ -1,5 +1,5 @@ import { router, useLocalSearchParams } from 'expo-router'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { View, Text, TouchableOpacity } from 'react-native'; import styles from './styles'; @@ -9,11 +9,20 @@ import EducationalBar from '../../../../Components/EducationalBar/EducationalBar import EligibilityCard from '../../../../Components/EligibilityCard/EligibilityCard'; import FormsCard from '../../../../Components/FormsCard/FormsCard'; import { Case, Eligibility } from '../../../../types/types'; +import { getCaseStatus } from '../../../../supabase/queries/cases'; function CasesScreen() { const caseData = useLocalSearchParams() as unknown as Case; const [status, setStatus] = useState(Eligibility.ELIGIBLE); - console.log(caseData); + + useEffect(() => { + const getStatus = async () => { + const caseStatus = await getCaseStatus(caseData.id); + setStatus(caseStatus); + console.log(caseStatus); + }; + getStatus(); + }, []); return ( @@ -27,7 +36,8 @@ function CasesScreen() { )} - {status === Eligibility.ELIGIBLE && ( + {(status === Eligibility.ELIGIBLE || + status === Eligibility.UNDETERMINED) && ( )} diff --git a/src/supabase/queries/cases.ts b/src/supabase/queries/cases.ts index bbc431a8..8e7d9c50 100644 --- a/src/supabase/queries/cases.ts +++ b/src/supabase/queries/cases.ts @@ -93,7 +93,7 @@ export async function containsDuplicateCase(caseId: CaseUid) { .select() .eq('userId', userId) .eq('caseId', caseId); - return data?.length === 0; + return data?.length !== 0; } catch (error) { throw error; } @@ -148,6 +148,23 @@ export async function updateCaseStatus( } } +export async function getCaseStatus(caseId: CaseUid) { + try { + const { + data: { user }, + } = await supabase.auth.getUser(); + const userId = user?.id; + const { data, error } = await supabase + .from('status') + .select() + .eq('userId', userId) + .eq('caseId', caseId); + return data[0].eligibility; //bruhhhh + } catch (error) { + throw error; + } +} + // export async function addCase() { // const dummyCase = { // approved: false, diff --git a/src/types/types.tsx b/src/types/types.tsx index 80c2e456..eb0d3ddb 100644 --- a/src/types/types.tsx +++ b/src/types/types.tsx @@ -33,7 +33,7 @@ export type Status = { }; export enum Eligibility { - ELIGIBLE, - INELIGIBLE, - UNDETERMINED, + ELIGIBLE = 'ELIGIBLE', + INELIGIBLE = 'INELIGIBLE', + UNDETERMINED = 'UNDETERMINED', }