feat: Aggiungi funzionalità di eliminazione per clienti e preventivi con gestione delle dipendenze

This commit is contained in:
2026-10-19 15:48:15 +02:00
parent d6a9978167
commit 31d5152d8c
20 changed files with 673 additions and 17 deletions
+11 -2
View File
@@ -22,8 +22,17 @@ async function request(path, options = {}) {
export const api = {
getCarrello: (token) => request(`/carrello/${token}`),
rimuoviItem: (token, itemId) => request(`/carrello/${token}/item/${itemId}`, { method: 'DELETE' }),
conferma: (token, dati) =>
request(`/carrello/${token}/conferma`, { method: 'POST', body: JSON.stringify(dati) }),
// Se l'utente era loggato nel configuratore, passiamo il suo token al backend così
// il preventivo viene agganciato al suo record cliente esistente invece di crearne
// uno nuovo (è lo stesso token usato per precompilare l'anagrafica).
conferma: (token, dati) => {
const headers = {}
const clienteToken = resolveClienteToken()
if (clienteToken) {
headers.Authorization = `Bearer ${clienteToken}`
}
return request(`/carrello/${token}/conferma`, { method: 'POST', body: JSON.stringify(dati), headers })
},
// Dati anagrafici del cliente loggato nel configuratore, per precompilare il checkout.
me: (clienteToken) =>
request('/auth/me', { headers: { Authorization: `Bearer ${clienteToken}` } }),