Repository navigation
No brands protected screen implementation #64
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import React from 'react'; | ||
| import { StyleSheet } from 'react-native'; | ||
| import { useTheme } from '@react-navigation/native'; | ||
| import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'; | ||
| import { faBell, faChevronDown } from '@fortawesome/free-solid-svg-icons'; | ||
|
|
||
| import AppLayout from '@/layouts/app-layout'; | ||
| import Colors from '@/constants/Colors'; | ||
| import Shimmer from '@/shared-uis/components/shimmer'; | ||
| import { View } from '../theme/Themed'; | ||
|
|
||
| const ExploreInfluencerShimmer = () => { | ||
| const theme = useTheme(); | ||
|
|
||
| return ( | ||
| <AppLayout> | ||
| <View style={styles.container}> | ||
| <View style={styles.header}> | ||
| <View style={styles.headerLeft}> | ||
| <Shimmer width={80} height={36} /> | ||
| <FontAwesomeIcon | ||
| icon={faChevronDown} | ||
| size={20} | ||
| color={Colors(theme).text} | ||
| /> | ||
| </View> | ||
| <FontAwesomeIcon | ||
| icon={faBell} | ||
| size={22} | ||
| color={Colors(theme).text} | ||
| /> | ||
| </View> | ||
|
|
||
| <View style={styles.searchContainer}> | ||
| <Shimmer width="100%" height={40} /> | ||
| </View> | ||
|
|
||
| <View style={styles.profileSection}> | ||
| <Shimmer width={50} height={50} /> | ||
| <View style={styles.profileInfo}> | ||
| <Shimmer width={150} height={20} /> | ||
| <Shimmer width={100} height={16} /> | ||
| </View> | ||
| </View> | ||
|
|
||
| <Shimmer width="100%" height={300} /> | ||
|
|
||
| <View style={styles.metrics}> | ||
| <Shimmer width={50} height={24} /> | ||
| <Shimmer width={50} height={24} /> | ||
| </View> | ||
|
|
||
| <Shimmer width="100%" height={40} /> | ||
|
|
||
| <View style={styles.bottomNav}> | ||
| {[...Array(5)].map((_, index) => ( | ||
| <Shimmer | ||
| key={index} | ||
| width={56} | ||
| height={48} | ||
| /> | ||
| ))} | ||
| </View> | ||
| </View> | ||
| </AppLayout> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| paddingHorizontal: 16, | ||
| }, | ||
| header: { | ||
| flexDirection: 'row', | ||
| justifyContent: 'space-between', | ||
| alignItems: 'center', | ||
| marginBottom: 16, | ||
| }, | ||
| headerLeft: { | ||
| flexDirection: 'row', | ||
| alignItems: 'center', | ||
| gap: 12, | ||
| }, | ||
| searchContainer: { | ||
| marginBottom: 16, | ||
| }, | ||
| profileSection: { | ||
| flexDirection: 'row', | ||
| alignItems: 'center', | ||
| gap: 12, | ||
| marginBottom: 16, | ||
| }, | ||
| profileInfo: { | ||
| gap: 4, | ||
| }, | ||
| metrics: { | ||
| flexDirection: 'row', | ||
| gap: 16, | ||
| marginVertical: 16, | ||
| }, | ||
| bottomNav: { | ||
| flexDirection: 'row', | ||
| justifyContent: 'center', | ||
| gap: 16, | ||
| marginTop: 'auto', | ||
| }, | ||
| }); | ||
|
|
||
| export default ExploreInfluencerShimmer; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import React, { PropsWithChildren, useEffect, useState } from "react"; | ||
| import { ActivityIndicator, Platform } from "react-native"; | ||
| import { useTheme } from "@react-navigation/native"; | ||
| import { useRouter } from "expo-router"; | ||
| import { collection, getDocs, query, where } from "firebase/firestore"; | ||
|
|
||
| import { View } from "@/components/theme/Themed"; | ||
| import { useAuthContext } from "@/contexts"; | ||
| import Colors from "@/constants/Colors"; | ||
| import ExploreInfluencerShimmer from "@/components/shimmers/explore-influencer-shimmer"; | ||
| import { FirestoreDB } from "@/utils/firestore"; | ||
|
|
||
| interface BrandProtectedScreenProps extends PropsWithChildren { } | ||
|
|
||
| const BrandProtectedScreen: React.FC<BrandProtectedScreenProps> = ({ | ||
| children, | ||
| }) => { | ||
| const [hasBrandWithManagerId, setHasBrandWithManagerId] = useState(false); | ||
| const router = useRouter(); | ||
|
|
||
| const { | ||
| manager, | ||
| } = useAuthContext(); | ||
|
|
||
| const fetchBrands = async ( | ||
| managerId: string | ||
| ): Promise<void> => { | ||
| const brandsCollection = collection(FirestoreDB, "brands"); | ||
|
|
||
| const brandsSnapshot = await getDocs(brandsCollection); | ||
|
|
||
| for (const brandDoc of brandsSnapshot.docs) { | ||
| const brandId = brandDoc.id; | ||
|
|
||
| const membersCollection = collection(FirestoreDB, `brands/${brandId}/members`); | ||
| const membersQuery = query(membersCollection, where("managerId", "==", managerId)); | ||
| const membersSnapshot = await getDocs(membersQuery); | ||
|
|
||
| if (!membersSnapshot.empty) { | ||
| setHasBrandWithManagerId(true); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| // If the manager has no brands, redirect to onboarding | ||
| router.replace({ | ||
| pathname: "/onboarding-your-brand", | ||
| params: { | ||
| firstBrand: "true", | ||
| }, | ||
| }); | ||
| }; | ||
|
dev-rathore marked this conversation as resolved.
Resolved
|
||
|
|
||
| useEffect(() => { | ||
| if (!manager?.id) return; | ||
|
|
||
| fetchBrands(manager.id); | ||
| }, [manager]); | ||
|
|
||
| if (!hasBrandWithManagerId) { | ||
| return <LoadingScreen />; | ||
| } | ||
|
|
||
| return <>{children}</>; | ||
| }; | ||
|
|
||
| const LoadingScreen: React.FC = () => { | ||
| const theme = useTheme(); | ||
|
|
||
| if (Platform.OS === "web") { | ||
| return ( | ||
| <View | ||
| style={{ | ||
| flex: 1, | ||
| justifyContent: "center", | ||
| alignItems: "center", | ||
| }} | ||
| > | ||
| <ActivityIndicator | ||
| size="large" | ||
| color={Colors(theme).primary} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <ExploreInfluencerShimmer /> | ||
| ); | ||
| } | ||
|
|
||
| export default BrandProtectedScreen; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import BrandProtectedScreen from "./brand-protected-screen"; | ||
|
|
||
| export { BrandProtectedScreen }; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.