refactor(actions): adopt endpoint client in portal service reads

This commit is contained in:
2026-03-25 06:26:45 +00:00
parent a74f59394e
commit f596ad4e98
2 changed files with 97 additions and 104 deletions
+69 -104
View File
@@ -2,141 +2,107 @@ import axios from "axios";
import { BASE_URL } from "../core/env";
import { consoleLogger } from "../core/logger";
import { buildHashedQueryUrl } from "../clients/relayClient";
import { getJson, requestJson } from "../clients/endpointClient";
export const getMyCases = (loggedInUserId) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getmycases_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
return getJson(
BASE_URL +
"/api/endpoint/getmycases_api?loggedInUserId=" +
loggedInUserId
).catch((error) => {
consoleLogger(error);
});
};
export const getMyInvolvements = async (loggedInUserId) => {
try {
const res = await axios.get(
BASE_URL +
"/api/endpoint/getmyinvolvements_api?loggedInUserId=" +
loggedInUserId
);
return res.data;
} catch (error) {
return getJson(
BASE_URL +
"/api/endpoint/getmyinvolvements_api?loggedInUserId=" +
loggedInUserId
).catch((error) => {
consoleLogger(error);
}
});
};
export const getMyLPACases = (lpaid) => {
return axios
.get(BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
return getJson(
BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid
).catch((error) => {
consoleLogger(error);
});
};
export const getMyRepresentations = (loggedInUserId) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
BASE_URL +
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
loggedInUserId
).catch((error) => {
consoleLogger(error);
});
};
export const getMyRepresentationsProxy = (loggedInUserId) => {
return axios
.get(
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
loggedInUserId
).catch((error) => {
consoleLogger(error);
});
};
export const getRepresentations = (incidentID) => {
return axios
.get("/api/endpoint/getrepresentations_api?incidentID=" + incidentID)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
"/api/endpoint/getrepresentations_api?incidentID=" + incidentID
).catch((error) => {
consoleLogger(error);
});
};
export const getRepresentationsProxy = (incidentID) => {
return axios
.get(
"/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
"/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID
).catch((error) => {
consoleLogger(error);
});
};
export const getWatchedCases = (loggedInUserId) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
BASE_URL +
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
loggedInUserId
).catch((error) => {
consoleLogger(error);
});
};
export const getWatchedCasesProxy = (loggedInUserId) => {
return axios
.get(
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
loggedInUserId
).catch((error) => {
consoleLogger(error);
});
};
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
return axios
.get(
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
loggedInUserId
).catch((error) => {
consoleLogger(error);
});
};
export const getAwaitingSubmission = (loggedInUserId) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
loggedInUserId
)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
return getJson(
BASE_URL +
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
loggedInUserId
).catch((error) => {
consoleLogger(error);
});
};
export const createWatchedCases = async (formValues) => {
@@ -150,8 +116,7 @@ export const createWatchedCases = async (formValues) => {
};
try {
const res = await axios(config);
return res.data;
return await requestJson(config);
} catch (error) {
consoleLogger(error);
}
+28
View File
@@ -1544,3 +1544,31 @@ Validation:
Follow-ups:
- Optional next bounded slice: adopt endpoint client helpers in selected `portalDirectService` GET/POST helper paths while preserving delete/hash flow semantics.
---
### CL-042: TASK22260 next slice — portal direct service partial endpointClient adoption
date: 2026-03-25
author: Cline
scope: `actions/services/portalDirectService.js`
type: change
rationale: Continue phased client-layer adoption by migrating low-risk portal direct-service read/create paths to shared endpoint request helpers while leaving hash-sensitive delete/message flows unchanged.
impact: Reduces duplicated axios response extraction on high-traffic portal retrieval paths and keeps hashed delete/message semantics stable.
status: completed
Summary:
- Refactored selected `portalDirectService` functions to use shared endpoint client helpers:
- `getJson(...)` for read/listing routes (`getMyCases`, `getMyInvolvements`, `getMyLPACases`, representations, watched, awaiting submission variants)
- `requestJson(...)` for `createWatchedCases`
- Preserved existing hash/delete/message flow implementations (`deleteMyRepresentations`, `deleteWatchedCases`, completion message functions) using existing axios + relay signing behavior.
- Preserved existing catch-path logging behavior for all migrated functions.
Validation:
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
Follow-ups:
- Optional next bounded slice: migrate remaining non-hash POST helpers in `portalDirectService` (`setRepInvolvment`, `setCaseInvolvment`) to `requestJson` for full internal consistency.