From c870552791466ff2e6f6e349de88760393ee1a59 Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Wed, 27 Mar 2024 07:39:14 +0700 Subject: [PATCH] change typescript type pattern --- .../workspace/tags/WorkspaceTagsPage.tsx | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index 2107fbb6ac5c..54cbe27b67d4 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -84,34 +84,33 @@ function WorkspaceTagsPage({policyTags, route}: WorkspaceTagsPageProps) { () => policyTagLists .map((policyTagList) => - lodashSortBy(Object.values(policyTagList.tags || []), 'name', localeCompare) - .filter((value): value is OnyxCommon.OnyxValueWithOfflineFeedback => typeof value === 'object' && value !== null) - .map((value) => { - const isDisabled = value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; - return { - value: value.name, - text: value.name, - keyForList: value.name, - isSelected: !!selectedTags[value.name], - pendingAction: value.pendingAction, - errors: value.errors ?? undefined, - enabled: value.enabled, - isDisabled, - rightElement: ( - - - {value.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} - - - - + lodashSortBy(Object.values(policyTagList.tags || []), 'name', localeCompare).map((value) => { + const tag = value as OnyxCommon.OnyxValueWithOfflineFeedback; + const isDisabled = tag.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; + return { + value: tag.name, + text: tag.name, + keyForList: tag.name, + isSelected: !!selectedTags[tag.name], + pendingAction: tag.pendingAction, + errors: tag.errors ?? undefined, + enabled: tag.enabled, + isDisabled, + rightElement: ( + + + {tag.enabled ? translate('workspace.common.enabled') : translate('workspace.common.disabled')} + + + - ), - }; - }), + + ), + }; + }), ) .flat(), [policyTagLists, selectedTags, styles.alignSelfCenter, styles.flexRow, styles.label, styles.p1, styles.pl2, styles.textSupporting, theme.icon, translate],