Update doorbell

This commit is contained in:
Bill 2021-08-15 00:55:12 -04:00
parent 077c016212
commit 39d337e287
3 changed files with 30 additions and 10 deletions

View File

@ -5,6 +5,7 @@ import { LocalizeText } from '../../../../utils';
import { useRoomContext } from '../../context/RoomContext'; import { useRoomContext } from '../../context/RoomContext';
import { RoomWidgetDoorbellEvent } from '../../events'; import { RoomWidgetDoorbellEvent } from '../../events';
import { RoomWidgetLetUserInMessage } from '../../messages'; import { RoomWidgetLetUserInMessage } from '../../messages';
import { DoorbellWidgetItemView } from './doorbell-item/DoorbellWidgetItemView';
export const DoorbellWidgetView: FC<{}> = props => export const DoorbellWidgetView: FC<{}> = props =>
{ {
@ -62,7 +63,7 @@ export const DoorbellWidgetView: FC<{}> = props =>
removeUser(userName); removeUser(userName);
}, [ widgetHandler, removeUser ]); }, [ widgetHandler, removeUser ]);
if(!users.length) return null; if(!isVisible) return null;
return ( return (
<NitroCardView className="nitro-widget-doorbell" simple={ true }> <NitroCardView className="nitro-widget-doorbell" simple={ true }>
@ -71,15 +72,7 @@ export const DoorbellWidgetView: FC<{}> = props =>
<div className="row row-cols-1 doorbell-user-list"> <div className="row row-cols-1 doorbell-user-list">
{ (users.length > 0) && users.map(userName => { (users.length > 0) && users.map(userName =>
{ {
return ( return <DoorbellWidgetItemView key={ userName } userName={ userName } accept={ () => answer(userName, true) } deny={ () => answer(userName, false) } />;
<div className="d-flex col align-items-center justify-content-between" key={ userName }>
<span className="fw-bold text-black">{ userName }</span>
<div>
<button type="button" className="btn btn-success btn-sm me-1" onClick={ event => answer(userName, true) }><i className="fas fa-check" /></button>
<button type="button" className="btn btn-danger btn-sm" onClick={ event => answer(userName, false) }><i className="fas fa-times" /></button>
</div>
</div>
);
}) } }) }
</div> </div>
</NitroCardContentView> </NitroCardContentView>

View File

@ -0,0 +1,21 @@
import { FC } from 'react';
import { DoorbellWidgetItemViewProps } from './DoorbellWidgetItemView.types';
export const DoorbellWidgetItemView: FC<DoorbellWidgetItemViewProps> = props =>
{
const { userName = '', accept = null, deny = null } = props;
return (
<div className="d-flex col align-items-center justify-content-between">
<span className="fw-bold text-black">{ userName }</span>
<div>
<button type="button" className="btn btn-success btn-sm me-1" onClick={ accept }>
<i className="fas fa-check" />
</button>
<button type="button" className="btn btn-danger btn-sm" onClick={ deny }>
<i className="fas fa-times" />
</button>
</div>
</div>
);
}

View File

@ -0,0 +1,6 @@
export interface DoorbellWidgetItemViewProps
{
userName: string;
accept: () => void;
deny: () => void;
}