fix: remove duplicate and deprecated createService implementation
This commit is contained in:
@@ -128,17 +128,31 @@
|
||||
let creatingService = $state(false);
|
||||
|
||||
async function createService() {
|
||||
updateAllErrors();
|
||||
|
||||
const hasErrors = Object.values(serviceErrors).some((error) => error !== '');
|
||||
if (hasErrors) {
|
||||
toast.error('Please fix the validation errors before submitting');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isFormValid) {
|
||||
toast.error('Form validation failed');
|
||||
return;
|
||||
}
|
||||
|
||||
creatingService = true;
|
||||
const loadingToast = toast.loading('Creating service...');
|
||||
|
||||
try {
|
||||
const payload = {
|
||||
...newService,
|
||||
name: newService.name.trim(),
|
||||
description: newService.description.trim() || undefined,
|
||||
price: Number(newService.price),
|
||||
duration_minutes: Number(newService.duration_minutes),
|
||||
minimum_age_required: Number(newService.minimum_age_required)
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/admin/services', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -173,6 +187,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error creating service:', err);
|
||||
toast.error('Network error creating service', { id: loadingToast });
|
||||
} finally {
|
||||
creatingService = false;
|
||||
}
|
||||
}
|
||||
|
||||
function resetServiceForm() {
|
||||
newService = {
|
||||
name: '',
|
||||
|
||||
Reference in New Issue
Block a user