import React, { useEffect, useState } from 'react'; import '../Manager/App.scss'; import { api, Restriction, ShareType } from '../Common/Api'; import RestrictionRow from './RestrictionRow'; import ShareSelection from '../Common/ShareSelection'; type Props = { } const App: React.FC = () => { const [areRestrictionsLoaded, setRestrictionsLoaded] = useState(false); const [error, setError] = useState(''); const [restrictions, setRestrictions] = useState([]); const rows = restrictions.sort((a, b) => a.groupId.localeCompare(b.groupId)).map(restriction => ); useEffect(() => { api.getRestrictions().then(restrictions => { setRestrictions(restrictions); }).catch((err) => { console.warn('Could not load restrictions', err); setError(t('bbb', 'Server error')); }).then(() => { setRestrictionsLoaded(true); }); }, []); function addRestriction(groupId: string) { return api.createRestriction(groupId).then(restriction => { setRestrictions([...restrictions, restriction]); }); } function updateRestriction(restriction: Restriction) { return api.updateRestriction(restriction).then(updatedRestriction => { setRestrictions(restrictions.map(restriction => { if (restriction.id === updatedRestriction.id || restriction.groupId === updatedRestriction.groupId) { return updatedRestriction; } return restriction; })); }); } function deleteRestriction(id: number) { api.deleteRestriction(id).then(deletedRestriction => { setRestrictions(restrictions.filter(restriction => restriction.id !== deletedRestriction.id)); }); } return (
{rows}
{t('bbb', 'Group name')} {t('bbb', 'Max. rooms')} {t('bbb', 'Access options')} {t('bbb', 'Max. participants')} {t('bbb', 'Recording')}
{!areRestrictionsLoaded ? : addRestriction(share.value.shareWith)} shareType={[ShareType.Group]} excluded={{groupIds: restrictions.map(restriction => restriction.groupId)}} /> } {error && <> {error}}

{t('bbb', 'Restrictions do not affect existing rooms. Minus one means the value is unlimited. The least restrictive option is chosen for every user if multiple restrictions apply.')}

); }; export default App;