diff --git a/src/Components/Assets/AssetManage.tsx b/src/Components/Assets/AssetManage.tsx
index 0da432eccb6..77bb88da3a8 100644
--- a/src/Components/Assets/AssetManage.tsx
+++ b/src/Components/Assets/AssetManage.tsx
@@ -498,7 +498,12 @@ const AssetManage = (props: AssetManageProps) => {
{asset?.id &&
asset?.asset_class &&
- asset?.asset_class != AssetClass.NONE && }
+ asset?.asset_class != AssetClass.NONE && (
+
+ )}
Service History
>;
+ params?: Record
;
+ }>
+) {
const [summary, setSummary] = useState<{
- [key: number]: AssetUptimeRecord[];
+ [key: number]: AvailabilityRecord[];
}>([]);
- const { data, loading } = useQuery(routes.listAssetAvailability, {
- query: { external_id: props.assetId },
+ const { data, loading } = useQuery(props.route, {
+ pathParams: props.params,
onResponse: ({ data }) => setUptimeRecord(data?.results.reverse() ?? []),
});
const availabilityData = data?.results ?? [];
@@ -186,8 +191,8 @@ export default function Uptime(props: { assetId: string }) {
setNumDays(Math.min(newNumDays, 100));
};
- const setUptimeRecord = (records: AssetUptimeRecord[]): void => {
- const recordsByDayBefore: { [key: number]: AssetUptimeRecord[] } = {};
+ const setUptimeRecord = (records: AvailabilityRecord[]): void => {
+ const recordsByDayBefore: { [key: number]: AvailabilityRecord[] } = {};
records.forEach((record) => {
const timestamp = dayjs(record.timestamp).startOf("day");
@@ -207,10 +212,8 @@ export default function Uptime(props: { assetId: string }) {
recordsByDayBefore[i] = [];
if (statusToCarryOver) {
recordsByDayBefore[i].push({
- id: "",
- asset: { id: "", name: "" },
- created_date: "",
- modified_date: "",
+ linked_id: "",
+ linked_model: "",
status: statusToCarryOver,
timestamp: dayjs()
.subtract(i, "days")
@@ -225,10 +228,8 @@ export default function Uptime(props: { assetId: string }) {
).length === 0
) {
recordsByDayBefore[i].unshift({
- id: "",
- asset: { id: "", name: "" },
- created_date: "",
- modified_date: "",
+ linked_id: "",
+ linked_model: "",
status: statusToCarryOver,
timestamp: dayjs()
.subtract(i, "days")
@@ -284,7 +285,7 @@ export default function Uptime(props: { assetId: string }) {
const statusColors: (typeof STATUS_COLORS)[keyof typeof STATUS_COLORS][] =
[];
let dayUptimeScore = 0;
- const recordsInPeriodCache: { [key: number]: AssetUptimeRecord[] } = {};
+ const recordsInPeriodCache: { [key: number]: AvailabilityRecord[] } = {};
for (let i = 0; i < 3; i++) {
const start = i * 8;
const end = (i + 1) * 8;
diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx
index eed17ad3b4b..40c842adc07 100644
--- a/src/Redux/api.tsx
+++ b/src/Redux/api.tsx
@@ -27,7 +27,7 @@ import {
AssetService,
AssetServiceUpdate,
AssetTransaction,
- AssetUptimeRecord,
+ AvailabilityRecord,
PatientAssetBed,
} from "../Components/Assets/AssetTypes";
import {
@@ -371,6 +371,11 @@ const routes = {
path: "/api/v1/facility/{facility_external_id}/asset_location/{external_id}/",
method: "PATCH",
},
+ getFacilityAssetLocationAvailability: {
+ path: "/api/v1/facility/{facility_external_id}/asset_location/{external_id}/availability/",
+ method: "GET",
+ TRes: Type>(),
+ },
// Asset bed
listAssetBeds: {
@@ -1116,6 +1121,11 @@ const routes = {
TRes: Type(),
TBody: Type>(),
},
+ listAssetAvailability: {
+ path: "/api/v1/asset/{external_id}/availability/",
+ method: "GET",
+ TRes: Type>(),
+ },
// Asset transaction endpoints
@@ -1290,19 +1300,6 @@ const routes = {
},
},
- // Asset Availability endpoints
-
- listAssetAvailability: {
- path: "/api/v1/asset_availability/",
- method: "GET",
- TRes: Type>(),
- },
- getAssetAvailability: {
- path: "/api/v1/asset_availability/{id}",
- method: "GET",
- TRes: Type(),
- },
-
// Prescription endpoints
listPrescriptions: {