trigger socket event to display time picker
This commit is contained in:
@@ -5,6 +5,7 @@ import { useGlobalInfoStore } from "../../context/globalInfo";
|
|||||||
import { useActionContext } from '../../context/browserActions';
|
import { useActionContext } from '../../context/browserActions';
|
||||||
import DatePicker from './DatePicker';
|
import DatePicker from './DatePicker';
|
||||||
import Dropdown from './Dropdown';
|
import Dropdown from './Dropdown';
|
||||||
|
import TimePicker from './TimePicker';
|
||||||
|
|
||||||
interface CreateRefCallback {
|
interface CreateRefCallback {
|
||||||
(ref: React.RefObject<HTMLCanvasElement>): void;
|
(ref: React.RefObject<HTMLCanvasElement>): void;
|
||||||
@@ -49,6 +50,11 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => {
|
|||||||
}>;
|
}>;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
|
|
||||||
|
const [timePickerInfo, setTimePickerInfo] = React.useState<{
|
||||||
|
coordinates: Coordinates;
|
||||||
|
selector: string;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
const notifyLastAction = (action: string) => {
|
const notifyLastAction = (action: string) => {
|
||||||
if (lastAction !== action) {
|
if (lastAction !== action) {
|
||||||
setLastAction(action);
|
setLastAction(action);
|
||||||
@@ -81,6 +87,10 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => {
|
|||||||
setDropdownInfo(info);
|
setDropdownInfo(info);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('showTimePicker', (info: {coordinates: Coordinates, selector: string}) => {
|
||||||
|
setTimePickerInfo(info);
|
||||||
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off('showDatePicker');
|
socket.off('showDatePicker');
|
||||||
socket.off('showDropdown');
|
socket.off('showDropdown');
|
||||||
@@ -205,6 +215,13 @@ const Canvas = ({ width, height, onCreateRef }: CanvasProps) => {
|
|||||||
onClose={() => setDropdownInfo(null)}
|
onClose={() => setDropdownInfo(null)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{timePickerInfo && (
|
||||||
|
<TimePicker
|
||||||
|
coordinates={timePickerInfo.coordinates}
|
||||||
|
selector={timePickerInfo.selector}
|
||||||
|
onClose={() => setTimePickerInfo(null)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user