Add customer management
This commit is contained in:
21
internal_frontend/services/customers/usecases/addCustomer.ts
Normal file
21
internal_frontend/services/customers/usecases/addCustomer.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
"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;
|
||||
|
||||
const payload: CreateCustomerDto = {
|
||||
email,
|
||||
name,
|
||||
companyName,
|
||||
street,
|
||||
zip,
|
||||
city,
|
||||
phoneNumbers,
|
||||
notes: notes.map(({text}) => ({text})),
|
||||
};
|
||||
|
||||
await CustomerRepository.create(payload);
|
||||
}
|
||||
Reference in New Issue
Block a user