Skip to content

Commit

Permalink
Merge pull request #662 from andrew-bierman/refactor/auth-new
Browse files Browse the repository at this point in the history
Refactor/auth new
  • Loading branch information
andrew-bierman authored Feb 10, 2024
2 parents 38e82b4 + fe82ec9 commit 17dc0d6
Show file tree
Hide file tree
Showing 93 changed files with 535 additions and 268 deletions.
5 changes: 3 additions & 2 deletions apps/expo/app/(app)/(drawer)/(tabs)/(stack)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { View, Text, SafeAreaView, TouchableOpacity } from 'react-native';
import useCustomStyles from 'app/hooks/useCustomStyles';
import { useIsMobileView } from 'app/hooks/common';
import { useNavigate } from 'app/hooks/navigation';
import { useAuthUser } from 'app/hooks/user/useAuthUser';
import { useAuthUser } from 'app/auth/hooks';
import { Button } from 'tamagui';
import { EvilIcons } from '@expo/vector-icons';
import SVGLogoComponent from 'app/components/logo';
import { AuthStateListener } from 'app/auth/AuthStateListener';
import useTheme from 'app/hooks/useTheme';
import { DrawerActions } from '@react-navigation/native';

export default function StackLayout() {
const user = useAuthUser();
Expand Down Expand Up @@ -41,7 +42,7 @@ export default function StackLayout() {
<TouchableOpacity
style={styles.drawerTrigger}
onPress={() => {
navigation.toggleDrawer();
navigation.dispatch(DrawerActions.toggleDrawer());
}}
>
<EvilIcons
Expand Down
3 changes: 2 additions & 1 deletion apps/expo/app/(app)/(drawer)/(tabs)/(stack)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { darkTheme, theme } from 'app/theme';
import LandingPage from 'app/components/landing_page';
import Dashboard from 'app/screens/dashboard';
import useTheme from 'app/hooks/useTheme';
import { useAuthUser } from 'app/auth/hooks';
import { current } from '@reduxjs/toolkit';
import Head from 'expo-router/head';
import Login from 'app/screens/LoginScreen';
Expand All @@ -19,7 +20,7 @@ export default function HomeScreen() {
currentTheme = theme,
} = useTheme();

const user = useSelector((state) => state.auth.user);
const user = useAuthUser();

const mutualStyles = {
backgroundColor: currentTheme.colors.background,
Expand Down
14 changes: 7 additions & 7 deletions apps/expo/app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useSession } from 'app/context/Auth/SessionProvider';
import { useProtectedRoute } from 'app/hooks/auth/useProtectedRoute';
import { Navigation } from 'app/components/navigation';
import { Slot } from 'expo-router'
import { Slot } from 'expo-router';
import { AuthWrapper } from 'app/auth/AuthWrapper';

export default function AppLayout() {
const { session } = useSession();
useProtectedRoute(session);
return <Slot />;
return (
<AuthWrapper>
<Slot />
</AuthWrapper>
);
}
4 changes: 0 additions & 4 deletions apps/expo/app/(auth)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Stack } from 'expo-router';
import { useSession } from 'app/context/Auth/SessionProvider';
import { useProtectedRoute } from 'app/hooks/auth/useProtectedRoute';

export default function AppLayout() {
const { session } = useSession();
useProtectedRoute(session);
return <Stack />;
}
25 changes: 0 additions & 25 deletions apps/next/auth/authWrapper.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/next/pages/appearance/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AppearanceContainer from 'app/screens/appearance/AppearanceContainer';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge';

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Dashboard from 'app/screens/dashboard';

import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge';

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/destination/[destinationId].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DestinationPage } from 'app/components/destination';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';
// import DestinationPage from "../../components/destination";

// export const runtime = 'experimental-edge';
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/feed/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feed from 'app/screens/feed/Feed';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge';

Expand Down
5 changes: 3 additions & 2 deletions apps/next/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Dashboard from './dashboard';
import { useSelector } from 'react-redux';
import LandingPage from 'app/components/landing_page';
import { useAuthUser } from 'app/auth/hooks';

// export const runtime = 'experimental-edge'

