import { OriginDeviceDTO } from '@energyweb/origin-device-registry-api-react-query-client' ; import { PublicDeviceDTO , DeviceDTO as IRecMyDeviceDTO , } from '@energyweb/origin-device-registry-irec-local-api-react-query-client' ; import { ComposedDevice , ComposedPublicDevice } from './types' ; export function composePublicDevices ( originDevices , iRecDevices ) { if ( ! originDevices || ! iRecDevices ) return [ ] ; const composedResult = [ ] ; for ( const originDevice of originDevices ) { const matchingIRecDevice = iRecDevices . find ( ( device ) => device . id === originDevice . externalRegistryId ) ; composedResult . push ( { ... originDevice , ... matchingIRecDevice , id : originDevice . id , } ) ; } return composedResult ; } export function composeMyDevices ( originDevices , iRecDevices ) { const composedResult = [ ] ; for ( const originDevice of originDevices ) { const matchingIRecDevice = iRecDevices . find ( ( device ) => device . id === originDevice . externalRegistryId ) ; composedResult . push ( { ... originDevice , ... matchingIRecDevice , id : originDevice . id , } ) ; } return composedResult ; }