toast message modified for input field sanitization validation
This commit is contained in:
parent
d3ab799898
commit
ef95d4af09
@ -112,12 +112,10 @@ export function ActivityTypeManager() {
|
||||
if (editingActivityType) {
|
||||
// Update existing
|
||||
await updateActivityType(editingActivityType.activityTypeId, payload);
|
||||
setSuccessMessage('Activity type updated successfully');
|
||||
toast.success('Activity type updated successfully');
|
||||
} else {
|
||||
// Create new
|
||||
await createActivityType(payload);
|
||||
setSuccessMessage('Activity type created successfully');
|
||||
toast.success('Activity type created successfully');
|
||||
}
|
||||
|
||||
@ -139,10 +137,8 @@ export function ActivityTypeManager() {
|
||||
try {
|
||||
setError(null);
|
||||
await deleteActivityType(activityType.activityTypeId);
|
||||
setSuccessMessage('Activity type deleted successfully');
|
||||
toast.success('Activity type deleted successfully');
|
||||
await loadActivityTypes();
|
||||
setTimeout(() => setSuccessMessage(null), 3000);
|
||||
} catch (err: any) {
|
||||
const errorMsg = err.response?.data?.error || 'Failed to delete activity type';
|
||||
setError(errorMsg);
|
||||
|
||||
@ -30,6 +30,7 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { getAllHolidays, createHoliday, updateHoliday, deleteHoliday, Holiday } from '@/services/adminApi';
|
||||
import { formatDateShort } from '@/utils/dateFormatter';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
export function HolidayManager() {
|
||||
const [holidays, setHolidays] = useState<Holiday[]>([]);
|
||||
@ -111,11 +112,11 @@ export function HolidayManager() {
|
||||
if (editingHoliday) {
|
||||
// Update existing
|
||||
await updateHoliday(editingHoliday.holidayId, formData);
|
||||
setSuccessMessage('Holiday updated successfully');
|
||||
toast.success('Holiday updated successfully');
|
||||
} else {
|
||||
// Create new
|
||||
await createHoliday(formData);
|
||||
setSuccessMessage('Holiday created successfully');
|
||||
toast.success('Holiday created successfully');
|
||||
}
|
||||
|
||||
await loadHolidays();
|
||||
@ -134,11 +135,12 @@ export function HolidayManager() {
|
||||
try {
|
||||
setError(null);
|
||||
await deleteHoliday(holiday.holidayId);
|
||||
setSuccessMessage('Holiday deleted successfully');
|
||||
toast.success('Holiday deleted successfully');
|
||||
await loadHolidays();
|
||||
setTimeout(() => setSuccessMessage(null), 3000);
|
||||
} catch (err: any) {
|
||||
setError(err.response?.data?.error || 'Failed to delete holiday');
|
||||
const errorMsg = err.response?.data?.error || 'Failed to delete holiday';
|
||||
setError(errorMsg);
|
||||
toast.error(errorMsg);
|
||||
}
|
||||
};
|
||||
|
||||
@ -152,6 +154,8 @@ export function HolidayManager() {
|
||||
return 'bg-gradient-to-r from-purple-50 to-violet-50 text-purple-800 border-purple-300';
|
||||
case 'OPTIONAL':
|
||||
return 'bg-gradient-to-r from-slate-50 to-gray-50 text-slate-700 border-slate-300';
|
||||
default:
|
||||
return 'bg-gradient-to-r from-red-50 to-rose-50 text-red-800 border-red-300';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user