Skip to content

Commit

Permalink
integrate lock and unlock apis
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranshu1902 committed Nov 16, 2023
1 parent 11527f4 commit 8f86f98
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/Components/Facility/Consultations/LiveFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import Page from "../../Common/components/Page";
import ConfirmDialog from "../../Common/ConfirmDialog";
import { FieldLabel } from "../../Form/FormFields/FormField";
import useFullscreen from "../../../Common/hooks/useFullscreen";
// import useQuery from "../../../Utils/request/useQuery";
import routes from "../../../Redux/api";
import request from "../../../Utils/request/request";

const LiveFeed = (props: any) => {
const middlewareHostname =
Expand Down Expand Up @@ -291,6 +294,33 @@ const LiveFeed = (props: any) => {
return { ...option, callback: () => cb(option) };
});

// lock and unlock asset methods
const lockAsset = async () => {
const { data } = await request(routes.lockAsset, {
pathParams: {
asset_external_id: props.asset?.id ?? "",
},
});
console.log(data);

// useQuery(routes.lockAsset, {
// pathParams: { asset_external_id: "assetId" },
// });
};

const unlockAsset = async () => {
const { data } = await request(routes.unlockAsset, {
pathParams: {
asset_external_id: props.asset?.id ?? "",
},
});
console.log(data);

// useQuery(routes.unlockAsset, {
// pathParams: { asset_external_id: "assetId" },
// });
};

// Voluntarily disabling eslint, since length of `cameraPTZ` is constant and
// hence shall not cause issues. (https://news.ycombinator.com/item?id=24363703)
for (const option of cameraPTZ) {
Expand Down Expand Up @@ -463,7 +493,16 @@ const LiveFeed = (props: any) => {

<div className="mx-4 flex max-w-sm flex-col">
<div>
<button onClick={() => setLockStatus(!lockStatus)}>
<button
onClick={() => {
if (lockStatus) {
unlockAsset();
} else {
lockAsset();
}
setLockStatus(!lockStatus);
}}
>
: Lock Status: <b>{lockStatus ? "Locked" : "Unlocked"}</b>
</button>
</div>
Expand Down
23 changes: 23 additions & 0 deletions src/Redux/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,29 @@ const routes = {
TBody: Type<AssetServiceUpdate>(),
},

// Asset lock endpoints

lockAsset: {
path: "/api/v1/asset/{asset_external_id}/lock_asset/",
method: "POST",
TRes: Type<unknown>(),
TBody: Type<unknown>(),
},
unlockAsset: {
path: "/api/v1/asset/{asset_external_id}/unlock_asset/",
method: "POST",
TRes: Type<unknown>(),
TBody: Type<unknown>(),
},
addWaitingUserToAsset: {
path: "/api/v1/asset/{asset_external_id}/add_waiting_user/",
method: "POST",
},
removeWaitingUserFromAsset: {
path: "/api/v1/asset/{asset_external_id}/remove_waiting_user/",
method: "POST",
},

abha: {
// ABDM HealthID endpoints
generateAadhaarOtp: {
Expand Down

0 comments on commit 8f86f98

Please sign in to comment.