new devices system prototype

This commit is contained in:
RoyceDa
2026-01-31 03:03:27 +02:00
parent 49cedac8af
commit e87518a77e
6 changed files with 75 additions and 59 deletions

View File

@@ -0,0 +1,23 @@
import { useContext } from "react";
import { DeviceEntry, DeviceVerifyState } from "../ProtocolProvider/protocol/packets/packet.device.list";
import { DeviceProviderContext } from "./DeviceProvider";
/**
* Получает устройство ожидающее подтверждения, если оно есть
* @returns возвращает устройство которое сейчас ждет одобрения
* от других устройств
*/
export function useVerifyRequest() : DeviceEntry | null {
const context = useContext(DeviceProviderContext);
if(!context) {
throw new Error("useVerifyRequest must be used within a DeviceProvider");
}
const pending = context.devices.find(device => device.deviceVerify === DeviceVerifyState.NOT_VERIFIED);
if(!pending) {
return null;
}
return pending;
}