-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): add feature flag for camera preview
- Loading branch information
1 parent
d5ad675
commit 036cef2
Showing
5 changed files
with
51 additions
and
28 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
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
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
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
24 changes: 6 additions & 18 deletions
24
packages/client/src/pages/authorized/Dashboard/sections/TogglingSection/index.tsx
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 |
---|---|---|
@@ -1,29 +1,17 @@ | ||
import React, { useContext, useMemo } from 'react'; | ||
import React, { useContext } from 'react'; | ||
|
||
import { ToggleSlider } from '../../../../../elements'; | ||
import { ConnectionState } from '../../../../../enums/connectionState.enum'; | ||
import { DeviceStatus } from '../../../../../enums/deviceStatus.enum'; | ||
import { WebSocketContext } from '../../../../../providers/api/WebSocketProvider/WebSocketProvider.context'; | ||
import GateDisconnected from './components/GateDisconnected'; | ||
import { ToggleSliderWrapper } from './TogglingSection.styled'; | ||
|
||
const TogglingSection = () => { | ||
const { toggleGate, connectionState, deviceStatus } = useContext(WebSocketContext); | ||
const { toggleGate } = useContext(WebSocketContext); | ||
|
||
const isConnected = useMemo( | ||
() => connectionState === ConnectionState.CONNECTED && deviceStatus === DeviceStatus.CONNECTED, | ||
[connectionState, deviceStatus], | ||
return ( | ||
<ToggleSliderWrapper> | ||
<ToggleSlider onToggle={toggleGate} /> | ||
</ToggleSliderWrapper> | ||
); | ||
|
||
if (isConnected) { | ||
return ( | ||
<ToggleSliderWrapper> | ||
<ToggleSlider onToggle={toggleGate} /> | ||
</ToggleSliderWrapper> | ||
); | ||
} | ||
|
||
return <GateDisconnected connectionState={connectionState} deviceStatus={deviceStatus} />; | ||
}; | ||
|
||
export default TogglingSection; |