import React, { useState } from "react"; import { View, ScrollView, Pressable, TextInput, ActivityIndicator, useColorScheme, } from "react-native"; import { useSirouRouter } from "@sirou/react-native"; import { AppRoutes } from "@/lib/routes"; import { Text } from "@/components/ui/text"; import { Button } from "@/components/ui/button"; import { ScreenWrapper } from "@/components/ScreenWrapper"; import { ArrowLeft, User, Mail, Check } from "@/lib/icons"; import { useAuthStore } from "@/lib/auth-store"; import { api } from "@/lib/api"; import { toast } from "@/lib/toast-store"; export default function EditProfileScreen() { const nav = useSirouRouter(); const { user, updateUser } = useAuthStore(); const isDark = useColorScheme() === "dark"; const iconColor = isDark ? "#94a3b8" : "#64748b"; const [loading, setLoading] = useState(false); const [firstName, setFirstName] = useState(user?.firstName || ""); const [lastName, setLastName] = useState(user?.lastName || ""); const handleSave = async () => { if (!firstName.trim() || !lastName.trim()) { toast.error("Error", "First and last name are required"); return; } setLoading(true); try { const response = await api.users.updateProfile({ body: { firstName: firstName.trim(), lastName: lastName.trim(), }, }); updateUser(response); toast.success("Success", "Profile updated"); nav.back(); } catch (e: any) { toast.error("Error", e?.message || "Failed to update profile"); } finally { setLoading(false); } }; return ( nav.back()} className="h-10 w-10 rounded-[10px] bg-card items-center justify-center border border-border" > Edit Profile First Name {firstName.trim().length > 0 && ( )} Last Name {lastName.trim().length > 0 && ( )} {user?.email && ( Email {user.email} )} nav.back()} className="h-12 rounded-[8px] border border-border items-center justify-center" disabled={loading} > Cancel ); }