-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(automatic): Add API call for setpoint changes & integrate with W…
…ebSocket updates * Introduced `handleSetpointChange` function in `apiCalls.tsx` for API interactions * Incorporated WebSocket updates in `page.tsx` using `useWebSocket` hook * Introduced logic to enable / disable automatic control * controllable with Switch
- Loading branch information
1 parent
75c7e79
commit a364c20
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use server"; | ||
|
||
import { | ||
client, | ||
postSetpointV1SensorsFlowmetersSensorIdSetpointPost, | ||
} from "../api"; | ||
|
||
client.setConfig({ | ||
baseURL: process.env.BACKEND_URI, | ||
proxy: false, | ||
}); | ||
|
||
export async function handleSetpointChange( | ||
setpoint: number | null, | ||
sensorId: number | ||
) { | ||
postSetpointV1SensorsFlowmetersSensorIdSetpointPost({ | ||
body: { setpoint: setpoint }, | ||
path: { | ||
sensor_id: sensorId, | ||
}, | ||
}).then((response) => { | ||
if (response.data) { | ||
return response.data; | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters