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

[auth] Implement email account creation #10

Merged
merged 42 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4dfaba6
Add components from tutorials
adityapawar1 Sep 27, 2023
b970ec4
Add profile columns to update page
adityapawar1 Sep 29, 2023
77319ab
Update supabase data working
adityapawar1 Sep 29, 2023
53bd2c3
Only update non-blank entries
adityapawar1 Sep 29, 2023
2f29992
Run eslint fix
adityapawar1 Sep 29, 2023
3114e12
Fix eslint errors
adityapawar1 Sep 29, 2023
fd6cfff
Fix tsc errors
adityapawar1 Sep 29, 2023
83bbbbd
Fix trivial review changes
adityapawar1 Oct 3, 2023
536a2d9
Add components from tutorials
adityapawar1 Sep 27, 2023
74b77d4
Add profile columns to update page
adityapawar1 Sep 29, 2023
57aa90c
Update supabase data working
adityapawar1 Sep 29, 2023
6cbb24f
Only update non-blank entries
adityapawar1 Sep 29, 2023
3a9a2f8
Run eslint fix
adityapawar1 Sep 29, 2023
5b48100
Fix eslint errors
adityapawar1 Sep 29, 2023
ab2a06e
Fix tsc errors
adityapawar1 Sep 29, 2023
ea56070
Fix trivial review changes
adityapawar1 Oct 3, 2023
0e4eed8
Merge
adityapawar1 Oct 3, 2023
142e05f
Downgrade ts to be compatible with deps
adityapawar1 Oct 3, 2023
1e2f1d3
Add components from tutorials
adityapawar1 Sep 27, 2023
d87c56a
Add profile columns to update page
adityapawar1 Sep 29, 2023
b0464bc
Update supabase data working
adityapawar1 Sep 29, 2023
6fb0e10
Only update non-blank entries
adityapawar1 Sep 29, 2023
8f3ba0a
Run eslint fix
adityapawar1 Sep 29, 2023
8688585
Fix eslint errors
adityapawar1 Sep 29, 2023
a485a9d
Fix trivial review changes
adityapawar1 Oct 3, 2023
4b6d64a
Add components from tutorials
adityapawar1 Sep 27, 2023
81f8271
Add profile columns to update page
adityapawar1 Sep 29, 2023
0824996
Update supabase data working
adityapawar1 Sep 29, 2023
28c00d1
Only update non-blank entries
adityapawar1 Sep 29, 2023
2350fad
Run eslint fix
adityapawar1 Sep 29, 2023
db1c8b4
Fix eslint errors
adityapawar1 Sep 29, 2023
5989a25
Fix merge conflicts
adityapawar1 Oct 4, 2023
6bcfdb3
Fixes after merge :(
adityapawar1 Oct 4, 2023
5eb03ed
Fix eslint errors
adityapawar1 Oct 4, 2023
460091f
Fix routing for sign up/in
adityapawar1 Oct 4, 2023
4a3d744
Downgrade ts
adityapawar1 Oct 4, 2023
7f9f305
Fix andriod date taking up the screen
adityapawar1 Oct 4, 2023
e2d3cbe
Fix build
adityapawar1 Oct 4, 2023
d9cf4b5
Downgrade ts
adityapawar1 Oct 4, 2023
422c7fa
Fix android date issue
adityapawar1 Oct 7, 2023
16fbd23
Merge branch 'main' into adi/email-auth
adityapawar1 Oct 7, 2023
45e4a25
Fix package-lock.jsonO
adityapawar1 Oct 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env.example
adityapawar1 marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

876 changes: 322 additions & 554 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions package.json
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,30 @@
"prettier": "prettier --check ."
},
"dependencies": {
"@expo/vector-icons": "^13.0.0",
"@react-navigation/bottom-tabs": "^6.5.9",
"@react-navigation/material-bottom-tabs": "^6.2.17",
"@react-native-async-storage/async-storage": "^1.19.3",
"@react-native-community/datetimepicker": "^7.6.0",
"@react-native-async-storage/async-storage": "1.18.2",
"@react-navigation/native": "^6.1.8",
"@react-navigation/native-stack": "^6.9.14",
"@react-navigation/stack": "^6.3.18",
"@react-native-async-storage/async-storage": "^1.19.3",
"@supabase/supabase-js": "^2.36.0",
"axios": "^1.5.0",
"expo": "~49.0.11",
"expo-status-bar": "~1.6.0",
"react": "18.2.0",
"react-native": "0.72.4",
"react-native-root-siblings": "^4.1.1",
"react-native-root-toast": "^3.5.1",
"react-native-ionicons": "^4.6.5",
"react-native": "0.72.5",
"react-native-elements": "^3.4.3",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-vector-icons": "^10.0.0",
"react-native-elements": "^3.4.3",
"react-native-url-polyfill": "^2.0.0"
},
"devDependencies": {
Expand All @@ -45,7 +56,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"prettier": "^2.8.8",
"typescript": "^4.9.5"
"typescript": "^4.3.0"
},
"private": true
}
39 changes: 11 additions & 28 deletions src/components/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { StyleSheet, View, Alert, ScrollView } from 'react-native';
import { Button, Input } from 'react-native-elements';
import { Session } from '@supabase/supabase-js';
import DateTimePicker from '@react-native-community/datetimepicker';
import supabase from '../lib/supabase';
import UserStringInput from './UserStringInput';
import supabase from '../utils/supabase';

