Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folasade/imp 5 supabase client #6

Merged
merged 9 commits into from
Oct 11, 2023
Merged

Conversation

foloye
Copy link
Contributor

@foloye foloye commented Oct 8, 2023

What's new in this PR

Description

In this PR, I have initialized the supabase, and created some dummy queries to test if the client is working properly.

Screenshots

Screenshot 2023-10-08 at 12 58 23 AM

How to review

To test queries, a user must go to impact fund supabase -> click authentication tab -> disable rls for cases table -> add console.logs displaying data in impact-fund/lib/DummyQueries.tsx -> run app -> click Get Case Data button

(sorry that it's kinda hard to test, didn't want to push console logs!)

First a user should add console.logs to the DummyQueries file, then change function within onPress to test out various queries. This should just be reviewed all at once. Edge cases should mainly be tested out when retool app is up and functioning.

Next steps

This PR is mainly to test out some queries on the database, however the real testing will come when it is connected to retool and user auth is set up.

Relevant Links

Online sources

Related PRs

CC: @stephaniewong2

@linear
Copy link

linear bot commented Oct 8, 2023

IMP-5 Supabase Client

Description

Set up supabase client and write queries to create, fetch. update, delete cases.

  • Add Case to Supabase using the table editor

  • Intialize Supabase Client using react-native-dotenv

  • Make this its own PR! Thank you!

  • Write queries to fetch and create cases

  • Dummy data in Supabase to test queries

Useful Links

https://supabase.com/docs/guides/getting-started/tutorials/with-expo-react-native?database-method=dashboard&auth-store=async-storage

https://supabase.com/docs/reference/javascript/typescript-support

Related PRs

@foloye foloye requested a review from stephaniewong2 October 8, 2023 08:03
@foloye foloye self-assigned this Oct 8, 2023
lib/supabase.ts Outdated

const supabaseUrl = 'https://kvfpmjezholwvgdmabhr.supabase.co';
const supabaseAnonKey =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imt2ZnBtamV6aG9sd3ZnZG1hYmhyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTUwNzAzMDIsImV4cCI6MjAxMDY0NjMwMn0.e6CFmLq4kjNnoGzHDd_hVSUZI6gHaDU-dWu_1Uhd6Mk';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to expose the keys. Using the react-native-dotenv package allows us to do this

lib/supabase.ts Show resolved Hide resolved
import styles from './styles';

function StartScreen() {
const [session, setSession] = useState<Session | null>(null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint is complaining about eslint[@typescript-eslint/no-shadow](https://typescript-eslint.io/rules/no-shadow) and we can resolve this by renaming the state variable session.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also eslint will complain if we do not use this variable so for now, we can either remove it or get the session user in order to use the variable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it because we will use it shortly!

lib/DummyQueries.tsx Show resolved Hide resolved
return (
<View style={styles.container}>
<Link href="/Welcome" asChild>
<TouchableOpacity style={styles.button}>
<Text>Welcome Screen</Text>
</TouchableOpacity>
</Link>
<Link href="/SignUp" asChild>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove SignUp link. This is in the auth flow from the Welcome page!

supabase.auth.onAuthStateChange((_event, session) => {
setSession(session);
});
}, []);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a clean-up function on return (unsubscribe from the session) using something like authListener.subscription.unsubscribe();

import styles from './styles';

function StartScreen() {
const [session, setSession] = useState<Session | null>(null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it because we will use it shortly!


return (
<View>
<Button title="Get Case Data" onPress={() => allCases()} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor but let's use TouchableOpacity instead of Button and make texts specific to queries! Can you also add a little bit of styling or copy over from the other buttons above? Besides that, everything looks good!

@@ -0,0 +1,63 @@
import { View } from 'react-native';
import { Text } from 'react-native-elements';
import { TouchableOpacity } from 'react-native-gesture-handler';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use TouchableOpacity from react-native instead!

@foloye foloye merged commit 26bb1be into main Oct 11, 2023
2 checks passed
stephaniewong2 added a commit that referenced this pull request Oct 11, 2023
@stephaniewong2 stephaniewong2 deleted the folasade/imp-5-supabase-client branch November 12, 2023 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants