Skip to content

Commit

Permalink
Connect to authToken with Onyx.connect
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Jul 26, 2024
1 parent 7e9f4ce commit 7617d0c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/libs/actions/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Onyx from 'react-native-onyx';
import * as API from '@libs/API';
import type {CreateWorkspaceApprovalParams, RemoveWorkspaceApprovalParams, UpdateWorkspaceApprovalParams} from '@libs/API/parameters';
import {WRITE_COMMANDS} from '@libs/API/types';
import * as NetworkStore from '@libs/Network/NetworkStore';
import {convertApprovalWorkflowToPolicyEmployees} from '@libs/WorkflowUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import type {ApprovalWorkflow, Policy} from '@src/types/onyx';
Expand All @@ -24,8 +23,15 @@ Onyx.connect({
callback: (value) => (allPolicies = value),
});

let authToken: string | undefined;
Onyx.connect({
key: ONYXKEYS.SESSION,
callback: (value) => {
authToken = value?.authToken;
},
});

function createApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWorkflow) {
const authToken = NetworkStore.getAuthToken();
if (!authToken) {
return;
}
Expand Down Expand Up @@ -74,7 +80,6 @@ function createApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork
}

function updateApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWorkflow) {
const authToken = NetworkStore.getAuthToken();
if (!authToken) {
return;
}
Expand Down Expand Up @@ -123,7 +128,6 @@ function updateApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork
}

function removeApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWorkflow) {
const authToken = NetworkStore.getAuthToken();
if (!authToken) {
return;
}
Expand Down

0 comments on commit 7617d0c

Please sign in to comment.