Skip to content

Commit

Permalink
chore: move changes from Policy.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
getusha committed May 30, 2024
1 parent a8c3429 commit 4e86f74
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libs/actions/Policy/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as ReportUtils from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SetPolicyTagsEnabled from '@libs/API/parameters/SetPolicyTagsEnabled';
import type {Policy, PolicyTag, PolicyTagList, PolicyTags, RecentlyUsedTags, Report} from '@src/types/onyx';
import type {OnyxValueWithOfflineFeedback} from '@src/types/onyx/OnyxCommon';
import type {Attributes, Rate} from '@src/types/onyx/Policy';
Expand Down Expand Up @@ -177,8 +178,8 @@ function createPolicyTag(policyID: string, tagName: string) {
API.write(WRITE_COMMANDS.CREATE_POLICY_TAG, parameters, onyxData);
}

function setWorkspaceTagEnabled(policyID: string, tagsToUpdate: Record<string, {name: string; enabled: boolean}>) {
const policyTag = PolicyUtils.getTagLists(allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {})?.[0] ?? {};
function setWorkspaceTagEnabled(policyID: string, tagsToUpdate: Record<string, {name: string; enabled: boolean}>, tagListIndex: number) {
const policyTag = PolicyUtils.getTagLists(allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {})?.[tagListIndex] ?? {};

const onyxData: OnyxData = {
optimisticData: [
Expand Down Expand Up @@ -258,9 +259,10 @@ function setWorkspaceTagEnabled(policyID: string, tagsToUpdate: Record<string, {
],
};

const parameters = {
const parameters: SetPolicyTagsEnabled = {
policyID,
tags: JSON.stringify(Object.keys(tagsToUpdate).map((key) => tagsToUpdate[key])),
tagListIndex,
};

API.write(WRITE_COMMANDS.SET_POLICY_TAGS_ENABLED, parameters, onyxData);
Expand Down

0 comments on commit 4e86f74

Please sign in to comment.