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)
|
- `relayClient` (shared hash-signing helper used by account/portal/document direct services)
|
||||||
- `endpointClient` (shared JSON request helpers for GET and generic axios config requests)
|
- `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:
|
Notes:
|
||||||
|
|
||||||
- Core helper extraction and compatibility barrel support remain in place.
|
- 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 { BASE_URL } from "../core/env";
|
||||||
import { consoleLogger } from "../core/logger";
|
import { consoleLogger } from "../core/logger";
|
||||||
import { logAndReturnEmptyValueErrorResponse } from "./httpServiceUtils";
|
import { logAndReturnEmptyValueErrorResponse } from "./httpServiceUtils";
|
||||||
|
import { getJson } from "../clients/endpointClient";
|
||||||
|
|
||||||
export const getAppealsTypes = () => {
|
export const getAppealsTypes = () => {
|
||||||
return axios
|
return getJson(BASE_URL + "/api/endpoint/getappealtypes_api").catch(
|
||||||
.get(BASE_URL + "/api/endpoint/getappealtypes_api")
|
logAndReturnEmptyValueErrorResponse
|
||||||
.then((res) => res.data)
|
);
|
||||||
.catch(logAndReturnEmptyValueErrorResponse);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getProjectTypes = () => {
|
export const getProjectTypes = () => {
|
||||||
return axios
|
return getJson(BASE_URL + "/api/endpoint/getprojecttypes_api").catch(
|
||||||
.get(BASE_URL + "/api/endpoint/getprojecttypes_api")
|
logAndReturnEmptyValueErrorResponse
|
||||||
.then((res) => res.data)
|
);
|
||||||
.catch(logAndReturnEmptyValueErrorResponse);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAppealsTypesForNewAppeal = () => {
|
export const getAppealsTypesForNewAppeal = () => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api")
|
BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api"
|
||||||
.then((res) => res.data)
|
).catch(logAndReturnEmptyValueErrorResponse);
|
||||||
.catch(logAndReturnEmptyValueErrorResponse);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getLPA = () => {
|
export const getLPA = () => {
|
||||||
return axios
|
return getJson(BASE_URL + "/api/endpoint/getlpa_api").catch(
|
||||||
.get(BASE_URL + "/api/endpoint/getlpa_api")
|
logAndReturnEmptyValueErrorResponse
|
||||||
.then((res) => {
|
);
|
||||||
return res.data;
|
|
||||||
})
|
|
||||||
.catch(logAndReturnEmptyValueErrorResponse);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFormData = (whichForm) => {
|
export const getFormData = (whichForm) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(BASE_URL + "/api/endpoint/getformdata_api?whichForm=" + whichForm)
|
BASE_URL + "/api/endpoint/getformdata_api?whichForm=" + whichForm
|
||||||
.then((res) => res.data)
|
).catch((error) => {
|
||||||
.catch((error) => {
|
consoleLogger(error);
|
||||||
consoleLogger(error);
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMandatoryFields = (whichForm) => {
|
export const getMandatoryFields = (whichForm) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
BASE_URL + "/api/endpoint/getmandatoryfields_api?whichForm=" + whichForm
|
||||||
BASE_URL +
|
).catch((error) => {
|
||||||
"/api/endpoint/getmandatoryfields_api?whichForm=" +
|
consoleLogger(error);
|
||||||
whichForm
|
});
|
||||||
)
|
|
||||||
.then((res) => res.data)
|
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPickLists = (whichForm) => {
|
export const getPickLists = (whichForm) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm)
|
BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm
|
||||||
.then((res) => res.data)
|
).catch((error) => {
|
||||||
.catch((error) => {
|
consoleLogger(error);
|
||||||
consoleLogger(error);
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getNotice = () => {
|
export const getNotice = () => {
|
||||||
return axios
|
return getJson(BASE_URL + "/api/notices").catch((error) => {
|
||||||
.get(BASE_URL + "/api/notices")
|
consoleLogger(error);
|
||||||
.then((res) => {
|
});
|
||||||
return res.data;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1485,3 +1485,31 @@ Addendum (same TASK22260 slice):
|
|||||||
- `actions/services/integrationDirectService.js` (POST via `requestJson`)
|
- `actions/services/integrationDirectService.js` (POST via `requestJson`)
|
||||||
- `actions/services/adminDirectService.js` (GET flows via `getJson`)
|
- `actions/services/adminDirectService.js` (GET flows via `getJson`)
|
||||||
- Updated `actions/clients/README.md` to include `endpointClient` in current extracted clients.
|
- 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