refactor: improve fetch request handling, update invoice PDF layout, and adjust docker-compose configuration
This commit is contained in:
@@ -18,9 +18,22 @@
|
||||
const fd = new FormData();
|
||||
fd.append('avatar', input.files[0]);
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
const res = await fetch('{{ route('clients.upload-avatar', $client) }}', { method: 'POST', body: fd });
|
||||
const data = await res.json();
|
||||
if (res.ok) this.avatarUrl = data.url + '?t=' + Date.now();
|
||||
try {
|
||||
const res = await fetch('{{ route('clients.upload-avatar', $client->id, false) }}', {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
headers: { 'Accept': 'application/json' }
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
this.avatarUrl = data.url + '?t=' + Date.now();
|
||||
} else {
|
||||
alert(data.message || 'Upload failed');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Avatar upload error:', err);
|
||||
alert('Network Error. Could not upload.');
|
||||
}
|
||||
this.uploading = false;
|
||||
input.value = '';
|
||||
},
|
||||
@@ -29,8 +42,16 @@
|
||||
const fd = new FormData();
|
||||
fd.append('_token', document.querySelector('meta[name=csrf-token]').content);
|
||||
fd.append('_method', 'DELETE');
|
||||
await fetch('{{ route('clients.delete-avatar', $client) }}', { method: 'POST', body: fd });
|
||||
this.avatarUrl = '';
|
||||
try {
|
||||
await fetch('{{ route('clients.delete-avatar', $client->id, false) }}', {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
headers: { 'Accept': 'application/json' }
|
||||
});
|
||||
this.avatarUrl = '';
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}">
|
||||
<div class="flex items-start gap-4">
|
||||
|
||||
Reference in New Issue
Block a user