export default function Home() {
const user = useSelector((state: any) => state.auth.user);
const user = useAuthUser();

return <>{!user ? <LandingPage /> : <Dashboard />}</>;
}
4 changes: 2 additions & 2 deletions apps/next/pages/items/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Items from 'app/screens/items';

import { AuthWrapper } from 'app/auth/AuthWrapper';
// export const runtime = 'experimental-edge';

export default function ItemsPage() {
Expand All @@ -11,5 +11,5 @@ export default function ItemsPage() {
}

ItemsPage.getLayout = function getLayout(page: any) {
return <>{page}</>;
return <AuthWrapper>{page}</AuthWrapper>;
};
2 changes: 1 addition & 1 deletion apps/next/pages/pack/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { PackDetails } from 'app/components/pack/PackDetails';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/pack/create.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { AddPack } from 'app/components/pack/AddPack';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/packs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Feed from 'app/screens/feed/Feed';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/password-reset/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RequestPasswordReset } from 'app/components/password-reset';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/profile/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { StyleSheet, Text, View, Platform } from 'react-native';
import ProfileContainer from 'app/screens/user/ProfileContainer';
import { createParam } from 'solito';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

const { useParam } = createParam();

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/profile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ProfileContainer from 'app/screens/user/ProfileContainer';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/profile/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Settings from 'app/screens/user/Settings';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 0 additions & 2 deletions apps/next/pages/sign-in/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import LoginScreen from 'app/screens/LoginScreen';

// export const runtime = 'experimental-edge'

function Login() {
return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/trip/[tripId].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TripDetails } from 'app/screens/trip/TripDetails';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/trip/create.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CreateTrip from 'app/screens/trip/createTrip';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/trips/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feed from 'app/screens/feed/Feed';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
25 changes: 0 additions & 25 deletions apps/tauri/auth/authWrapper.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/tauri/pages/appearance/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AppearanceContainer from 'app/screens/appearance/AppearanceContainer';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge';

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Dashboard from 'app/screens/dashboard';

import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge';

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/destination/[destinationId].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DestinationPage } from 'app/components/destination';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';
// import DestinationPage from "../../components/destination";

// export const runtime = 'experimental-edge';
Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/feed/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feed from 'app/screens/feed/Feed';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge';

Expand Down
4 changes: 2 additions & 2 deletions apps/tauri/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Dashboard from './dashboard';
import { useSelector } from 'react-redux';
import LandingPage from 'app/components/landing_page';
import { useAuthUser } from 'app/auth/hooks';

// export const runtime = 'experimental-edge'

export default function Home() {
const user = useSelector((state: any) => state.auth.user);
const user = useAuthUser();
return <>{!user ? <LandingPage /> : <Dashboard />}</>;
}
2 changes: 1 addition & 1 deletion apps/tauri/pages/pack/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { PackDetails } from 'app/components/pack/PackDetails';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/pack/create.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { AddPack } from 'app/components/pack/AddPack';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/packs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Feed from 'app/screens/feed/Feed';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/password-reset/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RequestPasswordReset } from 'app/components/password-reset';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/profile/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
import { StyleSheet, Text, View, Platform } from 'react-native';
import ProfileContainer from 'app/screens/user/ProfileContainer';
import { createParam } from 'solito';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

const { useParam } = createParam();

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/profile/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ProfileContainer from 'app/screens/user/ProfileContainer';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/profile/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Settings from 'app/screens/user/Settings';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/trip/[tripId].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TripDetails } from 'app/screens/trip/TripDetails';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/trip/create.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CreateTrip from 'app/screens/trip/createTrip';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 1 addition & 1 deletion apps/tauri/pages/trips/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feed from 'app/screens/feed/Feed';
import { AuthWrapper } from 'auth/authWrapper';
import { AuthWrapper } from 'app/auth/AuthWrapper';

// export const runtime = 'experimental-edge'

Expand Down
2 changes: 2 additions & 0 deletions packages/app/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module.exports = {
},
extends: [
'standard-with-typescript',
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@tanstack/eslint-plugin-query/recommended',
'prettier',
Expand Down
Loading

0 comments on commit 17dc0d6

Please sign in to comment.