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