refactor(actions): adopt endpoint client in reference data service
This commit is contained in:
@@ -7,6 +7,11 @@ Current extracted clients:
|
||||
- `relayClient` (shared hash-signing helper used by account/portal/document direct services)
|
||||
- `endpointClient` (shared JSON request helpers for GET and generic axios config requests)
|
||||
|
||||
Current usage includes:
|
||||
|
||||
- relay hash-signing helper reuse across account/portal/document direct services
|
||||
- shared endpoint JSON request helpers reused by admin/notify/integration/reference-data direct services
|
||||
|
||||
Notes:
|
||||
|
||||
- Core helper extraction and compatibility barrel support remain in place.
|
||||
|
||||
@@ -1,76 +1,58 @@
|
||||
import axios from "axios";
|
||||
import { BASE_URL } from "../core/env";
|
||||
import { consoleLogger } from "../core/logger";
|
||||
import { logAndReturnEmptyValueErrorResponse } from "./httpServiceUtils";
|
||||
import { getJson } from "../clients/endpointClient";
|
||||
|
||||
export const getAppealsTypes = () => {
|
||||
return axios
|
||||
.get(BASE_URL + "/api/endpoint/getappealtypes_api")
|
||||
.then((res) => res.data)
|
||||
.catch(logAndReturnEmptyValueErrorResponse);
|
||||
return getJson(BASE_URL + "/api/endpoint/getappealtypes_api").catch(
|
||||
logAndReturnEmptyValueErrorResponse
|
||||
);
|
||||
};
|
||||
|
||||
export const getProjectTypes = () => {
|
||||
return axios
|
||||
.get(BASE_URL + "/api/endpoint/getprojecttypes_api")
|
||||
.then((res) => res.data)
|
||||
.catch(logAndReturnEmptyValueErrorResponse);
|
||||
return getJson(BASE_URL + "/api/endpoint/getprojecttypes_api").catch(
|
||||
logAndReturnEmptyValueErrorResponse
|
||||
);
|
||||
};
|
||||
|
||||
export const getAppealsTypesForNewAppeal = () => {
|
||||
return axios
|
||||
.get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api")
|
||||
.then((res) => res.data)
|
||||
.catch(logAndReturnEmptyValueErrorResponse);
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api"
|
||||
).catch(logAndReturnEmptyValueErrorResponse);
|
||||
};
|
||||
|
||||
export const getLPA = () => {
|
||||
return axios
|
||||
.get(BASE_URL + "/api/endpoint/getlpa_api")
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch(logAndReturnEmptyValueErrorResponse);
|
||||
return getJson(BASE_URL + "/api/endpoint/getlpa_api").catch(
|
||||
logAndReturnEmptyValueErrorResponse
|
||||
);
|
||||
};
|
||||
|
||||
export const getFormData = (whichForm) => {
|
||||
return axios
|
||||
.get(BASE_URL + "/api/endpoint/getformdata_api?whichForm=" + whichForm)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getformdata_api?whichForm=" + whichForm
|
||||
).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getMandatoryFields = (whichForm) => {
|
||||
return axios
|
||||
.get(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getmandatoryfields_api?whichForm=" +
|
||||
whichForm
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getmandatoryfields_api?whichForm=" + whichForm
|
||||
).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getPickLists = (whichForm) => {
|
||||
return axios
|
||||
.get(BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm
|
||||
).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getNotice = () => {
|
||||
return axios
|
||||
.get(BASE_URL + "/api/notices")
|
||||
.then((res) => {
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
return getJson(BASE_URL + "/api/notices").catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1485,3 +1485,31 @@ Addendum (same TASK22260 slice):
|
||||
- `actions/services/integrationDirectService.js` (POST via `requestJson`)
|
||||
- `actions/services/adminDirectService.js` (GET flows via `getJson`)
|
||||
- Updated `actions/clients/README.md` to include `endpointClient` in current extracted clients.
|
||||
|
||||
---
|
||||
|
||||
### CL-040: TASK22260 next slice — reference-data direct service endpointClient adoption
|
||||
|
||||
date: 2026-03-25
|
||||
author: Cline
|
||||
scope: `actions/services/referenceDataDirectService.js`, `actions/clients/README.md`
|
||||
type: change
|
||||
rationale: Continue the incremental façade/client adoption stream by migrating another bounded direct-service module to shared endpoint request helpers.
|
||||
impact: Reduces axios boilerplate and centralizes JSON extraction behavior for reference-data requests without changing public call signatures.
|
||||
status: completed
|
||||
|
||||
Summary:
|
||||
|
||||
- Migrated `actions/services/referenceDataDirectService.js` from direct `axios.get(...).then(res => res.data)` patterns to shared `getJson(...)` helper from `actions/clients/endpointClient`.
|
||||
- Preserved existing error behavior:
|
||||
- `logAndReturnEmptyValueErrorResponse` for appeals/project/LPA fetches
|
||||
- `consoleLogger` catch handling for form/mandatory/picklist/notice fetches
|
||||
- Updated `actions/clients/README.md` usage notes to include reference-data service reuse.
|
||||
|
||||
Validation:
|
||||
|
||||
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
|
||||
|
||||
Follow-ups:
|
||||
|
||||
- Next optional bounded slice: adopt `getJson`/`requestJson` for selected low-risk read paths in `searchDirectService` or `caseDirectService` while preserving per-function error semantics.
|
||||
|
||||
Reference in New Issue
Block a user