File size: 1,080 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import PropTypes from 'prop-types';
import FormSelect from 'calypso/components/forms/form-select';
import { useNotificationDevicesQuery } from 'calypso/data/notification-devices/use-notification-devices-query';
import StreamHeader from './stream-header';
function NotificationSettingsFormDeviceSelector( { selectedDeviceId, onChange } ) {
const { data: devices = [] } = useNotificationDevicesQuery();
if ( devices.length === 1 ) {
return <StreamHeader title={ devices[ 0 ].name } />;
}
return (
<div className="notification-settings-form-header">
<div className="notification-settings-form-header__title">
<FormSelect value={ selectedDeviceId } onChange={ onChange }>
{ devices.map( ( { id, name } ) => (
<option key={ `device-notifications-${ id }` } value={ id }>
{ name }
</option>
) ) }
</FormSelect>
</div>
</div>
);
}
NotificationSettingsFormDeviceSelector.propTypes = {
selectedDeviceId: PropTypes.number.isRequired,
onChange: PropTypes.func.isRequired,
};
export default NotificationSettingsFormDeviceSelector;
|