diff --git a/src/pages/workspace/tags/WorkspaceTagsPage.tsx b/src/pages/workspace/tags/WorkspaceTagsPage.tsx index 62c0bd104bcb..92b016766742 100644 --- a/src/pages/workspace/tags/WorkspaceTagsPage.tsx +++ b/src/pages/workspace/tags/WorkspaceTagsPage.tsx @@ -34,8 +34,9 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; +import type {PendingAction} from '@src/types/onyx/OnyxCommon'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; -import type {TagListItem} from './types'; +import type {PolicyTag, PolicyTagList, TagListItem} from './types'; type WorkspaceTagsPageProps = StackScreenProps; @@ -71,6 +72,15 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { setSelectedTags({}); }, [isFocused]); + const getPendingAction = (policyTagList: PolicyTagList): PendingAction | undefined => { + if (!policyTagList) { + return undefined; + } + return (policyTagList.pendingAction as PendingAction) ?? Object.values(policyTagList.tags).some((tag: PolicyTag) => tag.pendingAction) + ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE + : undefined; + }; + const tagList = useMemo(() => { if (isMultiLevelTags) { return policyTagLists.map((policyTagList) => ({ @@ -79,6 +89,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { text: PolicyUtils.getCleanedTagName(policyTagList.name), keyForList: String(policyTagList.orderWeight), isSelected: selectedTags[policyTagList.name], + pendingAction: getPendingAction(policyTagList), enabled: true, required: policyTagList.required, rightElement: ( diff --git a/src/pages/workspace/tags/types.ts b/src/pages/workspace/tags/types.ts index b601ce458ce4..cae0e5c4e3dd 100644 --- a/src/pages/workspace/tags/types.ts +++ b/src/pages/workspace/tags/types.ts @@ -1,4 +1,5 @@ import type {ListItem} from '@components/SelectionList/types'; +import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon'; type TagListItem = ListItem & { value: string; @@ -6,5 +7,30 @@ type TagListItem = ListItem & { orderWeight?: number; }; +type PolicyTag = { + name: string; + enabled: boolean; + previousTagName?: string; + /** "General Ledger code" that corresponds to this tag in an accounting system. Similar to an ID. */ + // eslint-disable-next-line @typescript-eslint/naming-convention + 'GL Code'?: string; + errors?: Errors | null; + rules?: { + parentTagsFilter?: string; + }; + parentTagsFilter?: string; + pendingAction?: PendingAction | null; +}; + +type PolicyTags = Record; + +type PolicyTagList = { + name: string; + orderWeight: number; + required: boolean; + tags: PolicyTags; + pendingAction?: PendingAction | null; +}; + // eslint-disable-next-line import/prefer-default-export -export type {TagListItem}; +export type {TagListItem, PolicyTag, PolicyTagList};