refactor(actions): adopt endpoint client in portal service reads
This commit is contained in:
@@ -2,141 +2,107 @@ 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 { buildHashedQueryUrl } from "../clients/relayClient";
|
import { buildHashedQueryUrl } from "../clients/relayClient";
|
||||||
|
import { getJson, requestJson } from "../clients/endpointClient";
|
||||||
|
|
||||||
export const getMyCases = (loggedInUserId) => {
|
export const getMyCases = (loggedInUserId) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
BASE_URL +
|
||||||
BASE_URL +
|
"/api/endpoint/getmycases_api?loggedInUserId=" +
|
||||||
"/api/endpoint/getmycases_api?loggedInUserId=" +
|
loggedInUserId
|
||||||
loggedInUserId
|
).catch((error) => {
|
||||||
)
|
consoleLogger(error);
|
||||||
.then((res) => {
|
});
|
||||||
return res.data;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMyInvolvements = async (loggedInUserId) => {
|
export const getMyInvolvements = async (loggedInUserId) => {
|
||||||
try {
|
return getJson(
|
||||||
const res = await axios.get(
|
BASE_URL +
|
||||||
BASE_URL +
|
"/api/endpoint/getmyinvolvements_api?loggedInUserId=" +
|
||||||
"/api/endpoint/getmyinvolvements_api?loggedInUserId=" +
|
loggedInUserId
|
||||||
loggedInUserId
|
).catch((error) => {
|
||||||
);
|
|
||||||
return res.data;
|
|
||||||
} catch (error) {
|
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMyLPACases = (lpaid) => {
|
export const getMyLPACases = (lpaid) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid)
|
BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid
|
||||||
.then((res) => {
|
).catch((error) => {
|
||||||
return res.data;
|
consoleLogger(error);
|
||||||
})
|
});
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMyRepresentations = (loggedInUserId) => {
|
export const getMyRepresentations = (loggedInUserId) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
BASE_URL +
|
||||||
BASE_URL +
|
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
|
||||||
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
|
loggedInUserId
|
||||||
loggedInUserId
|
).catch((error) => {
|
||||||
)
|
consoleLogger(error);
|
||||||
.then((res) => res.data)
|
});
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
|
||||||
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
|
loggedInUserId
|
||||||
loggedInUserId
|
).catch((error) => {
|
||||||
)
|
consoleLogger(error);
|
||||||
.then((res) => res.data)
|
});
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRepresentations = (incidentID) => {
|
export const getRepresentations = (incidentID) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get("/api/endpoint/getrepresentations_api?incidentID=" + incidentID)
|
"/api/endpoint/getrepresentations_api?incidentID=" + incidentID
|
||||||
.then((res) => res.data)
|
).catch((error) => {
|
||||||
.catch((error) => {
|
consoleLogger(error);
|
||||||
consoleLogger(error);
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRepresentationsProxy = (incidentID) => {
|
export const getRepresentationsProxy = (incidentID) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
"/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID
|
||||||
"/api/endpoint/getrepresentationsproxy_api?incidentID=" + incidentID
|
).catch((error) => {
|
||||||
)
|
consoleLogger(error);
|
||||||
.then((res) => res.data)
|
});
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getWatchedCases = (loggedInUserId) => {
|
export const getWatchedCases = (loggedInUserId) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
BASE_URL +
|
||||||
BASE_URL +
|
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
|
||||||
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
|
loggedInUserId
|
||||||
loggedInUserId
|
).catch((error) => {
|
||||||
)
|
consoleLogger(error);
|
||||||
.then((res) => res.data)
|
});
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getWatchedCasesProxy = (loggedInUserId) => {
|
export const getWatchedCasesProxy = (loggedInUserId) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
|
||||||
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
|
loggedInUserId
|
||||||
loggedInUserId
|
).catch((error) => {
|
||||||
)
|
consoleLogger(error);
|
||||||
.then((res) => res.data)
|
});
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
|
||||||
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
|
loggedInUserId
|
||||||
loggedInUserId
|
).catch((error) => {
|
||||||
)
|
consoleLogger(error);
|
||||||
.then((res) => res.data)
|
});
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getAwaitingSubmission = (loggedInUserId) => {
|
export const getAwaitingSubmission = (loggedInUserId) => {
|
||||||
return axios
|
return getJson(
|
||||||
.get(
|
BASE_URL +
|
||||||
BASE_URL +
|
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
|
||||||
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
|
loggedInUserId
|
||||||
loggedInUserId
|
).catch((error) => {
|
||||||
)
|
consoleLogger(error);
|
||||||
.then((res) => {
|
});
|
||||||
return res.data;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
consoleLogger(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createWatchedCases = async (formValues) => {
|
export const createWatchedCases = async (formValues) => {
|
||||||
@@ -150,8 +116,7 @@ export const createWatchedCases = async (formValues) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await axios(config);
|
return await requestJson(config);
|
||||||
return res.data;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
consoleLogger(error);
|
consoleLogger(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1544,3 +1544,31 @@ Validation:
|
|||||||
Follow-ups:
|
Follow-ups:
|
||||||
|
|
||||||
- Optional next bounded slice: adopt endpoint client helpers in selected `portalDirectService` GET/POST helper paths while preserving delete/hash flow semantics.
|
- 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user