Skip to content

Commit

Permalink
Merge pull request #3113 from KBVE/dev
Browse files Browse the repository at this point in the history
Preparing Alpha Branch
  • Loading branch information
h0lybyte authored Oct 24, 2024
2 parents f08fb5a + 04edddf commit b93954f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 11 deletions.
64 changes: 55 additions & 9 deletions apps/expo-lcagents/src/app/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, {
useMemo,
useCallback,
} from 'react';
import { YStack, SizableText, ScrollView, View } from 'tamagui';
import { YStack, SizableText, ScrollView, View, Button } from 'tamagui';
import { TamaLogin, LottieAnimation, TamaSheet, useBBQ, TamaSkeleton } from '@kbve/expo-bbq';
import { useNavigation } from 'expo-router';

Expand All @@ -17,6 +17,8 @@ const Login = () => {
hideSheet: () => void;
} | null>(null);
const [sheetMessage, setSheetMessage] = useState('');
const [isLoggedIn, setIsLoggedIn] = useState(false); // Track login state
const [hasError, setHasError] = useState(false); // Track error state

const lottieLoginAnimation = useMemo(
() => require('../../assets/json/vr.json'),
Expand All @@ -36,26 +38,70 @@ const Login = () => {
}, [updateNavigationOptions]);

const handleSuccess = () => {
setIsLoggedIn(true);
setHasError(false);
if (sheetRef.current) {
setSheetMessage('Login successful! Redirecting...');
setSheetMessage('Login successful! ...');
sheetRef.current.showSheet();
}

setTimeout(() => {
sheetRef.current?.hideSheet();
router.go('/profile');
}, 3000);
};

const MemoizedLottieAnimation = React.memo(LottieAnimation);

const handleError = (error: string) => {
setIsLoggedIn(false);
setHasError(true);
if (sheetRef.current) {
setSheetMessage(error);
setSheetMessage(error);
sheetRef.current.showSheet();
}
};

const renderSheetContent = () => {
return (
<YStack ai="center" jc="center" paddingVertical={10}>
<SizableText>{sheetMessage}</SizableText>
{isLoggedIn && !hasError && (
<YStack
f={1}
jc="center"
ai="center"
padding="$1"
gap>
<Button
onPress={() => {
if (sheetRef.current) {
sheetRef.current.hideSheet();
}
router.go('/profile');
}}
color="green"
size="$4"
marginTop={10}
>
Go to Profile
</Button>

<Button
onPress={() => {
if (sheetRef.current) {
sheetRef.current.hideSheet();
}
router.go('/dashboard');
}}
color="green"
size="$4"
marginTop={10}
>
Go to Dashboard
</Button>

</YStack>
)}
</YStack>
);
};

return (
<ScrollView
contentContainerStyle={{
Expand Down Expand Up @@ -94,7 +140,7 @@ const Login = () => {
/>

<TamaSheet ref={sheetRef} title="Login Status">
<SizableText>{sheetMessage}</SizableText>
{renderSheetContent()}
</TamaSheet>
</ScrollView>
);
Expand Down
5 changes: 4 additions & 1 deletion apps/kbve.com/src/content/journal/10-24.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ So we will wrap back around to the router and maybe setup a loading screen type
This means we can wrap backaround and replace the `useRouter` from the expo-router with our custom router, `useBBQ`.
Next we can customize the BBQ router, at least in the future, to have a skeleton / loading screen to help make the transitions from one scene to another very smooth.

Damn it seems that the issue still has not been resolved, maybe we could go back to the board and start removing the redirects that we have on all the applications.
Manually moving from one scene to another would be the only way we can move forward at this point because I still do not understand why we having issues with the redirect.

**BBQ**

Updated the BBQ component with the base skeleton and added a couple other mount checks.
Expand All @@ -53,4 +56,4 @@ This should work but I am still on the fenece.
**MediaHook**

I am still having some weird issues with the media query but I will have to reference back to the notes and get a better understanding of them.
There are a couple more things that I want to focus on but we can get there through test casing.
There are a couple more things that I want to focus on but we can get there through test casing.
2 changes: 1 addition & 1 deletion packages/expo-bbq/src/components/auth/TamaProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function TamaProfile({
const { data: session } = await supabase.auth.getSession();

if (!session || !session.session) {
router.replace('/login'); // If not logged in, redirect to login
//router.replace('/login'); // If not logged in, redirect to login
return;
}

Expand Down

0 comments on commit b93954f

Please sign in to comment.