Improve the frontend 3

This commit is contained in:
Urtzi Alfaro
2025-10-30 21:08:07 +01:00
parent 36217a2729
commit 63f5c6d512
184 changed files with 21512 additions and 7442 deletions

View File

@@ -22,7 +22,7 @@ import {
import { Button, Card, Avatar, Input, Select } from '../../../../components/ui';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../../../../components/ui/Tabs';
import { PageHeader } from '../../../../components/layout';
import { useToast } from '../../../../hooks/ui/useToast';
import { showToast } from '../../../../utils/toast';
import { useAuthUser, useAuthActions } from '../../../../stores/auth.store';
import { useAuthProfile, useUpdateProfile, useChangePassword } from '../../../../api/hooks/auth';
import { useCurrentTenant } from '../../../../stores';
@@ -49,7 +49,7 @@ interface PasswordData {
const NewProfileSettingsPage: React.FC = () => {
const { t } = useTranslation('settings');
const navigate = useNavigate();
const { addToast } = useToast();
const user = useAuthUser();
const { logout } = useAuthActions();
const currentTenant = useCurrentTenant();
@@ -169,9 +169,9 @@ const NewProfileSettingsPage: React.FC = () => {
await updateProfileMutation.mutateAsync(profileData);
setIsEditing(false);
addToast(t('profile.save_changes'), { type: 'success' });
showToast.success(t('profile.save_changes'));
} catch (error) {
addToast(t('common.error'), { type: 'error' });
showToast.error(t('common.error'));
} finally {
setIsLoading(false);
}
@@ -191,9 +191,9 @@ const NewProfileSettingsPage: React.FC = () => {
setShowPasswordForm(false);
setPasswordData({ currentPassword: '', newPassword: '', confirmPassword: '' });
addToast(t('profile.password.change_success'), { type: 'success' });
showToast.success(t('profile.password.change_success'));
} catch (error) {
addToast(t('profile.password.change_error'), { type: 'error' });
showToast.error(t('profile.password.change_error'));
} finally {
setIsLoading(false);
}
@@ -246,9 +246,9 @@ const NewProfileSettingsPage: React.FC = () => {
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
addToast(t('profile.privacy.export_success'), { type: 'success' });
showToast.success(t('profile.privacy.export_success'));
} catch (err) {
addToast(t('profile.privacy.export_error'), { type: 'error' });
showToast.error(t('profile.privacy.export_error'));
} finally {
setIsExporting(false);
}
@@ -256,12 +256,12 @@ const NewProfileSettingsPage: React.FC = () => {
const handleAccountDeletion = async () => {
if (deleteConfirmEmail.toLowerCase() !== user?.email?.toLowerCase()) {
addToast(t('common.error'), { type: 'error' });
showToast.error(t('common.error'));
return;
}
if (!deletePassword) {
addToast(t('common.error'), { type: 'error' });
showToast.error(t('common.error'));
return;
}
@@ -270,14 +270,14 @@ const NewProfileSettingsPage: React.FC = () => {
const { authService } = await import('../../../../api');
await authService.deleteAccount(deleteConfirmEmail, deletePassword, deleteReason);
addToast(t('common.success'), { type: 'success' });
showToast.success(t('common.success'));
setTimeout(() => {
logout();
navigate('/');
}, 2000);
} catch (err: any) {
addToast(err.message || t('common.error'), { type: 'error' });
showToast.error(err.message || t('common.error'));
} finally {
setIsDeleting(false);
}