Skip to content

Commit

Permalink
Fix trivial review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapawar1 committed Oct 3, 2023
1 parent fd6cfff commit 83bbbbd
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 458 deletions.
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

597 changes: 176 additions & 421 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
"prettier": "prettier --check ."
},
"dependencies": {
"@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-native-community/datetimepicker": "7.2.0",
"@react-navigation/native": "^6.1.8",
"@react-navigation/native-stack": "^6.9.14",
"@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": "0.72.5",
"react-native-elements": "^3.4.3",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
Expand All @@ -43,7 +43,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"prettier": "^2.8.8",
"typescript": "^4.9.5"
"typescript": "^5.1.3"
},
"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]);

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
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>>;
};

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.

0 comments on commit 83bbbbd

Please sign in to comment.