Skip to content

Commit

Permalink
show display name for approver field on tag settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
etCoderDysto committed Nov 22, 2024
1 parent 376f9f0 commit bf58af6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
Expand Down Expand Up @@ -52,6 +53,12 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) {
navigation.setParams({tagName: currentPolicyTag?.name});
}, [tagName, currentPolicyTag, navigation]);

const approverText = useMemo(() => {
const tagApprover = PolicyUtils.getTagApproverRule(policyID, route.params?.tagName)?.approver ?? '';
const approver = PersonalDetailsUtils.getPersonalDetailByEmail(tagApprover);
return approver?.displayName ?? tagApprover;
}, [policyID, route.params?.tagName, policy?.rules?.approvalRules]);

Check warning on line 60 in src/pages/workspace/tags/TagSettingsPage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has an unnecessary dependency: 'policy.rules.approvalRules'. Either exclude it or remove the dependency array

Check warning on line 60 in src/pages/workspace/tags/TagSettingsPage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has an unnecessary dependency: 'policy.rules.approvalRules'. Either exclude it or remove the dependency array

if (!currentPolicyTag) {
return <NotFoundPage />;
}
Expand Down Expand Up @@ -104,7 +111,6 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) {

const isThereAnyAccountingConnection = Object.keys(policy?.connections ?? {}).length !== 0;
const isMultiLevelTags = PolicyUtils.isMultiLevelTags(policyTags);
const tagApprover = PolicyUtils.getTagApproverRule(policyID, route.params.tagName)?.approver;

const shouldShowDeleteMenuItem = !isThereAnyAccountingConnection && !isMultiLevelTags;
const workflowApprovalsUnavailable = PolicyUtils.getWorkflowApprovalsUnavailable(policy);
Expand Down Expand Up @@ -180,7 +186,7 @@ function TagSettingsPage({route, navigation}: TagSettingsPageProps) {
<Text style={[styles.textNormal, styles.textStrong, styles.mv3]}>{translate('workspace.tags.tagRules')}</Text>
</View>
<MenuItemWithTopDescription
title={tagApprover ?? ''}
title={approverText}
description={translate(`workspace.tags.approverDescription`)}
onPress={navigateToEditTagApprover}
shouldShowRightIcon
Expand Down

0 comments on commit bf58af6

Please sign in to comment.