@makana-cl/portal-internal-client 1.2.3
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/README.md +404 -0
- package/dist/client/apollo-client.d.ts +25 -0
- package/dist/client/apollo-client.d.ts.map +1 -0
- package/dist/client/apollo-client.js +93 -0
- package/dist/client/apollo-client.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js/client/apollo-client.d.ts +25 -0
- package/dist/index.esm.js/client/apollo-client.d.ts.map +1 -0
- package/dist/index.esm.js/client/apollo-client.js +90 -0
- package/dist/index.esm.js/client/apollo-client.js.map +1 -0
- package/dist/index.esm.js/index.d.ts +22 -0
- package/dist/index.esm.js/index.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/client/apollo-client.d.ts +25 -0
- package/dist/index.esm.js/index.esm.js.tmp/client/apollo-client.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/client/apollo-client.js +90 -0
- package/dist/index.esm.js/index.esm.js.tmp/client/apollo-client.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/index.d.ts +22 -0
- package/dist/index.esm.js/index.esm.js.tmp/index.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/index.js +21 -0
- package/dist/index.esm.js/index.esm.js.tmp/index.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/businesses.d.ts +37 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/businesses.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/businesses.js +82 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/businesses.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/index.d.ts +5 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/index.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/index.js +5 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/index.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/searchBusinesses.d.ts +64 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/searchBusinesses.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/searchBusinesses.js +97 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/searchBusinesses.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/users.d.ts +51 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/users.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/users.js +138 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/users.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/usersLight.d.ts +63 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/usersLight.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/usersLight.js +90 -0
- package/dist/index.esm.js/index.esm.js.tmp/queries/usersLight.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/business.d.ts +20 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/business.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/business.js +2 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/business.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/common.d.ts +45 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/common.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/common.js +2 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/common.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/department.d.ts +6 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/department.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/department.js +2 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/department.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/group.d.ts +9 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/group.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/group.js +2 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/group.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/index.d.ts +6 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/index.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/index.js +6 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/index.js.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/user.d.ts +61 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/user.d.ts.map +1 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/user.js +7 -0
- package/dist/index.esm.js/index.esm.js.tmp/types/user.js.map +1 -0
- package/dist/index.esm.js/index.js +21 -0
- package/dist/index.esm.js/index.js.map +1 -0
- package/dist/index.esm.js/queries/businesses.d.ts +37 -0
- package/dist/index.esm.js/queries/businesses.d.ts.map +1 -0
- package/dist/index.esm.js/queries/businesses.js +82 -0
- package/dist/index.esm.js/queries/businesses.js.map +1 -0
- package/dist/index.esm.js/queries/index.d.ts +5 -0
- package/dist/index.esm.js/queries/index.d.ts.map +1 -0
- package/dist/index.esm.js/queries/index.js +5 -0
- package/dist/index.esm.js/queries/index.js.map +1 -0
- package/dist/index.esm.js/queries/searchBusinesses.d.ts +64 -0
- package/dist/index.esm.js/queries/searchBusinesses.d.ts.map +1 -0
- package/dist/index.esm.js/queries/searchBusinesses.js +97 -0
- package/dist/index.esm.js/queries/searchBusinesses.js.map +1 -0
- package/dist/index.esm.js/queries/users.d.ts +51 -0
- package/dist/index.esm.js/queries/users.d.ts.map +1 -0
- package/dist/index.esm.js/queries/users.js +138 -0
- package/dist/index.esm.js/queries/users.js.map +1 -0
- package/dist/index.esm.js/queries/usersLight.d.ts +63 -0
- package/dist/index.esm.js/queries/usersLight.d.ts.map +1 -0
- package/dist/index.esm.js/queries/usersLight.js +90 -0
- package/dist/index.esm.js/queries/usersLight.js.map +1 -0
- package/dist/index.esm.js/types/business.d.ts +20 -0
- package/dist/index.esm.js/types/business.d.ts.map +1 -0
- package/dist/index.esm.js/types/business.js +2 -0
- package/dist/index.esm.js/types/business.js.map +1 -0
- package/dist/index.esm.js/types/common.d.ts +45 -0
- package/dist/index.esm.js/types/common.d.ts.map +1 -0
- package/dist/index.esm.js/types/common.js +2 -0
- package/dist/index.esm.js/types/common.js.map +1 -0
- package/dist/index.esm.js/types/department.d.ts +6 -0
- package/dist/index.esm.js/types/department.d.ts.map +1 -0
- package/dist/index.esm.js/types/department.js +2 -0
- package/dist/index.esm.js/types/department.js.map +1 -0
- package/dist/index.esm.js/types/group.d.ts +9 -0
- package/dist/index.esm.js/types/group.d.ts.map +1 -0
- package/dist/index.esm.js/types/group.js +2 -0
- package/dist/index.esm.js/types/group.js.map +1 -0
- package/dist/index.esm.js/types/index.d.ts +6 -0
- package/dist/index.esm.js/types/index.d.ts.map +1 -0
- package/dist/index.esm.js/types/index.js +6 -0
- package/dist/index.esm.js/types/index.js.map +1 -0
- package/dist/index.esm.js/types/user.d.ts +61 -0
- package/dist/index.esm.js/types/user.d.ts.map +1 -0
- package/dist/index.esm.js/types/user.js +7 -0
- package/dist/index.esm.js/types/user.js.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/queries/businesses.d.ts +37 -0
- package/dist/queries/businesses.d.ts.map +1 -0
- package/dist/queries/businesses.js +86 -0
- package/dist/queries/businesses.js.map +1 -0
- package/dist/queries/index.d.ts +5 -0
- package/dist/queries/index.d.ts.map +1 -0
- package/dist/queries/index.js +21 -0
- package/dist/queries/index.js.map +1 -0
- package/dist/queries/searchBusinesses.d.ts +64 -0
- package/dist/queries/searchBusinesses.d.ts.map +1 -0
- package/dist/queries/searchBusinesses.js +101 -0
- package/dist/queries/searchBusinesses.js.map +1 -0
- package/dist/queries/users.d.ts +51 -0
- package/dist/queries/users.d.ts.map +1 -0
- package/dist/queries/users.js +142 -0
- package/dist/queries/users.js.map +1 -0
- package/dist/queries/usersLight.d.ts +63 -0
- package/dist/queries/usersLight.d.ts.map +1 -0
- package/dist/queries/usersLight.js +94 -0
- package/dist/queries/usersLight.js.map +1 -0
- package/dist/types/business.d.ts +20 -0
- package/dist/types/business.d.ts.map +1 -0
- package/dist/types/business.js +3 -0
- package/dist/types/business.js.map +1 -0
- package/dist/types/common.d.ts +45 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +3 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/department.d.ts +6 -0
- package/dist/types/department.d.ts.map +1 -0
- package/dist/types/department.js +3 -0
- package/dist/types/department.js.map +1 -0
- package/dist/types/group.d.ts +9 -0
- package/dist/types/group.d.ts.map +1 -0
- package/dist/types/group.js +3 -0
- package/dist/types/group.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +22 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/user.d.ts +61 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +10 -0
- package/dist/types/user.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @makana-cl/portal-internal-client
|
|
3
|
+
*
|
|
4
|
+
* GraphQL client library for Makana Portal internal applications.
|
|
5
|
+
* Provides React hooks and Apollo Client setup for querying Makana GraphQL API.
|
|
6
|
+
*/
|
|
7
|
+
export { createMakanaClient } from './client/apollo-client';
|
|
8
|
+
export type { MakanaClientConfig } from './client/apollo-client';
|
|
9
|
+
export { useGetUsers } from './queries/users';
|
|
10
|
+
export type { FetchUsersVariables, FetchUsersResponse } from './queries/users';
|
|
11
|
+
export { useGetUsersLight } from './queries/usersLight';
|
|
12
|
+
export type { FetchUsersLightVariables, FetchUsersLightResponse, UserLightNode } from './queries/usersLight';
|
|
13
|
+
export { useGetBusinesses } from './queries/businesses';
|
|
14
|
+
export type { FetchBusinessesResponse } from './queries/businesses';
|
|
15
|
+
export { useSearchBusinesses } from './queries/searchBusinesses';
|
|
16
|
+
export type { SearchBusinessesVariables, SearchBusinessesResponse } from './queries/searchBusinesses';
|
|
17
|
+
export { GET_USERS } from './queries/users';
|
|
18
|
+
export { GET_USERS_LIGHT } from './queries/usersLight';
|
|
19
|
+
export { GET_BUSINESSES } from './queries/businesses';
|
|
20
|
+
export { SEARCH_BUSINESSES } from './queries/searchBusinesses';
|
|
21
|
+
export * from './types';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGtG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApolloClient } from '@apollo/client';
|
|
2
|
+
export interface MakanaClientConfig {
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
getToken: () => string | null | Promise<string | null>;
|
|
5
|
+
onError?: (error: Error) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates a configured Apollo Client instance for Makana GraphQL API
|
|
9
|
+
*
|
|
10
|
+
* @param config - Configuration object
|
|
11
|
+
* @param config.apiUrl - The GraphQL API endpoint URL (e.g., 'https://api.makana.cl/graphql')
|
|
12
|
+
* @param config.getToken - Function that returns the JWT token for authentication
|
|
13
|
+
* @param config.onError - Optional error handler callback
|
|
14
|
+
* @returns Configured Apollo Client instance
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const client = createMakanaClient({
|
|
19
|
+
* apiUrl: 'https://api.makana.cl/graphql',
|
|
20
|
+
* getToken: () => localStorage.getItem('jwt_token')
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createMakanaClient(config: MakanaClientConfig): ApolloClient<any>;
|
|
25
|
+
//# sourceMappingURL=apollo-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client.d.ts","sourceRoot":"","sources":["../../../src/client/apollo-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuC,MAAM,gBAAgB,CAAC;AAInF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAAC,GAAG,CAAC,CA2EhF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ApolloClient, InMemoryCache, createHttpLink, from } from '@apollo/client';
|
|
2
|
+
import { setContext } from '@apollo/client/link/context';
|
|
3
|
+
import { onError } from '@apollo/client/link/error';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a configured Apollo Client instance for Makana GraphQL API
|
|
6
|
+
*
|
|
7
|
+
* @param config - Configuration object
|
|
8
|
+
* @param config.apiUrl - The GraphQL API endpoint URL (e.g., 'https://api.makana.cl/graphql')
|
|
9
|
+
* @param config.getToken - Function that returns the JWT token for authentication
|
|
10
|
+
* @param config.onError - Optional error handler callback
|
|
11
|
+
* @returns Configured Apollo Client instance
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const client = createMakanaClient({
|
|
16
|
+
* apiUrl: 'https://api.makana.cl/graphql',
|
|
17
|
+
* getToken: () => localStorage.getItem('jwt_token')
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function createMakanaClient(config) {
|
|
22
|
+
const httpLink = createHttpLink({
|
|
23
|
+
uri: config.apiUrl,
|
|
24
|
+
});
|
|
25
|
+
const authLink = setContext(async (_, { headers }) => {
|
|
26
|
+
const token = await config.getToken();
|
|
27
|
+
return {
|
|
28
|
+
headers: {
|
|
29
|
+
...headers,
|
|
30
|
+
authorization: token ? `Bearer ${token}` : '',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const errorLink = onError(({ graphQLErrors, networkError, operation, forward }) => {
|
|
35
|
+
if (graphQLErrors) {
|
|
36
|
+
graphQLErrors.forEach(({ message, locations, path }) => {
|
|
37
|
+
console.error(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
|
|
38
|
+
if (config.onError) {
|
|
39
|
+
config.onError(new Error(message));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (networkError) {
|
|
44
|
+
console.error(`[Network error]: ${networkError}`);
|
|
45
|
+
if (config.onError) {
|
|
46
|
+
config.onError(networkError);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return new ApolloClient({
|
|
51
|
+
link: from([errorLink, authLink, httpLink]),
|
|
52
|
+
cache: new InMemoryCache({
|
|
53
|
+
typePolicies: {
|
|
54
|
+
Query: {
|
|
55
|
+
fields: {
|
|
56
|
+
fetchUsers: {
|
|
57
|
+
keyArgs: ['filters', 'sort'],
|
|
58
|
+
merge(existing, incoming) {
|
|
59
|
+
return incoming;
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
fetchBusinesses: {
|
|
63
|
+
keyArgs: ['filters'],
|
|
64
|
+
merge(existing, incoming) {
|
|
65
|
+
return incoming;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
searchBusinesses: {
|
|
69
|
+
keyArgs: ['searchTerm', 'sort', 'fromDate', 'toDate'],
|
|
70
|
+
merge(existing, incoming) {
|
|
71
|
+
return incoming;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
defaultOptions: {
|
|
79
|
+
watchQuery: {
|
|
80
|
+
fetchPolicy: 'cache-first',
|
|
81
|
+
errorPolicy: 'all',
|
|
82
|
+
},
|
|
83
|
+
query: {
|
|
84
|
+
fetchPolicy: 'cache-first',
|
|
85
|
+
errorPolicy: 'all',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=apollo-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apollo-client.js","sourceRoot":"","sources":["../../../src/client/apollo-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAQpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,MAAM,QAAQ,GAAG,cAAc,CAAC;QAC9B,GAAG,EAAE,MAAM,CAAC,MAAM;KACnB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACnD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QAEtC,OAAO;YACL,OAAO,EAAE;gBACP,GAAG,OAAO;gBACV,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE;aAC9C;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE;QAChF,IAAI,aAAa,EAAE,CAAC;YAClB,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE;gBACrD,OAAO,CAAC,KAAK,CACX,6BAA6B,OAAO,eAAe,SAAS,WAAW,IAAI,EAAE,CAC9E,CAAC;gBACF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;oBACnB,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,oBAAoB,YAAY,EAAE,CAAC,CAAC;YAClD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,YAAY,CAAC;QACtB,IAAI,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC3C,KAAK,EAAE,IAAI,aAAa,CAAC;YACvB,YAAY,EAAE;gBACZ,KAAK,EAAE;oBACL,MAAM,EAAE;wBACN,UAAU,EAAE;4BACV,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;4BAC5B,KAAK,CAAC,QAAQ,EAAE,QAAQ;gCACtB,OAAO,QAAQ,CAAC;4BAClB,CAAC;yBACF;wBACD,eAAe,EAAE;4BACf,OAAO,EAAE,CAAC,SAAS,CAAC;4BACpB,KAAK,CAAC,QAAQ,EAAE,QAAQ;gCACtB,OAAO,QAAQ,CAAC;4BAClB,CAAC;yBACF;wBACD,gBAAgB,EAAE;4BAChB,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC;4BACrD,KAAK,CAAC,QAAQ,EAAE,QAAQ;gCACtB,OAAO,QAAQ,CAAC;4BAClB,CAAC;yBACF;qBACF;iBACF;aACF;SACF,CAAC;QACF,cAAc,EAAE;YACd,UAAU,EAAE;gBACV,WAAW,EAAE,aAAa;gBAC1B,WAAW,EAAE,KAAK;aACnB;YACD,KAAK,EAAE;gBACL,WAAW,EAAE,aAAa;gBAC1B,WAAW,EAAE,KAAK;aACnB;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @makana-cl/portal-internal-client
|
|
3
|
+
*
|
|
4
|
+
* GraphQL client library for Makana Portal internal applications.
|
|
5
|
+
* Provides React hooks and Apollo Client setup for querying Makana GraphQL API.
|
|
6
|
+
*/
|
|
7
|
+
export { createMakanaClient } from './client/apollo-client';
|
|
8
|
+
export type { MakanaClientConfig } from './client/apollo-client';
|
|
9
|
+
export { useGetUsers } from './queries/users';
|
|
10
|
+
export type { FetchUsersVariables, FetchUsersResponse } from './queries/users';
|
|
11
|
+
export { useGetUsersLight } from './queries/usersLight';
|
|
12
|
+
export type { FetchUsersLightVariables, FetchUsersLightResponse, UserLightNode } from './queries/usersLight';
|
|
13
|
+
export { useGetBusinesses } from './queries/businesses';
|
|
14
|
+
export type { FetchBusinessesResponse } from './queries/businesses';
|
|
15
|
+
export { useSearchBusinesses } from './queries/searchBusinesses';
|
|
16
|
+
export type { SearchBusinessesVariables, SearchBusinessesResponse } from './queries/searchBusinesses';
|
|
17
|
+
export { GET_USERS } from './queries/users';
|
|
18
|
+
export { GET_USERS_LIGHT } from './queries/usersLight';
|
|
19
|
+
export { GET_BUSINESSES } from './queries/businesses';
|
|
20
|
+
export { SEARCH_BUSINESSES } from './queries/searchBusinesses';
|
|
21
|
+
export * from './types';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGtG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @makana-cl/portal-internal-client
|
|
3
|
+
*
|
|
4
|
+
* GraphQL client library for Makana Portal internal applications.
|
|
5
|
+
* Provides React hooks and Apollo Client setup for querying Makana GraphQL API.
|
|
6
|
+
*/
|
|
7
|
+
// Client setup
|
|
8
|
+
export { createMakanaClient } from './client/apollo-client';
|
|
9
|
+
// Query hooks
|
|
10
|
+
export { useGetUsers } from './queries/users';
|
|
11
|
+
export { useGetUsersLight } from './queries/usersLight';
|
|
12
|
+
export { useGetBusinesses } from './queries/businesses';
|
|
13
|
+
export { useSearchBusinesses } from './queries/searchBusinesses';
|
|
14
|
+
// GraphQL queries (for advanced usage)
|
|
15
|
+
export { GET_USERS } from './queries/users';
|
|
16
|
+
export { GET_USERS_LIGHT } from './queries/usersLight';
|
|
17
|
+
export { GET_BUSINESSES } from './queries/businesses';
|
|
18
|
+
export { SEARCH_BUSINESSES } from './queries/searchBusinesses';
|
|
19
|
+
// Types
|
|
20
|
+
export * from './types';
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe;AACf,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,cAAc;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,QAAQ;AACR,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { QueryHookOptions } from '@apollo/client';
|
|
2
|
+
import { Business } from '../types/business';
|
|
3
|
+
import { BaseQueryVariables, Connection } from '../types/common';
|
|
4
|
+
export declare const GET_BUSINESSES: import("@apollo/client").DocumentNode;
|
|
5
|
+
export interface FetchBusinessesResponse {
|
|
6
|
+
fetchBusinesses: Connection<Business>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* React hook to fetch businesses from Makana GraphQL API
|
|
10
|
+
*
|
|
11
|
+
* @param variables - Query variables (filters, pagination, etc.)
|
|
12
|
+
* @param options - Additional Apollo Client query options
|
|
13
|
+
* @returns Object containing businesses data, loading state, error, and refetch function
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const { businesses, loading, error } = useGetBusinesses({
|
|
18
|
+
* filters: { groupId: '456' },
|
|
19
|
+
* first: 20
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function useGetBusinesses(variables?: BaseQueryVariables, options?: Omit<QueryHookOptions<FetchBusinessesResponse, BaseQueryVariables>, 'variables'>): {
|
|
24
|
+
businesses: Business[];
|
|
25
|
+
totalCount: number;
|
|
26
|
+
pageInfo: import("../types/common").PageInfo | null;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
error: import("@apollo/client").ApolloError | undefined;
|
|
29
|
+
fetchMore: <TFetchData = FetchBusinessesResponse, TFetchVars extends import("@apollo/client").OperationVariables = BaseQueryVariables>(fetchMoreOptions: import("@apollo/client").FetchMoreQueryOptions<TFetchVars, TFetchData> & {
|
|
30
|
+
updateQuery?: ((previousQueryResult: FetchBusinessesResponse, options: {
|
|
31
|
+
fetchMoreResult: import("@apollo/client").Unmasked<TFetchData>;
|
|
32
|
+
variables: TFetchVars;
|
|
33
|
+
}) => FetchBusinessesResponse) | undefined;
|
|
34
|
+
}) => Promise<import("@apollo/client").ApolloQueryResult<TFetchData>>;
|
|
35
|
+
refetch: (variables?: Partial<BaseQueryVariables> | undefined) => Promise<import("@apollo/client").ApolloQueryResult<FetchBusinessesResponse>>;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=businesses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"businesses.d.ts","sourceRoot":"","sources":["../../../src/queries/businesses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEjE,eAAO,MAAM,cAAc,uCA6C1B,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,GAAE,kBAAuB,EAClC,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,EAAE,WAAW,CAAC;;;;;;;;;;;;;EAwB3F"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { gql, useQuery } from '@apollo/client';
|
|
2
|
+
export const GET_BUSINESSES = gql `
|
|
3
|
+
query FetchBusinesses(
|
|
4
|
+
$filters: FilterInput
|
|
5
|
+
$first: Int
|
|
6
|
+
$last: Int
|
|
7
|
+
$after: String
|
|
8
|
+
$before: String
|
|
9
|
+
) {
|
|
10
|
+
fetchBusinesses(
|
|
11
|
+
filters: $filters
|
|
12
|
+
first: $first
|
|
13
|
+
last: $last
|
|
14
|
+
after: $after
|
|
15
|
+
before: $before
|
|
16
|
+
) {
|
|
17
|
+
totalCount
|
|
18
|
+
edges {
|
|
19
|
+
node {
|
|
20
|
+
id
|
|
21
|
+
name
|
|
22
|
+
schedule
|
|
23
|
+
defaultDepartment
|
|
24
|
+
reservationLimit
|
|
25
|
+
reservationDuration
|
|
26
|
+
status
|
|
27
|
+
totalUsers
|
|
28
|
+
createdAt
|
|
29
|
+
dailyStaff
|
|
30
|
+
totalStaff
|
|
31
|
+
monthlyRecurrentRevenewUf
|
|
32
|
+
subdomain
|
|
33
|
+
parentGroup {
|
|
34
|
+
id
|
|
35
|
+
name
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
pageInfo {
|
|
40
|
+
hasNextPage
|
|
41
|
+
hasPreviousPage
|
|
42
|
+
startCursor
|
|
43
|
+
endCursor
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
/**
|
|
49
|
+
* React hook to fetch businesses from Makana GraphQL API
|
|
50
|
+
*
|
|
51
|
+
* @param variables - Query variables (filters, pagination, etc.)
|
|
52
|
+
* @param options - Additional Apollo Client query options
|
|
53
|
+
* @returns Object containing businesses data, loading state, error, and refetch function
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const { businesses, loading, error } = useGetBusinesses({
|
|
58
|
+
* filters: { groupId: '456' },
|
|
59
|
+
* first: 20
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function useGetBusinesses(variables = {}, options) {
|
|
64
|
+
const { loading, error, data, fetchMore, refetch } = useQuery(GET_BUSINESSES, {
|
|
65
|
+
variables,
|
|
66
|
+
fetchPolicy: 'cache-first',
|
|
67
|
+
...options,
|
|
68
|
+
});
|
|
69
|
+
const businesses = data?.fetchBusinesses?.edges.map((edge) => edge.node) || [];
|
|
70
|
+
const totalCount = data?.fetchBusinesses?.totalCount || 0;
|
|
71
|
+
const pageInfo = data?.fetchBusinesses?.pageInfo || null;
|
|
72
|
+
return {
|
|
73
|
+
businesses,
|
|
74
|
+
totalCount,
|
|
75
|
+
pageInfo,
|
|
76
|
+
loading,
|
|
77
|
+
error,
|
|
78
|
+
fetchMore,
|
|
79
|
+
refetch,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=businesses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"businesses.js","sourceRoot":"","sources":["../../../src/queries/businesses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAoB,MAAM,gBAAgB,CAAC;AAIjE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ChC,CAAC;AAMF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAC9B,YAAgC,EAAE,EAClC,OAA0F;IAE1F,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,QAAQ,CAG3D,cAAc,EAAE;QAChB,SAAS;QACT,WAAW,EAAE,aAAa;QAC1B,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,IAAI,EAAE,eAAe,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC/E,MAAM,UAAU,GAAG,IAAI,EAAE,eAAe,EAAE,UAAU,IAAI,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,IAAI,EAAE,eAAe,EAAE,QAAQ,IAAI,IAAI,CAAC;IAEzD,OAAO;QACL,UAAU;QACV,UAAU;QACV,QAAQ;QACR,OAAO;QACP,KAAK;QACL,SAAS;QACT,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queries/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/queries/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { QueryHookOptions } from '@apollo/client';
|
|
2
|
+
import { Business } from '../types/business';
|
|
3
|
+
import { SortInput, PageInfo } from '../types/common';
|
|
4
|
+
export declare const SEARCH_BUSINESSES: import("@apollo/client").DocumentNode;
|
|
5
|
+
export interface SearchBusinessesVariables {
|
|
6
|
+
searchTerm?: string;
|
|
7
|
+
sort?: SortInput;
|
|
8
|
+
page?: number;
|
|
9
|
+
pageSize?: number;
|
|
10
|
+
fromDate?: string;
|
|
11
|
+
toDate?: string;
|
|
12
|
+
skip?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface SearchBusinessesResponse {
|
|
15
|
+
searchBusinesses: {
|
|
16
|
+
totalBusinesses: number;
|
|
17
|
+
businesses: {
|
|
18
|
+
totalCount: number;
|
|
19
|
+
edges: {
|
|
20
|
+
node: Business & {
|
|
21
|
+
totalAttentions?: number;
|
|
22
|
+
};
|
|
23
|
+
}[];
|
|
24
|
+
pageInfo: PageInfo;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* React hook to search businesses from Makana GraphQL API
|
|
30
|
+
*
|
|
31
|
+
* @param variables - Query variables (search term, sort, pagination, date filters)
|
|
32
|
+
* @param options - Additional Apollo Client query options
|
|
33
|
+
* @returns Object containing businesses data, loading state, error, and refetch function
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const { businesses, totalBusinesses, loading, error } = useSearchBusinesses({
|
|
38
|
+
* searchTerm: 'Makana',
|
|
39
|
+
* sort: { sortBy: 'name', sortOrder: 'ASC' },
|
|
40
|
+
* page: 0,
|
|
41
|
+
* pageSize: 25,
|
|
42
|
+
* fromDate: '2024-01-01',
|
|
43
|
+
* toDate: '2024-12-31'
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function useSearchBusinesses(variables?: SearchBusinessesVariables, options?: Omit<QueryHookOptions<SearchBusinessesResponse, SearchBusinessesVariables>, 'variables'>): {
|
|
48
|
+
businesses: (Business & {
|
|
49
|
+
totalAttentions?: number;
|
|
50
|
+
})[];
|
|
51
|
+
totalCount: number;
|
|
52
|
+
totalBusinesses: number;
|
|
53
|
+
pageInfo: PageInfo | null;
|
|
54
|
+
loading: boolean;
|
|
55
|
+
error: import("@apollo/client").ApolloError | undefined;
|
|
56
|
+
refetch: (variables?: Partial<SearchBusinessesVariables> | undefined) => Promise<import("@apollo/client").ApolloQueryResult<SearchBusinessesResponse>>;
|
|
57
|
+
fetchMore: <TFetchData = SearchBusinessesResponse, TFetchVars extends import("@apollo/client").OperationVariables = SearchBusinessesVariables>(fetchMoreOptions: import("@apollo/client").FetchMoreQueryOptions<TFetchVars, TFetchData> & {
|
|
58
|
+
updateQuery?: ((previousQueryResult: SearchBusinessesResponse, options: {
|
|
59
|
+
fetchMoreResult: import("@apollo/client").Unmasked<TFetchData>;
|
|
60
|
+
variables: TFetchVars;
|
|
61
|
+
}) => SearchBusinessesResponse) | undefined;
|
|
62
|
+
}) => Promise<import("@apollo/client").ApolloQueryResult<TFetchData>>;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=searchBusinesses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchBusinesses.d.ts","sourceRoot":"","sources":["../../../src/queries/searchBusinesses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtD,eAAO,MAAM,iBAAiB,uCAoD7B,CAAC;AAEF,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,gBAAgB,EAAE;QAChB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE;YACV,UAAU,EAAE,MAAM,CAAC;YACnB,KAAK,EAAE;gBAAE,IAAI,EAAE,QAAQ,GAAG;oBAAE,eAAe,CAAC,EAAE,MAAM,CAAA;iBAAE,CAAA;aAAE,EAAE,CAAC;YAC3D,QAAQ,EAAE,QAAQ,CAAC;SACpB,CAAC;KACH,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,GAAE,yBAA8B,EACzC,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,EAAE,WAAW,CAAC;;0BA3BhD,MAAM;;;;;;;;;;;;;;EAwDzD"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { gql, useQuery } from '@apollo/client';
|
|
2
|
+
export const SEARCH_BUSINESSES = gql `
|
|
3
|
+
query SearchBusinesses(
|
|
4
|
+
$searchTerm: String
|
|
5
|
+
$sort: SortInput
|
|
6
|
+
$page: Int
|
|
7
|
+
$pageSize: Int
|
|
8
|
+
$fromDate: String
|
|
9
|
+
$toDate: String
|
|
10
|
+
) {
|
|
11
|
+
searchBusinesses(
|
|
12
|
+
searchTerm: $searchTerm
|
|
13
|
+
sort: $sort
|
|
14
|
+
page: $page
|
|
15
|
+
pageSize: $pageSize
|
|
16
|
+
fromDate: $fromDate
|
|
17
|
+
toDate: $toDate
|
|
18
|
+
) {
|
|
19
|
+
totalBusinesses
|
|
20
|
+
businesses {
|
|
21
|
+
totalCount
|
|
22
|
+
edges {
|
|
23
|
+
node {
|
|
24
|
+
id
|
|
25
|
+
name
|
|
26
|
+
status
|
|
27
|
+
totalUsers
|
|
28
|
+
totalAttentions(fromDate: $fromDate, toDate: $toDate)
|
|
29
|
+
createdAt
|
|
30
|
+
updatedAt
|
|
31
|
+
defaultDepartment
|
|
32
|
+
schedule
|
|
33
|
+
reservationLimit
|
|
34
|
+
reservationDuration
|
|
35
|
+
dailyStaff
|
|
36
|
+
totalStaff
|
|
37
|
+
monthlyRecurrentRevenewUf
|
|
38
|
+
subdomain
|
|
39
|
+
parentGroup {
|
|
40
|
+
id
|
|
41
|
+
name
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
pageInfo {
|
|
46
|
+
hasNextPage
|
|
47
|
+
hasPreviousPage
|
|
48
|
+
startCursor
|
|
49
|
+
endCursor
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
/**
|
|
56
|
+
* React hook to search businesses from Makana GraphQL API
|
|
57
|
+
*
|
|
58
|
+
* @param variables - Query variables (search term, sort, pagination, date filters)
|
|
59
|
+
* @param options - Additional Apollo Client query options
|
|
60
|
+
* @returns Object containing businesses data, loading state, error, and refetch function
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const { businesses, totalBusinesses, loading, error } = useSearchBusinesses({
|
|
65
|
+
* searchTerm: 'Makana',
|
|
66
|
+
* sort: { sortBy: 'name', sortOrder: 'ASC' },
|
|
67
|
+
* page: 0,
|
|
68
|
+
* pageSize: 25,
|
|
69
|
+
* fromDate: '2024-01-01',
|
|
70
|
+
* toDate: '2024-12-31'
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function useSearchBusinesses(variables = {}, options) {
|
|
75
|
+
const { skip, ...queryVariables } = variables;
|
|
76
|
+
const { loading, error, data, refetch, fetchMore } = useQuery(SEARCH_BUSINESSES, {
|
|
77
|
+
variables: queryVariables,
|
|
78
|
+
fetchPolicy: 'cache-first',
|
|
79
|
+
skip: skip === true,
|
|
80
|
+
...options,
|
|
81
|
+
});
|
|
82
|
+
const businesses = data?.searchBusinesses?.businesses.edges.map((edge) => edge.node) || [];
|
|
83
|
+
const totalCount = data?.searchBusinesses?.businesses.totalCount || 0;
|
|
84
|
+
const totalBusinesses = data?.searchBusinesses?.totalBusinesses || 0;
|
|
85
|
+
const pageInfo = data?.searchBusinesses?.businesses.pageInfo || null;
|
|
86
|
+
return {
|
|
87
|
+
businesses,
|
|
88
|
+
totalCount,
|
|
89
|
+
totalBusinesses,
|
|
90
|
+
pageInfo,
|
|
91
|
+
loading,
|
|
92
|
+
error,
|
|
93
|
+
refetch,
|
|
94
|
+
fetchMore,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=searchBusinesses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchBusinesses.js","sourceRoot":"","sources":["../../../src/queries/searchBusinesses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAoB,MAAM,gBAAgB,CAAC;AAIjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDnC,CAAC;AAuBF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAuC,EAAE,EACzC,OAAkG;IAElG,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,GAAG,SAAS,CAAC;IAE9C,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,CAG3D,iBAAiB,EAAE;QACnB,SAAS,EAAE,cAAc;QACzB,WAAW,EAAE,aAAa;QAC1B,IAAI,EAAE,IAAI,KAAK,IAAI;QACnB,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,IAAI,EAAE,gBAAgB,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC3F,MAAM,UAAU,GAAG,IAAI,EAAE,gBAAgB,EAAE,UAAU,CAAC,UAAU,IAAI,CAAC,CAAC;IACtE,MAAM,eAAe,GAAG,IAAI,EAAE,gBAAgB,EAAE,eAAe,IAAI,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,IAAI,EAAE,gBAAgB,EAAE,UAAU,CAAC,QAAQ,IAAI,IAAI,CAAC;IAErE,OAAO;QACL,UAAU;QACV,UAAU;QACV,eAAe;QACf,QAAQ;QACR,OAAO;QACP,KAAK;QACL,OAAO;QACP,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { QueryHookOptions } from '@apollo/client';
|
|
2
|
+
import { User } from '../types/user';
|
|
3
|
+
import { FilterInput, SortInput, Connection } from '../types/common';
|
|
4
|
+
export declare const GET_USERS: import("@apollo/client").DocumentNode;
|
|
5
|
+
export interface FetchUsersVariables {
|
|
6
|
+
userId?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
rut?: string;
|
|
9
|
+
phone?: string;
|
|
10
|
+
filters?: FilterInput;
|
|
11
|
+
sort?: SortInput;
|
|
12
|
+
first?: number;
|
|
13
|
+
last?: number;
|
|
14
|
+
after?: string | null;
|
|
15
|
+
before?: string | null;
|
|
16
|
+
includeInactive?: boolean;
|
|
17
|
+
skip?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface FetchUsersResponse {
|
|
20
|
+
fetchUsers: Connection<User>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* React hook to fetch users from Makana GraphQL API
|
|
24
|
+
*
|
|
25
|
+
* @param variables - Query variables (filters, pagination, etc.)
|
|
26
|
+
* @param options - Additional Apollo Client query options
|
|
27
|
+
* @returns Object containing users data, loading state, error, and refetch function
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const { users, loading, error, refetch } = useGetUsers({
|
|
32
|
+
* filters: { businessId: '123' },
|
|
33
|
+
* first: 10
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function useGetUsers(variables?: FetchUsersVariables, options?: Omit<QueryHookOptions<FetchUsersResponse, FetchUsersVariables>, 'variables'>): {
|
|
38
|
+
users: User[];
|
|
39
|
+
totalCount: number;
|
|
40
|
+
pageInfo: import("../types/common").PageInfo | null;
|
|
41
|
+
loading: boolean;
|
|
42
|
+
error: import("@apollo/client").ApolloError | undefined;
|
|
43
|
+
fetchMore: <TFetchData = FetchUsersResponse, TFetchVars extends import("@apollo/client").OperationVariables = FetchUsersVariables>(fetchMoreOptions: import("@apollo/client").FetchMoreQueryOptions<TFetchVars, TFetchData> & {
|
|
44
|
+
updateQuery?: ((previousQueryResult: FetchUsersResponse, options: {
|
|
45
|
+
fetchMoreResult: import("@apollo/client").Unmasked<TFetchData>;
|
|
46
|
+
variables: TFetchVars;
|
|
47
|
+
}) => FetchUsersResponse) | undefined;
|
|
48
|
+
}) => Promise<import("@apollo/client").ApolloQueryResult<TFetchData>>;
|
|
49
|
+
refetch: (variables?: Partial<FetchUsersVariables> | undefined) => Promise<import("@apollo/client").ApolloQueryResult<FetchUsersResponse>>;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/queries/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAErE,eAAO,MAAM,SAAS,uCAmGrB,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CACzB,SAAS,GAAE,mBAAwB,EACnC,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,mBAAmB,CAAC,EAAE,WAAW,CAAC;;;;;;;;;;;;;EA2BvF"}
|