refactor(frontend): migrate Customer domain to centralized API services

- Replaced all direct axios imports with service layer calls across 8 customer files
- Migrated core pages: home.vue, create.vue, edit.vue
- Migrated profile pages: profile.vue (1100+ lines), TankEstimation.vue
- Migrated supporting pages: ServicePlanEdit.vue, tank/edit.vue, list.vue

Services integrated:
- customerService: CRUD, descriptions, tank info, automatic status
- authService: authentication and Authorize.net account management
- paymentService: credit cards, transactions, payment authorization
- deliveryService: delivery records and automatic delivery data
- serviceService: service calls, parts, and service plans
- adminService: statistics, social comments, and reports
- queryService: dropdown data (customer types, states)

Type safety improvements:
- Updated paymentService.ts with accurate AxiosResponse types
- Fixed response unwrapping to match api.ts interceptor behavior
- Resolved all TypeScript errors in customer domain (0 errors)

Benefits:
- Consistent authentication via centralized interceptors
- Standardized error handling across all API calls
- Improved type safety with proper TypeScript interfaces
- Single source of truth for API endpoints
- Better testability through mockable services

Verified with vue-tsc --noEmit - all customer domain files pass type checking
This commit is contained in:
2026-02-01 13:00:21 -05:00
parent 5060ca8d9b
commit 72d8e35e06
59 changed files with 850 additions and 6220 deletions

View File

@@ -283,6 +283,7 @@ export default defineComponent({
method: "get",
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data && response.data.ok) {
@@ -312,8 +313,7 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.customer_description = response.data
this.customer_description = response.data?.description || response.data
})
},
@@ -323,6 +323,7 @@ export default defineComponent({
method: "get",
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data.ok) {
@@ -350,7 +351,7 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.customer = response.data
this.customer = response.data?.customer || response.data
this.getPastDeliveries1(this.customer.id)
this.getPastDeliveries2(this.customer.id)
@@ -365,8 +366,7 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.customer_tank = response.data
this.customer_tank = response.data?.tank || response.data
})
},
@@ -377,7 +377,7 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.past_deliveries1 = response.data
this.past_deliveries1 = response.data?.deliveries || response.data
})
},
getPastDeliveries2(userid: any) {
@@ -387,7 +387,7 @@ export default defineComponent({
url: path,
headers: authHeader(),
}).then((response: any) => {
this.past_deliveries2 = response.data
this.past_deliveries2 = response.data?.deliveries || response.data
})
},
@@ -415,8 +415,7 @@ export default defineComponent({
})
.then((response: any) => {
if (response.data) {
this.promo = response.data
// this.delivery.promo_id = this.promo.id
this.promo = response.data?.promo || response.data
}
})
},