Remove CustomerRepository and replace with direct API calls
- Remove `CustomerRepository` and its methods for customer management and caching. - Refactor customer-related pages (`[id]/page.tsx`, `customers/page.tsx`) to use direct `fetch` API calls. - Update breadcrumb resolver to fetch data directly from the API. - Simplify `addCustomer` use case to avoid repository dependency.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"use server";
|
||||
|
||||
import {CreateCustomerDto} from "@/services/customers/dtos/createCustomer.dto";
|
||||
import {CustomerRepository} from "@/services/customers/repositories/customerRepository";
|
||||
|
||||
export async function addCustomer(params: CreateCustomerDto): Promise<void> {
|
||||
const {email, name, companyName, street, zip, city, phoneNumbers, notes} = params;
|
||||
@@ -17,5 +16,15 @@ export async function addCustomer(params: CreateCustomerDto): Promise<void> {
|
||||
notes: notes.map(({text}) => ({text})),
|
||||
};
|
||||
|
||||
await CustomerRepository.create(payload);
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user