-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip: intializing db * wip: fixing branch name * feat: intialized database * update to feature * fixed eslint errors * current supabase update * fixed client initialization * feat: intialize database is done * changed touchableopactiy imports --------- Co-authored-by: foloy <[email protected]> Co-authored-by: Stephanie Wong <[email protected]>
- Loading branch information
1 parent
5a796d2
commit 26bb1be
Showing
6 changed files
with
560 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { TouchableOpacity, View } from 'react-native'; | ||
import { Text } from 'react-native-elements'; | ||
import styles from '../src/app/styles'; | ||
import supabase from './supabase'; | ||
|
||
export default function DummyQueries() { | ||
let queryHolder; | ||
|
||
async function allCases() { | ||
const { data, error } = await supabase.from('Cases').select(); | ||
queryHolder = data; | ||
queryHolder = error; | ||
} | ||
async function approvedCases() { | ||
const { data, error } = await supabase | ||
.from('Cases') | ||
.select() | ||
.filter('approved', 'is', 'True'); | ||
queryHolder = data; | ||
queryHolder = error; | ||
} | ||
async function unapprovedCases() { | ||
const { data, error } = await supabase | ||
.from('Cases') | ||
.select() | ||
.filter('approved', 'is', 'False'); | ||
queryHolder = data; | ||
queryHolder = error; | ||
} | ||
async function addCase() { | ||
const dummyCase = { | ||
approved: false, | ||
title: 'Dummy Case', | ||
summary: 'Testing intializing db', | ||
image: 'no.jpg', | ||
case_status: 'In Progress', | ||
claim_link: 'berkeley.edu', | ||
case_site: 'berkeley.edu', | ||
opt_out_link: 'berkeley.edu', | ||
}; | ||
const { error } = await supabase.from('Cases').insert(dummyCase); | ||
queryHolder = error; | ||
} | ||
|
||
return ( | ||
<View> | ||
<TouchableOpacity style={styles.button} onPress={() => allCases()}> | ||
<Text>Get All Cases</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity style={styles.button} onPress={() => approvedCases()}> | ||
<Text>Get Approved Cases</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity style={styles.button} onPress={() => unapprovedCases()}> | ||
<Text>Get Unapproved Cases</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity style={styles.button} onPress={() => addCase()}> | ||
<Text>Add a Dummy Case</Text> | ||
</TouchableOpacity> | ||
<Text>{queryHolder ? '' : queryHolder}</Text> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createClient } from '@supabase/supabase-js'; | ||
import 'react-native-url-polyfill/auto'; | ||
|
||
if (!process.env.SUPABASE_URL || !process.env.SUPABASE_ANON_KEY) { | ||
throw new Error('Supabase environment variables are not defined.'); | ||
} | ||
const supabase = createClient( | ||
process.env.SUPABASE_URL, | ||
process.env.SUPABASE_ANON_KEY, | ||
); | ||
|
||
export default supabase; |
Oops, something went wrong.