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:
2025-07-11 18:38:44 +02:00
parent 328c0537ba
commit 2a95efb75f
5 changed files with 47 additions and 106 deletions

View File

@@ -24,7 +24,6 @@ import {ArrowRight} from "lucide-react";
import {NewCustomerModal} from "@/components/customers/modal/NewCustomerModal";
import {Customer} from "@/services/customers/entities/customer";
import Link from "next/link";
import {CustomerRepository} from "@/services/customers/repositories/customerRepository";
export default function CustomersPage() {
const [customers, setCustomers] = useState<Customer[]>([]);
@@ -35,7 +34,13 @@ export default function CustomersPage() {
useEffect(() => {
setLoading(true);
CustomerRepository.getAll()
fetch('/api/customers')
.then(async (response) => {
if (!response.ok) {
throw new Error(`Failed to fetch customers: ${response.statusText}`);
}
return response.json();
})
.then((data) => {
setCustomers(data);
})
@@ -176,4 +181,4 @@ export default function CustomersPage() {
</motion.div>
</div>
);
}
}