forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDomainGroupDetailsPage.tsx
More file actions
76 lines (69 loc) · 3.91 KB
/
Copy pathDomainGroupDetailsPage.tsx
File metadata and controls
76 lines (69 loc) · 3.91 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import {domainSecurityGroupSettingErrorsSelector, domainSecurityGroupSettingPendingActionSelector, selectGroupByID} from '@selectors/Domain';
import React from 'react';
import {View} from 'react-native';
import ErrorMessageRow from '@components/ErrorMessageRow';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@navigation/Navigation';
import type {PlatformStackScreenProps} from '@navigation/PlatformStackNavigation/types';
import type {SettingsNavigatorParamList} from '@navigation/types';
import DomainNotFoundPageWrapper from '@pages/domain/DomainNotFoundPageWrapper';
import {clearDomainSecurityGroupSettingError} from '@userActions/Domain';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import PreferredWorkspaceToggle from './PreferredWorkspaceToggle';
type DomainGroupDetailsPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.DOMAIN.GROUP_DETAILS>;
function DomainGroupDetailsPage({route}: DomainGroupDetailsPageProps) {
const {domainAccountID, groupID} = route.params;
const styles = useThemeStyles();
const {translate} = useLocalize();
const [group] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN}${domainAccountID}`, {
selector: selectGroupByID(groupID),
});
const [namePendingAction] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`, {selector: domainSecurityGroupSettingPendingActionSelector('name', groupID)});
const [nameErrors] = useOnyx(`${ONYXKEYS.COLLECTION.DOMAIN_ERRORS}${domainAccountID}`, {selector: domainSecurityGroupSettingErrorsSelector('nameErrors', groupID)});
return (
<DomainNotFoundPageWrapper domainAccountID={domainAccountID}>
<ScreenWrapper
shouldEnableMaxHeight
shouldShowOfflineIndicatorInWideScreen
testID="DomainGroupDetailsPage"
>
<HeaderWithBackButton
title={group?.name ?? translate('domain.groups.title')}
onBackButtonPress={() => Navigation.goBack(ROUTES.DOMAIN_GROUPS.getRoute(domainAccountID))}
/>
<ScrollView>
<OfflineWithFeedback pendingAction={namePendingAction}>
<MenuItemWithTopDescription
description={translate('common.name')}
title={group?.name ?? ''}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.DOMAIN_GROUP_EDIT_NAME.getRoute(domainAccountID, groupID))}
/>
<ErrorMessageRow
errors={nameErrors}
onDismiss={() => clearDomainSecurityGroupSettingError(domainAccountID, groupID, 'nameErrors')}
errorRowStyles={[styles.mh5, styles.mt3]}
/>
</OfflineWithFeedback>
<View style={[styles.sectionDividerLine, styles.ph5, styles.mv6]} />
<Text style={[styles.textNormal, styles.textStrong, styles.ph5]}>{translate('domain.groups.permissions')}</Text>
<PreferredWorkspaceToggle
domainAccountID={domainAccountID}
groupID={groupID}
/>
</ScrollView>
</ScreenWrapper>
</DomainNotFoundPageWrapper>
);
}
export default DomainGroupDetailsPage;