@availity/hooks 5.2.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.ts +208 -0
- package/dist/index.js +156 -0
- package/package.json +25 -15
- package/project.json +14 -3
- package/src/index.ts +20 -0
- package/src/useCurrentRegion.ts +23 -0
- package/src/useCurrentUser.ts +24 -0
- package/src/useEffectAsync.ts +9 -0
- package/src/useMount.ts +6 -0
- package/src/useOrganizations.ts +73 -0
- package/src/usePermissions.ts +23 -0
- package/src/useProviders.ts +48 -0
- package/src/useStash.ts +21 -0
- package/src/{useTimeout.js → useTimeout.ts} +1 -1
- package/src/{useToggle.js → useToggle.ts} +2 -2
- package/src/{useUpdateNav.js → useUpdateNav.ts} +1 -1
- package/src/{useWindowDimensions.js → useWindowDimensions.ts} +9 -9
- package/stories/ResourceComponent.tsx +12 -10
- package/tests/useCurrentRegion.test.jsx +96 -0
- package/tests/useCurrentUser.test.jsx +94 -0
- package/tests/useEffectAsync.test.jsx +36 -0
- package/tests/useMount.test.jsx +24 -0
- package/tests/useOrganizations.test.jsx +112 -0
- package/tests/usePermissions.test.jsx +90 -0
- package/tests/useProviders.test.jsx +106 -0
- package/tests/useStash.test.jsx +89 -0
- package/tests/useTimeout.test.jsx +33 -0
- package/tests/useToggle.test.jsx +42 -0
- package/tests/useUpdateNav.test.jsx +46 -0
- package/tests/useWindowDimensions.test.jsx +38 -0
- package/vitest.config.ts +17 -0
- package/index.d.ts +0 -12
- package/index.js +0 -12
- package/jest.config.js +0 -7
- package/src/useCurrentRegion.js +0 -15
- package/src/useCurrentUser.js +0 -8
- package/src/useEffectAsync.js +0 -8
- package/src/useMount.js +0 -6
- package/src/useOrganizations.js +0 -8
- package/src/usePermissions.js +0 -8
- package/src/useProviders.js +0 -8
- package/src/useStash.js +0 -14
- package/tsconfig.spec.json +0 -10
- package/types/useCurrentRegion.d.ts +0 -12
- package/types/useCurrentUser.d.ts +0 -21
- package/types/useEffectAsync.d.ts +0 -3
- package/types/useMount.d.ts +0 -5
- package/types/useOrganizations.d.ts +0 -75
- package/types/usePermissions.d.ts +0 -22
- package/types/useProviders.d.ts +0 -50
- package/types/useStash.d.ts +0 -10
- package/types/useTimeout.d.ts +0 -3
- package/types/useToggle.d.ts +0 -3
- package/types/useUpdateNav.d.ts +0 -3
- package/types/useWindowDimensions.d.ts +0 -8
- /package/{types/aries.d.ts → src/types.ts} +0 -0
- /package/tests/{util.js → util.jsx} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { waitFor, cleanup } from '@testing-library/react';
|
|
4
|
+
import { avProvidersApi } from '@availity/api-axios';
|
|
5
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
import renderWithClient from './util';
|
|
7
|
+
import { useProviders } from '../src/index';
|
|
8
|
+
|
|
9
|
+
vi.mock('@availity/api-axios');
|
|
10
|
+
|
|
11
|
+
let queryStates = [];
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
queryStates = [];
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const queryClient = new QueryClient();
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
vi.clearAllMocks();
|
|
20
|
+
cleanup();
|
|
21
|
+
queryClient.clear();
|
|
22
|
+
queryStates = [];
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const pushState = (state) => {
|
|
26
|
+
queryStates.push(state);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const Component = ({ log }) => {
|
|
30
|
+
// Mirror testing methods from react-query instead of relying on timing or booleans
|
|
31
|
+
// https://github.com/tannerlinsley/react-query/blob/master/src/react/tests/useQuery.test.tsx
|
|
32
|
+
const state = useProviders({}, { gcTime: 0, retry: false });
|
|
33
|
+
|
|
34
|
+
// not directly used in assertions here, but useful for debugging purposes
|
|
35
|
+
if (log) log(state);
|
|
36
|
+
|
|
37
|
+
const { data, error, status } = state;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div>
|
|
41
|
+
<h1>Status: {status}</h1>
|
|
42
|
+
<h1>Data: {JSON.stringify(data)}</h1>
|
|
43
|
+
<h1>Error: {error}</h1>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Component.propTypes = {
|
|
49
|
+
log: PropTypes.func,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
describe('useProviders', () => {
|
|
53
|
+
test('should return an error', async () => {
|
|
54
|
+
avProvidersApi.getProviders.mockRejectedValueOnce('An error occurred');
|
|
55
|
+
|
|
56
|
+
const { getByText } = renderWithClient(queryClient, <Component log={pushState} />);
|
|
57
|
+
|
|
58
|
+
getByText('Status: pending');
|
|
59
|
+
await waitFor(() => {
|
|
60
|
+
const el = getByText('Status: error');
|
|
61
|
+
expect(el).toBeDefined();
|
|
62
|
+
});
|
|
63
|
+
await waitFor(() => {
|
|
64
|
+
const el = getByText('Error: An error occurred');
|
|
65
|
+
expect(el).toBeDefined();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('should return providers', async () => {
|
|
70
|
+
avProvidersApi.getProviders.mockResolvedValueOnce({
|
|
71
|
+
data: {
|
|
72
|
+
providers: [
|
|
73
|
+
{
|
|
74
|
+
id: 'test',
|
|
75
|
+
lastName: 'test',
|
|
76
|
+
firstName: 'test',
|
|
77
|
+
middleName: 'test',
|
|
78
|
+
uiDisplayName: 'test',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const { getByText } = renderWithClient(queryClient, <Component log={pushState} />);
|
|
85
|
+
|
|
86
|
+
getByText('Status: pending');
|
|
87
|
+
await waitFor(() => {
|
|
88
|
+
const el = getByText(
|
|
89
|
+
`Data: ${JSON.stringify({
|
|
90
|
+
data: {
|
|
91
|
+
providers: [
|
|
92
|
+
{
|
|
93
|
+
id: 'test',
|
|
94
|
+
lastName: 'test',
|
|
95
|
+
firstName: 'test',
|
|
96
|
+
middleName: 'test',
|
|
97
|
+
uiDisplayName: 'test',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
})}`
|
|
102
|
+
);
|
|
103
|
+
expect(el).toBeDefined();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { waitFor, cleanup } from '@testing-library/react';
|
|
4
|
+
import { avStashApi } from '@availity/api-axios';
|
|
5
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
import { vi, describe, test, expect, beforeEach, afterEach } from 'vitest';
|
|
7
|
+
import { useStash } from '../src';
|
|
8
|
+
import renderWithClient from './util';
|
|
9
|
+
|
|
10
|
+
vi.mock('@availity/api-axios', () => ({
|
|
11
|
+
avStashApi: { get: vi.fn() },
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
let queryStates = [];
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
queryStates = [];
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const queryClient = new QueryClient();
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
vi.clearAllMocks();
|
|
23
|
+
cleanup();
|
|
24
|
+
queryClient.clear();
|
|
25
|
+
queryStates = [];
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const pushState = (state) => {
|
|
29
|
+
queryStates.push(state);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const Component = ({ sessionId, log }) => {
|
|
33
|
+
const state = useStash(sessionId, { gcTime: 0, retry: false });
|
|
34
|
+
|
|
35
|
+
if (log) log(state);
|
|
36
|
+
|
|
37
|
+
const { data, error, status } = state;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div>
|
|
41
|
+
<h1>Status: {status}</h1>
|
|
42
|
+
<h1>Data: {JSON.stringify(data)}</h1>
|
|
43
|
+
<h1>Error: {error}</h1>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Component.propTypes = {
|
|
49
|
+
sessionId: PropTypes.string,
|
|
50
|
+
log: PropTypes.func,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
describe('useStash', () => {
|
|
54
|
+
test('should return an error', async () => {
|
|
55
|
+
avStashApi.get.mockRejectedValueOnce('An error occurred');
|
|
56
|
+
|
|
57
|
+
const { getByText } = renderWithClient(queryClient, <Component sessionId="test-session-id" log={pushState} />);
|
|
58
|
+
|
|
59
|
+
getByText('Status: pending');
|
|
60
|
+
await waitFor(() => {
|
|
61
|
+
const el = getByText('Status: error');
|
|
62
|
+
expect(el).toBeDefined();
|
|
63
|
+
});
|
|
64
|
+
await waitFor(() => {
|
|
65
|
+
const el = getByText('Error: An error occurred');
|
|
66
|
+
expect(el).toBeDefined();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('should return stash data', async () => {
|
|
71
|
+
const mockData = { key: 'value', nested: { foo: 'bar' } };
|
|
72
|
+
avStashApi.get.mockResolvedValueOnce({ data: mockData });
|
|
73
|
+
|
|
74
|
+
const { getByText } = renderWithClient(queryClient, <Component sessionId="test-session-id" log={pushState} />);
|
|
75
|
+
|
|
76
|
+
getByText('Status: pending');
|
|
77
|
+
await waitFor(() => {
|
|
78
|
+
const el = getByText(`Data: ${JSON.stringify(mockData)}`);
|
|
79
|
+
expect(el).toBeDefined();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('should not fetch when sessionId is empty', () => {
|
|
84
|
+
const { getByText } = renderWithClient(queryClient, <Component sessionId="" log={pushState} />);
|
|
85
|
+
|
|
86
|
+
getByText('Status: pending');
|
|
87
|
+
expect(avStashApi.get).not.toHaveBeenCalled();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitFor } from '@testing-library/react';
|
|
3
|
+
import { useTimeout } from '../src/index';
|
|
4
|
+
|
|
5
|
+
const Component = () => {
|
|
6
|
+
const timeout = useTimeout(1000);
|
|
7
|
+
|
|
8
|
+
return <p data-testid="timeout-test">{timeout ? 'True' : 'False'}</p>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
vi.useFakeTimers();
|
|
12
|
+
|
|
13
|
+
describe('useTimeout', () => {
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
vi.useRealTimers();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('should render "False"', () => {
|
|
19
|
+
const { getByTestId } = render(<Component />);
|
|
20
|
+
|
|
21
|
+
expect(getByTestId('timeout-test').textContent).toEqual('False');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test.todo('should render "True"', async () => {
|
|
25
|
+
const { getByTestId } = render(<Component />);
|
|
26
|
+
|
|
27
|
+
vi.runAllTimers();
|
|
28
|
+
|
|
29
|
+
await waitFor(() => {
|
|
30
|
+
expect(getByTestId('timeout-test').textContent).toEqual('True');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent, cleanup } from '@testing-library/react';
|
|
3
|
+
import { useToggle } from '../src/index';
|
|
4
|
+
|
|
5
|
+
afterEach(cleanup);
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line react/prop-types
|
|
8
|
+
const Component = ({ initialToggle = false }) => {
|
|
9
|
+
const [isToggled, toggle] = useToggle(initialToggle);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<button type="button" data-testid="toggle-test" onClick={toggle}>
|
|
13
|
+
{isToggled ? 'Hello' : 'World'}
|
|
14
|
+
</button>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('useToggle', () => {
|
|
19
|
+
test('should render "Hello"', () => {
|
|
20
|
+
const { getByTestId } = render(<Component />);
|
|
21
|
+
|
|
22
|
+
expect(getByTestId('toggle-test').textContent).toEqual('World');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('should render "World"', () => {
|
|
26
|
+
const { getByTestId } = render(<Component initialToggle />);
|
|
27
|
+
|
|
28
|
+
expect(getByTestId('toggle-test').textContent).toEqual('Hello');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('should toggle the state when clicked', () => {
|
|
32
|
+
const { getByTestId } = render(<Component />);
|
|
33
|
+
|
|
34
|
+
const button = getByTestId('toggle-test');
|
|
35
|
+
|
|
36
|
+
expect(button.textContent).toEqual('World');
|
|
37
|
+
|
|
38
|
+
fireEvent.click(button);
|
|
39
|
+
|
|
40
|
+
expect(getByTestId('toggle-test').textContent).toEqual('Hello');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
import { MemoryRouter, useNavigate, Routes, Route } from 'react-router-dom';
|
|
3
|
+
import avMessageMock from '@availity/message-core';
|
|
4
|
+
|
|
5
|
+
import useUpdateNav from '../src/useUpdateNav';
|
|
6
|
+
|
|
7
|
+
vi.mock('@availity/message-core');
|
|
8
|
+
|
|
9
|
+
const Component = () => {
|
|
10
|
+
const navigate = useNavigate();
|
|
11
|
+
|
|
12
|
+
useUpdateNav();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
onClick={() => {
|
|
18
|
+
navigate('/test');
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
Click
|
|
22
|
+
</button>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
describe('useUpdateNav', () => {
|
|
27
|
+
test.todo('calls avMessage on location change', () => {
|
|
28
|
+
render(
|
|
29
|
+
<MemoryRouter initialEntries={['/']}>
|
|
30
|
+
<Routes>
|
|
31
|
+
<Route path="/" element={<Component />} />
|
|
32
|
+
<Route path="/test" element={<div>Example</div>} />
|
|
33
|
+
</Routes>
|
|
34
|
+
</MemoryRouter>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const button = screen.getByText('Click');
|
|
38
|
+
|
|
39
|
+
fireEvent.click(button);
|
|
40
|
+
|
|
41
|
+
expect(avMessageMock.send).toHaveBeenCalledWith({
|
|
42
|
+
event: 'navChange',
|
|
43
|
+
url: 'http://localhost:3000/',
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitFor, act, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { useWindowDimensions } from '../src/index';
|
|
4
|
+
|
|
5
|
+
const Component = () => {
|
|
6
|
+
const { height, width } = useWindowDimensions();
|
|
7
|
+
return (
|
|
8
|
+
<div data-testid="window_dimensions">
|
|
9
|
+
{' '}
|
|
10
|
+
<span data-testid="window_height">{height}</span>
|
|
11
|
+
<span data-testid="window_width">{width}</span>
|
|
12
|
+
</div>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('useWindowDimensions', () => {
|
|
17
|
+
test('should show window dimensions', async () => {
|
|
18
|
+
const { getByTestId } = render(<Component />);
|
|
19
|
+
|
|
20
|
+
const element = getByTestId('window_dimensions');
|
|
21
|
+
expect(element).not.toBeNull();
|
|
22
|
+
|
|
23
|
+
act(() => {
|
|
24
|
+
window.innerWidth = 500;
|
|
25
|
+
window.innerHeight = 500;
|
|
26
|
+
|
|
27
|
+
fireEvent(window, new Event('resize'));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const heightEl = getByTestId('window_height');
|
|
31
|
+
const widthEl = getByTestId('window_width');
|
|
32
|
+
|
|
33
|
+
await waitFor(() => {
|
|
34
|
+
expect(heightEl.textContent).toBe('500');
|
|
35
|
+
expect(widthEl.textContent).toBe('500');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineProject } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
export default defineProject({
|
|
4
|
+
test: {
|
|
5
|
+
name: 'hooks',
|
|
6
|
+
globals: true,
|
|
7
|
+
environment: 'jsdom',
|
|
8
|
+
setupFiles: ['../../vitest.setup.ts'],
|
|
9
|
+
include: ['src/**/*.test.{ts,tsx,js,jsx}', 'tests/**/*.test.{ts,tsx,js,jsx}'],
|
|
10
|
+
env: { TZ: 'UTC' },
|
|
11
|
+
server: {
|
|
12
|
+
deps: {
|
|
13
|
+
inline: [/lodash/, /@availity\/yup/],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
package/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { default as useEffectAsync } from './types/useEffectAsync';
|
|
2
|
-
export { default as useMount } from './types/useMount';
|
|
3
|
-
export { default as useTimeout } from './types/useTimeout';
|
|
4
|
-
export { default as useToggle } from './types/useToggle';
|
|
5
|
-
export { default as useCurrentRegion } from './types/useCurrentRegion';
|
|
6
|
-
export { default as useCurrentUser } from './types/useCurrentUser';
|
|
7
|
-
export { default as useProviders } from './types/useProviders';
|
|
8
|
-
export { default as usePermissions } from './types/usePermissions';
|
|
9
|
-
export { default as useOrganizations } from './types/useOrganizations';
|
|
10
|
-
export { default as useUpdateNav } from './types/useUpdateNav';
|
|
11
|
-
export { default as useWindowDimensions } from './types/useWindowDimensions';
|
|
12
|
-
export { default as useStash } from './types/useStash';
|
package/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { default as useEffectAsync } from './src/useEffectAsync';
|
|
2
|
-
export { default as useMount } from './src/useMount';
|
|
3
|
-
export { default as useTimeout } from './src/useTimeout';
|
|
4
|
-
export { default as useToggle } from './src/useToggle';
|
|
5
|
-
export { default as useCurrentRegion } from './src/useCurrentRegion';
|
|
6
|
-
export { default as useCurrentUser } from './src/useCurrentUser';
|
|
7
|
-
export { default as useProviders } from './src/useProviders';
|
|
8
|
-
export { default as usePermissions } from './src/usePermissions';
|
|
9
|
-
export { default as useOrganizations } from './src/useOrganizations';
|
|
10
|
-
export { default as useUpdateNav } from './src/useUpdateNav';
|
|
11
|
-
export { default as useWindowDimensions } from './src/useWindowDimensions';
|
|
12
|
-
export { default as useStash } from './src/useStash';
|
package/jest.config.js
DELETED
package/src/useCurrentRegion.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { avRegionsApi } from '@availity/api-axios';
|
|
3
|
-
|
|
4
|
-
async function fetchRegion() {
|
|
5
|
-
const response = await avRegionsApi.getCurrentRegion();
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
code: response?.data?.regions?.[0]?.id || '',
|
|
9
|
-
value: response?.data?.regions?.[0]?.value || '',
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default function useCurrentRegion(options) {
|
|
14
|
-
return useQuery(['region'], fetchRegion, options);
|
|
15
|
-
}
|
package/src/useCurrentUser.js
DELETED
package/src/useEffectAsync.js
DELETED
package/src/useMount.js
DELETED
package/src/useOrganizations.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { avOrganizationsApi } from '@availity/api-axios';
|
|
3
|
-
|
|
4
|
-
const fetchOrganization = async (config) => avOrganizationsApi.getOrganizations(config);
|
|
5
|
-
|
|
6
|
-
export default function useOrganization(config, options) {
|
|
7
|
-
return useQuery(['organizations', config], () => fetchOrganization(config), options);
|
|
8
|
-
}
|
package/src/usePermissions.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { avPermissionsApi } from '@availity/api-axios';
|
|
3
|
-
|
|
4
|
-
const fetchPermissions = async (config) => avPermissionsApi.getPermissions(config);
|
|
5
|
-
|
|
6
|
-
export default function usePermissions(config, options) {
|
|
7
|
-
return useQuery(['permissions', config], () => fetchPermissions(config), options);
|
|
8
|
-
}
|
package/src/useProviders.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { avProvidersApi } from '@availity/api-axios';
|
|
3
|
-
|
|
4
|
-
const fetchProviders = async (config) => avProvidersApi.getProviders(config.customerId, config);
|
|
5
|
-
|
|
6
|
-
export default function useProviders(config, options) {
|
|
7
|
-
return useQuery(['providers', config], () => fetchProviders(config), options);
|
|
8
|
-
}
|
package/src/useStash.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { avStashApi } from '@availity/api-axios';
|
|
2
|
-
import { useQuery } from '@tanstack/react-query';
|
|
3
|
-
|
|
4
|
-
const fetchStash = async (sessionId) => {
|
|
5
|
-
const response = await avStashApi.get(sessionId);
|
|
6
|
-
return response?.data;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default function useStash(sessionId, options) {
|
|
10
|
-
return useQuery(['stash', sessionId], () => fetchStash(sessionId), {
|
|
11
|
-
enabled: !!sessionId,
|
|
12
|
-
...options,
|
|
13
|
-
});
|
|
14
|
-
}
|
package/tsconfig.spec.json
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../dist/out-tsc",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"types": ["jest", "node", "@testing-library/jest-dom"],
|
|
7
|
-
"allowJs": true
|
|
8
|
-
},
|
|
9
|
-
"include": ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
|
|
10
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
|
|
3
|
-
export type CurrentRegion = {
|
|
4
|
-
code: string;
|
|
5
|
-
value: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
declare function useCurrentRegion(
|
|
9
|
-
options?: UseQueryOptions<CurrentRegion, unknown>
|
|
10
|
-
): UseQueryResult<CurrentRegion, unknown>;
|
|
11
|
-
|
|
12
|
-
export default useCurrentRegion;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
|
|
3
|
-
export type CurrentUser = {
|
|
4
|
-
akaname: string;
|
|
5
|
-
createDate: string;
|
|
6
|
-
currentRegion: string;
|
|
7
|
-
email: string;
|
|
8
|
-
firstName: string;
|
|
9
|
-
lastName: string;
|
|
10
|
-
id: string;
|
|
11
|
-
jobTitle: string;
|
|
12
|
-
userHasSecurityException: boolean;
|
|
13
|
-
userId: string;
|
|
14
|
-
userValidated: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
declare function useCurrentUser(
|
|
18
|
-
options?: UseQueryOptions<CurrentUser, unknown>
|
|
19
|
-
): UseQueryResult<CurrentUser, unknown>;
|
|
20
|
-
|
|
21
|
-
export default useCurrentUser;
|
package/types/useMount.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import { AriesHookBase } from './aries';
|
|
4
|
-
|
|
5
|
-
interface OrganizationsBase {
|
|
6
|
-
data: {
|
|
7
|
-
organizations: [
|
|
8
|
-
{
|
|
9
|
-
links: {
|
|
10
|
-
permissions: { href: string };
|
|
11
|
-
patients: { href: string };
|
|
12
|
-
self: { href: string };
|
|
13
|
-
admin: { href: string };
|
|
14
|
-
businessArrangements: { href: string };
|
|
15
|
-
users: { href: string };
|
|
16
|
-
};
|
|
17
|
-
id: string;
|
|
18
|
-
customerId: string;
|
|
19
|
-
name: string;
|
|
20
|
-
status: string;
|
|
21
|
-
statusCode: string;
|
|
22
|
-
types: [{ code: string; value: string }];
|
|
23
|
-
|
|
24
|
-
primaryControllingAuthority: {
|
|
25
|
-
lastName: string;
|
|
26
|
-
firstName: string;
|
|
27
|
-
primaryPhone: string;
|
|
28
|
-
email: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
physicalAddress: {
|
|
32
|
-
line1: string;
|
|
33
|
-
city: string;
|
|
34
|
-
state: string;
|
|
35
|
-
stateCode: string;
|
|
36
|
-
zipCode: string;
|
|
37
|
-
};
|
|
38
|
-
mailingAddress: {
|
|
39
|
-
line1: string;
|
|
40
|
-
city: string;
|
|
41
|
-
state: string;
|
|
42
|
-
stateCode: string;
|
|
43
|
-
zipCode: string;
|
|
44
|
-
};
|
|
45
|
-
billingAddress: {
|
|
46
|
-
line1: string;
|
|
47
|
-
city: string;
|
|
48
|
-
state: string;
|
|
49
|
-
stateCode: string;
|
|
50
|
-
zipCode: string;
|
|
51
|
-
};
|
|
52
|
-
regions: { code: string; value: string }[];
|
|
53
|
-
npis: { number: string }[];
|
|
54
|
-
taxIds: { number: string; type: string }[];
|
|
55
|
-
|
|
56
|
-
phoneNumber: {
|
|
57
|
-
areaCode: string;
|
|
58
|
-
exchange: string;
|
|
59
|
-
phoneNumber: string;
|
|
60
|
-
};
|
|
61
|
-
numberOfLicensedPhysicians: string;
|
|
62
|
-
numberOfLicensedClinicians: string;
|
|
63
|
-
}
|
|
64
|
-
];
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
type Organizations = AriesHookBase & OrganizationsBase;
|
|
69
|
-
|
|
70
|
-
export declare function useOrganizations(
|
|
71
|
-
config: AxiosRequestConfig,
|
|
72
|
-
options?: UseQueryOptions<Organizations, unknown>
|
|
73
|
-
): UseQueryResult<Organizations, unknown>;
|
|
74
|
-
|
|
75
|
-
export default useOrganizations;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
import { AriesHookBase } from './aries';
|
|
4
|
-
|
|
5
|
-
export interface PermissionsBase {
|
|
6
|
-
data: {
|
|
7
|
-
permissions: {
|
|
8
|
-
id: string;
|
|
9
|
-
description: string;
|
|
10
|
-
links: { self: { href: string } };
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type Permissions = AriesHookBase & PermissionsBase;
|
|
16
|
-
|
|
17
|
-
declare function usePermissions(
|
|
18
|
-
config: AxiosRequestConfig,
|
|
19
|
-
options?: UseQueryOptions<Permissions, unknown>
|
|
20
|
-
): UseQueryResult<Permissions, unknown>;
|
|
21
|
-
|
|
22
|
-
export default usePermissions;
|