Revert then refix because shit got broken

This commit is contained in:
Gabriel Brown 2024-10-18 13:13:43 -05:00
parent cc8e0c623c
commit 770d04540c
6 changed files with 11 additions and 27 deletions

View File

@ -1,6 +1,6 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { StyleSheet } from 'react-native'; import { StyleSheet } from 'react-native';
import { ThemedText, ThemedView } from '@/components/theme/Theme'; import { ThemedView } from '@/components/theme/Theme';
import UserInfo from '@/components/home/UserInfo'; import UserInfo from '@/components/home/UserInfo';
import RelationshipView from '@/components/home/RelationshipView'; import RelationshipView from '@/components/home/RelationshipView';
@ -17,7 +17,6 @@ const IndexScreen = () => {
</ThemedView> </ThemedView>
</ThemedView> </ThemedView>
); );
}; };
export default IndexScreen; export default IndexScreen;

View File

@ -7,14 +7,9 @@ import {
const RootLayout = () => { const RootLayout = () => {
const [isSignedIn, setIsSignedIn] = useState(false); const [isSignedIn, setIsSignedIn] = useState(false);
console.log('RootLayout rendering, isSignedIn:', isSignedIn); if (!isSignedIn)
if (!isSignedIn) { return <SignInScreen onSignIn={() => setIsSignedIn(true)} />
console.log('Rendering SignInScreen');
return (
<SignInScreen onSignIn={() => setIsSignedIn(true)} />
);
}
console.log('PushNotificationManager & Stack');
return ( return (
<PushNotificationManager> <PushNotificationManager>
<Stack> <Stack>

View File

@ -37,7 +37,7 @@ const SignInScreen = ({onSignIn}: {onSignIn: () => void}) => {
const initialDataResponse = await getInitialDataByAppleId(credential.user); const initialDataResponse = await getInitialDataByAppleId(credential.user);
console.log("InitialData response: ", initialDataResponse); console.log(initialDataResponse);
if (initialDataResponse.status === 404 || !initialDataResponse.ok) { if (initialDataResponse.status === 404 || !initialDataResponse.ok) {
if (!credential.user || !credential.email || if (!credential.user || !credential.email ||
!credential.fullName?.givenName || !credential.fullName?.familyName || !credential.fullName?.givenName || !credential.fullName?.familyName ||

View File

@ -137,7 +137,6 @@ export const saveInitialData = async (initialData: InitialData) => {
await SecureStore.setItemAsync( await SecureStore.setItemAsync(
'partner', JSON.stringify(initialData.relationshipData.partner) 'partner', JSON.stringify(initialData.relationshipData.partner)
); );
if (initialData.countdown)
await SecureStore.setItemAsync('countdown', JSON.stringify(initialData.countdown)); await SecureStore.setItemAsync('countdown', JSON.stringify(initialData.countdown));
} }
} catch (error) { } catch (error) {

View File

@ -4,7 +4,6 @@ import * as Device from 'expo-device';
import * as Notifications from 'expo-notifications'; import * as Notifications from 'expo-notifications';
import Constants from 'expo-constants'; import Constants from 'expo-constants';
import type { NotificationMessage } from '@/constants/Types'; import type { NotificationMessage } from '@/constants/Types';
import { ThemedText } from '@/components/theme/Theme';
Notifications.setNotificationHandler({ Notifications.setNotificationHandler({
handleNotification: async () => ({ handleNotification: async () => ({
@ -115,12 +114,7 @@ export const PushNotificationManager = ({children}: {children: React.ReactNode})
Notifications.removeNotificationSubscription(responseListener.current); Notifications.removeNotificationSubscription(responseListener.current);
}; };
}, []); }, []);
//return ( <> {children} </> ); return ( <ErrorBoundary>{children}</ErrorBoundary> );
return (
<ErrorBoundary>
{children}
</ErrorBoundary>
);
}; };
class ErrorBoundary extends React.Component<{children: React.ReactNode}, {hasError: boolean}> { class ErrorBoundary extends React.Component<{children: React.ReactNode}, {hasError: boolean}> {

View File

@ -11,17 +11,15 @@ export const getInitialDataByAppleId = async (appleId: string) => {
'x-api-key': process.env.EXPO_PUBLIC_API_KEY ?? '', 'x-api-key': process.env.EXPO_PUBLIC_API_KEY ?? '',
}, },
}); });
console.log("InitialData API response: ", response);
return response; return response;
} catch (error: unknown) { } catch (error: unknown) {
console.error('Error getting Initial Data by Apple ID:', error); console.error('Error getting user by Apple ID:', error);
throw error; throw error;
} }
}; };
export const createUser = async ( export const createUser =
appleId: string, email: string, fullName: string, pushToken: string async (appleId: string, email: string, fullName: string, pushToken: string) => {
) => {
try { try {
const apiUrl = `${process.env.EXPO_PUBLIC_API_URL}/api/users/createUser`; const apiUrl = `${process.env.EXPO_PUBLIC_API_URL}/api/users/createUser`;
const response = await fetch(apiUrl, { const response = await fetch(apiUrl, {
@ -102,8 +100,7 @@ export const updateProfilePicture = async (userId: number, pfpUrl: string) => {
export const checkRelationshipStatus = async (userId: number) => { export const checkRelationshipStatus = async (userId: number) => {
try { try {
const apiUrl = const apiUrl = `${process.env.EXPO_PUBLIC_API_URL}/api/users/checkRelationship`;
`${process.env.EXPO_PUBLIC_API_URL}/api/relationships/checkRelationship`;
const response = await fetch((apiUrl + `?userId=${userId}`), { const response = await fetch((apiUrl + `?userId=${userId}`), {
headers: { headers: {
'x-api-key': process.env.EXPO_PUBLIC_API_KEY ?? '', 'x-api-key': process.env.EXPO_PUBLIC_API_KEY ?? '',