fix: remove duplicate and deprecated createService implementation
This commit is contained in:
@@ -128,17 +128,31 @@
|
|||||||
let creatingService = $state(false);
|
let creatingService = $state(false);
|
||||||
|
|
||||||
async function createService() {
|
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;
|
creatingService = true;
|
||||||
const loadingToast = toast.loading('Creating service...');
|
const loadingToast = toast.loading('Creating service...');
|
||||||
|
|
||||||
const payload = {
|
|
||||||
...newService,
|
|
||||||
price: Number(newService.price),
|
|
||||||
duration_minutes: Number(newService.duration_minutes),
|
|
||||||
minimum_age_required: Number(newService.minimum_age_required)
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const payload = {
|
||||||
|
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)
|
||||||
|
};
|
||||||
|
|
||||||
const response = await fetch('/api/admin/services', {
|
const response = await fetch('/api/admin/services', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
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() {
|
function resetServiceForm() {
|
||||||
newService = {
|
newService = {
|
||||||
name: '',
|
name: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user