Repository navigation
Theme update and code refactoring #33
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
Changes from all commits
417c796
c3f1a11
e4c9273
a6f2d07
f5fa778
815cb93
fa5287c
fd62005
6d7d848
cc9b00c
8f721f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ import { useRouter } from "expo-router"; | |
| import { useState } from "react"; | ||
| import { | ||
| View, | ||
| StyleSheet, | ||
| Image, | ||
| Text, | ||
| ScrollView, | ||
|
|
@@ -14,7 +13,6 @@ import { TextInput, Button } from "react-native-paper"; | |
| import fnStyles from "@/styles/signup.styles"; | ||
| import { useTheme } from "@react-navigation/native"; | ||
| import { useAuthContext } from "@/contexts"; | ||
| import Toast from "react-native-toast-message"; | ||
| import Colors from "@/constants/Colors"; | ||
|
|
||
| const SignUpScreen = () => { | ||
|
|
@@ -43,7 +41,6 @@ const SignUpScreen = () => { | |
| keyboardShouldPersistTaps="handled" | ||
| showsVerticalScrollIndicator={false} | ||
| > | ||
| <Toast /> | ||
| {/* Logo Section */} | ||
| <Image | ||
| source={require("@/assets/images/logo.png")} | ||
|
|
@@ -95,10 +92,8 @@ const SignUpScreen = () => { | |
| <Button | ||
| mode="contained" | ||
| onPress={() => signUp(name, email, password)} | ||
| style={styles.button} | ||
| labelStyle={styles.buttonText} | ||
| > | ||
| SIGN UP | ||
| Signup | ||
| </Button> | ||
|
Comment on lines
92
to
97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add loading state and error handling to improve UX The signup button lacks loading state and error handling, which could lead to a poor user experience if the signup process takes time or fails. Consider implementing these improvements: +const [isLoading, setIsLoading] = useState(false);
+const [error, setError] = useState<string | null>(null);
+const handleSignUp = async () => {
+ try {
+ setError(null);
+ setIsLoading(true);
+ await signUp(name, email, password);
+ } catch (err) {
+ setError(err.message);
+ } finally {
+ setIsLoading(false);
+ }
+};
<Button
mode="contained"
- onPress={() => signUp(name, email, password)}
+ onPress={handleSignUp}
+ loading={isLoading}
+ disabled={isLoading}
>
Signup
</Button>
+{error && <Text style={styles.errorText}>{error}</Text>}
🛠️ Refactor suggestion Add client-side validation before submission The signup function is called without validating the user input, which could lead to unnecessary server calls and poor user feedback. Consider adding basic validation: +const validateForm = () => {
+ if (!name.trim()) return "Name is required";
+ if (!email.trim()) return "Email is required";
+ if (!/\S+@\S+\.\S+/.test(email)) return "Invalid email format";
+ if (!password) return "Password is required";
+ if (password.length < 8) return "Password must be at least 8 characters";
+ if (password !== confirmPassword) return "Passwords do not match";
+ return null;
+};
+const handleSignUp = async () => {
+ const error = validateForm();
+ if (error) {
+ setError(error);
+ return;
+ }
+ try {
+ setError(null);
+ setIsLoading(true);
+ await signUp(name, email, password);
+ } catch (err) {
+ setError(err.message);
+ } finally {
+ setIsLoading(false);
+ }
+};
<Button
mode="contained"
- onPress={() => signUp(name, email, password)}
+ onPress={handleSignUp}
>
|
||
| </View> | ||
| {/* Login Prompt */} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,13 @@ | ||
| import BackButton from "@/components/ui/back-button/BackButton"; | ||
| import React from "react"; | ||
| import AppLayout from "@/layouts/app-layout"; | ||
| import { stylesFn } from "@/styles/CollaborationHistory.styles"; | ||
| import { useTheme } from "@react-navigation/native"; | ||
| import React, { useState } from "react"; | ||
| import { View, ScrollView, StyleSheet } from "react-native"; | ||
| import { | ||
| TextInput, | ||
| Button, | ||
| Title, | ||
| Paragraph, | ||
| IconButton, | ||
| RadioButton, | ||
| } from "react-native-paper"; | ||
| import ScreenHeader from "@/components/ui/screen-header"; | ||
|
|
||
|
Comment on lines
+1
to
4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Component name doesn't match the file name The file is named
|
||
| const CreateCollaborationScreen = () => { | ||
| const theme = useTheme(); | ||
| const styles = stylesFn(theme); | ||
| return ( | ||
| <AppLayout> | ||
| <ScrollView style={styles.container}> | ||
| <View | ||
| style={{ | ||
| flexDirection: "row", | ||
| alignItems: "center", | ||
| marginBottom: 16, | ||
| gap: 16, | ||
| }} | ||
| > | ||
| <BackButton /> | ||
| <Title style={styles.title}>Collaboration History</Title> | ||
| </View> | ||
| </ScrollView> | ||
| <ScreenHeader | ||
| title="Collaboration History" | ||
| /> | ||
| </AppLayout> | ||
| ); | ||
| }; | ||
|
Comment on lines
6
to
13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Component name inconsistent with its purpose The component is named
The component should be renamed to match its purpose:
🔗 Analysis chainVerify component purpose and functionality The component name
Let's check for related components and usage: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for related collaboration components and their usage
echo "Searching for collaboration-related components..."
rg -l "Collaboration" --type tsx
echo "\nChecking for references to this component..."
rg "CreateCollaborationScreen" --type tsx
Length of output: 342 Script: #!/bin/bash
# Search for related collaboration components and their usage with correct file extensions
echo "Searching for collaboration-related files..."
fd -e tsx -e ts "Collaboration"
echo "\nSearching for collaboration-related content..."
rg "Collaboration" -t ts -t tsx
echo "\nChecking component references..."
rg "CreateCollaborationScreen" -t ts -t tsx
Length of output: 919 Script: #!/bin/bash
# Let's check the content of the file to understand its actual purpose
echo "Checking the full content of CollaborationHistory.tsx..."
cat "app/(main)/(screens)/CollaborationHistory.tsx"
echo "\nChecking create collaboration related files..."
cat "components/collaboration/create-collaboration/CreateCollaborationMap.tsx"
cat "constants/CreateCollaborationForm.ts"
Length of output: 3392 |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,77 +1,33 @@ | ||
| import CollaborationPage from "@/components/collaboration/CollaborationDetails"; | ||
| import { useEffect, useState } from "react"; | ||
| import { doc, getDoc } from "firebase/firestore"; | ||
| import { useLocalSearchParams } from "expo-router"; | ||
| import { FirestoreDB } from "@/utils/firestore"; | ||
| import BottomSheetActions from "@/components/BottomSheetActions"; | ||
| import CollaborationDetails from "@/components/collaboration/collaboration-details"; | ||
| import ScreenHeader from "@/components/ui/screen-header"; | ||
| import AppLayout from "@/layouts/app-layout"; | ||
| import { ActivityIndicator, Chip } from "react-native-paper"; | ||
| import { ICollaboration } from "@/shared-libs/firestore/trendly-pro/models/collaborations"; | ||
| import { View } from "@/components/theme/Themed"; | ||
| import { ScrollView, StyleSheet } from "react-native"; | ||
|
|
||
| interface Collaboration extends ICollaboration { | ||
| brandName: string; | ||
| paymentVerified: boolean; | ||
| brandDescription: string; | ||
| } | ||
| import { useLocalSearchParams } from "expo-router"; | ||
| import { useState } from "react"; | ||
|
|
||
| const CollaborationDetailsScreen = () => { | ||
| const [isVisible, setIsVisible] = useState(false); | ||
| const pageID = useLocalSearchParams().pageID; | ||
| const [collaboration, setCollaboration] = useState<Collaboration | undefined>( | ||
| undefined | ||
| ); // Explicit type | ||
| const [loading, setLoading] = useState(true); | ||
| const [activeTab, setActiveTab] = useState("Overview"); | ||
| const fetchCollaboration = async () => { | ||
| if (!pageID) return; | ||
| try { | ||
| const collabRef = doc(FirestoreDB, "collaborations", pageID as string); | ||
| const snapshot = await getDoc(collabRef); | ||
| const data = snapshot.data() as ICollaboration; | ||
| if (!data) return; | ||
|
|
||
| const brandRef = doc(FirestoreDB, "brands", data.brandId); | ||
| const brandSnapshot = await getDoc(brandRef); | ||
| const brandData = brandSnapshot.data(); | ||
|
|
||
| setCollaboration({ | ||
| ...data, | ||
| brandName: brandData?.name || "Unknown Brand", | ||
| paymentVerified: brandData?.paymentMethodVerified || false, | ||
| brandDescription: brandData?.description || "", | ||
| }); | ||
| } catch (e) { | ||
| console.error(e); | ||
| } finally { | ||
| setLoading(false); | ||
| } | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| fetchCollaboration(); | ||
| }, [pageID]); | ||
|
|
||
| if (loading) | ||
| return ( | ||
| <AppLayout> | ||
| <ActivityIndicator /> | ||
| </AppLayout> | ||
| ); | ||
|
|
||
| if (!collaboration) return null; | ||
|
|
||
| return ( | ||
| <AppLayout> | ||
| {activeTab === "Overview" && ( | ||
| <CollaborationPage | ||
| collaborationDetail={collaboration} | ||
| pageID={pageID} | ||
| /> | ||
| )} | ||
| <ScreenHeader | ||
| title="Collaboration Details" | ||
| /> | ||
| <CollaborationDetails | ||
| pageID={pageID as string} | ||
| /> | ||
|
Comment on lines
+17
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the previous results and this search, I can now generate the final response: Error handling needs improvement in CollaborationDetails While the component implements loading states and basic try-catch blocks, it lacks proper error UI feedback:
🔗 Analysis chainVerify error handling in CollaborationDetails Since the loading and error states have been moved to the CollaborationDetails component, let's verify its implementation. Let me generate additional scripts to verify the error UI states and error boundaries: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check CollaborationDetails implementation for error handling
ast-grep --pattern 'function CollaborationDetails($_) {
$$$
}'
# Look for error handling patterns
rg -A 5 'try.*catch|error|loading' components/collaboration/collaboration-details
Length of output: 4795 Script: #!/bin/bash
# Check for error UI states and error boundaries
rg -A 3 'error.*state|error.*message|ErrorBoundary' components/collaboration/collaboration-details
# Check if there's any error UI component being rendered
ast-grep --pattern 'return (
<$_>
$$$
{error && $_}
$$$
</$_>
)'
Length of output: 183 |
||
| <BottomSheetActions | ||
| cardId={pageID as string} | ||
| cardType="influencerCard" | ||
| isVisible={isVisible} | ||
| snapPointsRange={["20%", "50%"]} | ||
| onClose={() => { | ||
| setIsVisible(false); | ||
| }} | ||
| /> | ||
| </AppLayout> | ||
| ); | ||
| }; | ||
|
|
||
| export default CollaborationDetailsScreen; | ||
|
|
||
| const styles = StyleSheet.create({}); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistent text casing found across auth screens
The casing is indeed inconsistent across the auth screens:
Locations that need attention:
🔗 Analysis chain
Verify text casing consistency across auth screens
The button text has been changed to "Signup". While this change is acceptable, we should ensure consistent casing across all auth-related buttons (login, signup, etc.) in the application.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 50
Script:
Length of output: 2380