const styles = StyleSheet.create({
container: {
Expand All @@ -20,24 +21,6 @@ const styles = StyleSheet.create({
},
});

type UserDataInputProps = {
label: string;
value: string;
set: React.Dispatch<React.SetStateAction<string>>;
};

function UserStringInput({ label, value, set }: UserDataInputProps) {
return (
<View style={styles.verticallySpaced}>
<Input
label={label}
value={value || ''}
onChangeText={text => set(text)}
/>
</View>
);
}

export default function Account({ session }: { session: Session }) {
const [loading, setLoading] = useState(true);
const [firstName, setFirstName] = useState('');
Expand All @@ -46,6 +29,11 @@ export default function Account({ session }: { session: Session }) {
const [gender, setGender] = useState('');
const [raceEthnicity, setRaceEthnicity] = useState('');

useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
if (session) getProfile();
}, [session]);

adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
const getProfile = async () => {
try {
setLoading(true);
Expand Down Expand Up @@ -77,16 +65,12 @@ export default function Account({ session }: { session: Session }) {
}
};

useEffect(() => {
if (session) getProfile();
}, [session]);

const updateProfile = async () => {
try {
setLoading(true);
if (!session?.user) throw new Error('No user on the session!');

// Only update value that are not blank
// Only update values that are not blank
const updates = {
...(firstName && { first_name: firstName }),
...(lastName && { last_name: lastName }),
Expand Down Expand Up @@ -132,7 +116,6 @@ export default function Account({ session }: { session: Session }) {
<View style={[styles.verticallySpaced, styles.mt20]}>
<Input label="Email" value={session?.user?.email} disabled />
</View>

<UserStringInput
label="First Name"
value={firstName}
Expand All @@ -145,13 +128,14 @@ export default function Account({ session }: { session: Session }) {
value={raceEthnicity}
set={setRaceEthnicity}
/>

<DateTimePicker
testID="dateTimePicker"
value={birthday}
mode="date"
onChange={date => {
setBirthday(new Date(date.nativeEvent.timestamp));
if (date.nativeEvent.timestamp) {
setBirthday(new Date(date.nativeEvent.timestamp));
}
}}
/>
<View style={[styles.verticallySpaced, styles.mt20]}>
Expand All @@ -161,7 +145,6 @@ export default function Account({ session }: { session: Session }) {
disabled={loading}
/>
</View>

<View style={styles.verticallySpaced}>
<Button title="Sign Out" onPress={() => supabase.auth.signOut()} />
</View>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login.tsx
akshaynthakur marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { Alert, StyleSheet, View } from 'react-native';
import { Button, Input } from 'react-native-elements';
import supabase from '../lib/supabase';
import supabase from '../utils/supabase';

const styles = StyleSheet.create({
container: {
Expand Down
30 changes: 30 additions & 0 deletions src/components/UserStringInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { View, StyleSheet } from 'react-native';
import { Input } from 'react-native-elements';

const styles = StyleSheet.create({
verticallySpaced: {
paddingTop: 4,
paddingBottom: 4,
alignSelf: 'stretch',
},
});

type UserStringInputProps = {
label: string;
value: string;
set: React.Dispatch<React.SetStateAction<string>>;
adityapawar1 marked this conversation as resolved.
Show resolved Hide resolved
};

function UserStringInput({ label, value, set }: UserStringInputProps) {
return (
<View style={styles.verticallySpaced}>
<Input
label={label}
value={value || ''}
onChangeText={text => set(text)}
/>
</View>
);
}

export default UserStringInput;
4 changes: 2 additions & 2 deletions src/screens/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import 'react-native-url-polyfill/auto';
import { useState, useEffect } from 'react';
import { View } from 'react-native';
import { Session } from '@supabase/supabase-js';
import supabase from '../lib/supabase';
import supabase from '../utils/supabase';
import Login from '../components/Login';
import Account from '../components/Account';

export default function App() {
export default function LoginScreen() {
const [session, setSession] = useState<Session | null>(null);

useEffect(() => {
Expand Down
File renamed without changes.