"use server"; import {CreateCustomerDto} from "@/services/customers/dtos/createCustomer.dto"; export async function addCustomer(params: CreateCustomerDto): Promise { const {email, name, companyName, street, zip, city, phoneNumbers, notes} = params; const payload: CreateCustomerDto = { email, name, companyName, street, zip, city, phoneNumbers, notes: notes.map(({text}) => ({text})), }; const response = await fetch('/api/customers', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(payload) }); if (!response.ok) { throw new Error(`Failed to create customer: ${response.statusText}`); } }