diff --git a/mobile/src/screens/EditProfileScreen.tsx b/mobile/src/screens/EditProfileScreen.tsx new file mode 100644 index 0000000..769511b --- /dev/null +++ b/mobile/src/screens/EditProfileScreen.tsx @@ -0,0 +1,131 @@ +import React from 'react'; +import { View, Text, TextInput, TouchableOpacity, ScrollView, ActivityIndicator, useColorScheme, KeyboardAvoidingView, Platform, Image } from 'react-native'; +import { Ionicons } from '@expo/vector-icons'; +import { useAuthStore } from '../store/useAuthStore'; +import { getThemeStyles, commonStyles } from '../theme/styles'; +import { COLORS } from '../theme/colors'; +import { useProfileManager } from '../hooks/useProfileManager'; + +export default function EditProfileScreen() { + const { user } = useAuthStore(); + + const colorScheme = useColorScheme(); + const isDark = colorScheme === 'dark'; + const themeStyles = getThemeStyles(isDark); + const themeColors = isDark ? COLORS.DARK : COLORS.LIGHT; + + const { + loading, + avatar, + firstName, + lastName, + phone, + address, + setFirstName, + setLastName, + setPhone, + setAddress, + pickImage, + handleSave, + } = useProfileManager(); + + return ( + + + + Edit Profile + + + + + + {avatar ? ( + + ) : ( + + {user?.user?.first_name?.charAt(0).toUpperCase() || user?.user?.email?.charAt(0).toUpperCase() || 'U'} + + )} + + + + + + + + + First Name + + + Last Name + + + Phone + + + Address + + + + {loading ? ( + + ) : ( + Save Changes + )} + + + + + ); +} diff --git a/mobile/src/store/useAuthStore.ts b/mobile/src/store/useAuthStore.ts index 6697a5a..afe99a2 100644 --- a/mobile/src/store/useAuthStore.ts +++ b/mobile/src/store/useAuthStore.ts @@ -7,7 +7,13 @@ interface User { user: { id: number; email: string; - // Add other user fields as needed + first_name?: string; + last_name?: string; + phone?: string; + address?: string; + username?: string; + email_verified_at?: string | null; + avatar?: string; }; } @@ -15,6 +21,7 @@ interface AuthState { user: User | null; isLoading: boolean; login: (userData: User) => void; + updateUser: (updates: Partial) => void; logout: () => void; setLoading: (loading: boolean) => void; } @@ -25,6 +32,12 @@ export const useAuthStore = create()( user: null, isLoading: true, login: (userData) => set({ user: userData }), + updateUser: (updates) => + set((state) => ({ + user: state.user + ? { ...state.user, user: { ...state.user.user, ...updates } } + : null, + })), logout: () => set({ user: null }), setLoading: (loading) => set({ isLoading: loading }), }),