🚀 Hotfixes: inline PDF preview and instant profile update in UI
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import apiClient from '../../api/client';
|
||||
import { useAuthStore } from '../../store/authStore';
|
||||
|
||||
export const SettingsPage = () => {
|
||||
const [activeTab, setActiveTab] = useState('profile');
|
||||
@@ -37,6 +38,8 @@ export const SettingsPage = () => {
|
||||
language: 'العربية'
|
||||
});
|
||||
|
||||
const updateUser = useAuthStore((state) => state.updateUser);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchProfile = async () => {
|
||||
try {
|
||||
@@ -62,6 +65,7 @@ export const SettingsPage = () => {
|
||||
setIsSaving(true);
|
||||
try {
|
||||
await apiClient.post('/users/profile', formData);
|
||||
updateUser({ name: formData.name });
|
||||
setShowSuccess(true);
|
||||
setTimeout(() => setShowSuccess(false), 3000);
|
||||
} catch (err) {
|
||||
|
||||
@@ -20,6 +20,7 @@ interface AuthState {
|
||||
isAuthenticated: boolean;
|
||||
setAuth: (user: User, token: string) => void;
|
||||
clearAuth: () => void;
|
||||
updateUser: (data: Partial<User>) => void;
|
||||
}
|
||||
|
||||
export const useAuthStore = create<AuthState>()(
|
||||
@@ -35,6 +36,11 @@ export const useAuthStore = create<AuthState>()(
|
||||
localStorage.removeItem('access_token');
|
||||
set({ user: null, isAuthenticated: false });
|
||||
},
|
||||
updateUser: (data) => {
|
||||
set((state) => ({
|
||||
user: state.user ? { ...state.user, ...data } : null
|
||||
}));
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: 'musadaq-auth-storage',
|
||||
|
||||
Reference in New Issue
Block a user