feat: implement real user profile viewing and auth state

This commit is contained in:
Cauê Faleiros
2026-02-26 10:18:27 -03:00
parent a175315437
commit dda606ef9b
3 changed files with 54 additions and 26 deletions

View File

@@ -1,24 +1,33 @@
import React, { useState, useEffect } from 'react';
import { Camera, Save, Mail, User as UserIcon, Building, Shield, Loader2, CheckCircle2 } from 'lucide-react';
import { USERS } from '../constants';
import { getUserById } from '../services/dataService';
import { User } from '../types';
export const UserProfile: React.FC = () => {
// Simulating logged-in user state
const [user, setUser] = useState<User | null>(null);
const [isLoading, setIsLoading] = useState(false);
const [isSuccess, setIsSuccess] = useState(false);
// Form State
const [name, setName] = useState('');
const [bio, setBio] = useState('');
useEffect(() => {
// Simulate fetching user data
const currentUser = USERS[0];
setUser(currentUser);
setName(currentUser.name);
setBio(currentUser.bio || '');
const fetchUser = async () => {
const storedId = localStorage.getItem('ctms_user_id');
if (storedId) {
try {
const fetchedUser = await getUserById(storedId);
if (fetchedUser) {
setUser(fetchedUser);
setName(fetchedUser.name);
setBio(fetchedUser.bio || '');
}
} catch (err) {
console.error("Error fetching profile:", err);
}
}
};
fetchUser();
}, []);
const handleSubmit = (e: React.FormEvent) => {