fix: toast theme & error msgs
This commit is contained in:
@@ -16,21 +16,21 @@ const getToastStyles = (_type: ToastType) => {
|
||||
'flex items-center gap-3 rounded-lg border-l-4 p-4 shadow-lg transition-all duration-300';
|
||||
|
||||
const typeStyles = {
|
||||
info: 'border-secondary-500 bg-secondary-50 dark:bg-secondary-100/20',
|
||||
warning: 'border-yellow-500 bg-yellow-50 dark:bg-yellow-100/20',
|
||||
error: 'border-red-500 bg-red-50 dark:bg-red-100/20',
|
||||
info: 'border-secondary-500 bg-secondary-100',
|
||||
warning: 'border-yellow-500 bg-yellow-100',
|
||||
error: 'border-red-500 bg-red-100',
|
||||
};
|
||||
|
||||
const iconStyles = {
|
||||
info: 'text-secondary-600 dark:text-secondary-500',
|
||||
warning: 'text-yellow-700 dark:text-yellow-500',
|
||||
error: 'text-red-600 dark:text-red-400',
|
||||
info: 'text-secondary-700',
|
||||
warning: 'text-yellow-700',
|
||||
error: 'text-red-700',
|
||||
};
|
||||
|
||||
const textStyles = {
|
||||
info: 'text-secondary-900 dark:text-secondary-700',
|
||||
warning: 'text-yellow-900 dark:text-yellow-700',
|
||||
error: 'text-red-900 dark:text-red-700',
|
||||
info: 'text-secondary-900',
|
||||
warning: 'text-yellow-900',
|
||||
error: 'text-red-900',
|
||||
};
|
||||
|
||||
return { baseStyles, typeStyles, iconStyles, textStyles };
|
||||
|
||||
@@ -31,7 +31,12 @@ export default function AdminUsersPage() {
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
onSuccess: response => {
|
||||
if (response.status < 200 || response.status >= 300) {
|
||||
showError('Failed to create user: ' + getErrorMessage(response.data));
|
||||
return;
|
||||
}
|
||||
|
||||
showInfo('User created successfully');
|
||||
setShowAddForm(false);
|
||||
setNewUsername('');
|
||||
@@ -50,7 +55,12 @@ export default function AdminUsersPage() {
|
||||
data: { operation: 'DELETE', user: userId },
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
onSuccess: response => {
|
||||
if (response.status < 200 || response.status >= 300) {
|
||||
showError('Failed to delete user: ' + getErrorMessage(response.data));
|
||||
return;
|
||||
}
|
||||
|
||||
showInfo('User deleted successfully');
|
||||
refetch();
|
||||
},
|
||||
@@ -67,7 +77,12 @@ export default function AdminUsersPage() {
|
||||
data: { operation: 'UPDATE', user: userId, password },
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
onSuccess: response => {
|
||||
if (response.status < 200 || response.status >= 300) {
|
||||
showError('Failed to update password: ' + getErrorMessage(response.data));
|
||||
return;
|
||||
}
|
||||
|
||||
showInfo('Password updated successfully');
|
||||
refetch();
|
||||
},
|
||||
@@ -82,7 +97,12 @@ export default function AdminUsersPage() {
|
||||
data: { operation: 'UPDATE', user: userId, is_admin: isAdmin },
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
onSuccess: response => {
|
||||
if (response.status < 200 || response.status >= 300) {
|
||||
showError('Failed to update admin status: ' + getErrorMessage(response.data));
|
||||
return;
|
||||
}
|
||||
|
||||
showInfo(`User permissions updated to ${isAdmin ? 'admin' : 'user'}`);
|
||||
refetch();
|
||||
},
|
||||
|
||||
@@ -40,15 +40,21 @@ export default function SettingsPage() {
|
||||
}
|
||||
|
||||
try {
|
||||
await updateSettings.mutateAsync({
|
||||
const response = await updateSettings.mutateAsync({
|
||||
data: {
|
||||
password,
|
||||
new_password: newPassword,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
showInfo('Password updated successfully');
|
||||
setPassword('');
|
||||
setNewPassword('');
|
||||
return;
|
||||
}
|
||||
|
||||
showError('Failed to update password: ' + getErrorMessage(response.data));
|
||||
} catch (error) {
|
||||
showError('Failed to update password: ' + getErrorMessage(error));
|
||||
}
|
||||
@@ -58,12 +64,18 @@ export default function SettingsPage() {
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
await updateSettings.mutateAsync({
|
||||
const response = await updateSettings.mutateAsync({
|
||||
data: {
|
||||
timezone,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
showInfo('Timezone updated successfully');
|
||||
return;
|
||||
}
|
||||
|
||||
showError('Failed to update timezone: ' + getErrorMessage(response.data));
|
||||
} catch (error) {
|
||||
showError('Failed to update timezone: ' + getErrorMessage(error));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user