diff --git a/packages/authorize/src/api.test.ts b/packages/authorize/src/api.test.ts index a7d82e6cb3..a55b864cc7 100644 --- a/packages/authorize/src/api.test.ts +++ b/packages/authorize/src/api.test.ts @@ -16,9 +16,9 @@ describe('authorize api', () => { expect(region).toBe('FL'); }); - test('getRegion returns undefined when given falsey value', async () => { + test('getRegion returns null when given falsey value', async () => { const region = await getRegion(false); - expect(region).toBeUndefined(); + expect(region).toBeNull(); }); test('getRegion returns value when not falsey', async () => { diff --git a/packages/authorize/src/api.ts b/packages/authorize/src/api.ts index 3a1aae1628..81af036b5c 100644 --- a/packages/authorize/src/api.ts +++ b/packages/authorize/src/api.ts @@ -7,14 +7,14 @@ import type { Permission, RequestedPermissions, RequestedResources } from './typ * * If the region is a string then it will be returned without fetching. */ -export const getRegion = async (region?: boolean | string): Promise => { +export const getRegion = async (region?: boolean | string): Promise => { if (region === true) { const resp = await avRegionsApi.getCurrentRegion(); - return resp?.data?.regions?.[0]?.id; + return resp?.data?.regions?.[0]?.id || null; } - return region || undefined; + return region || null; }; /** @@ -22,12 +22,12 @@ export const getRegion = async (region?: boolean | string): Promise> => { if (!permissions) return {}; // TODO: fix these types - const response = await avUserPermissionsApi.getPermissions(permissions as string[], region); + const response = await avUserPermissionsApi.getPermissions(permissions as string[], region || undefined); return response.reduce>((prev, cur) => { prev[cur.id] = cur; @@ -91,7 +91,7 @@ export const checkPermission = ( */ export const checkPermissions = async ( permissions: RequestedPermissions, - region?: string, + region?: string | null, resources?: RequestedResources, organizationId?: string, customerId?: string