@planningcenter/chat-react-native 3.3.0 → 3.4.0-rc.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.
Files changed (48) hide show
  1. package/build/hooks/services/use_find_or_create_services_conversation.d.ts +9 -0
  2. package/build/hooks/services/use_find_or_create_services_conversation.d.ts.map +1 -0
  3. package/build/hooks/services/use_find_or_create_services_conversation.js +72 -0
  4. package/build/hooks/services/use_find_or_create_services_conversation.js.map +1 -0
  5. package/build/hooks/services/use_team_members_for_new_conversation.d.ts +176 -0
  6. package/build/hooks/services/use_team_members_for_new_conversation.d.ts.map +1 -0
  7. package/build/hooks/services/use_team_members_for_new_conversation.js +29 -0
  8. package/build/hooks/services/use_team_members_for_new_conversation.js.map +1 -0
  9. package/build/hooks/services/use_team_plans.d.ts +8 -0
  10. package/build/hooks/services/use_team_plans.d.ts.map +1 -0
  11. package/build/hooks/services/use_team_plans.js +37 -0
  12. package/build/hooks/services/use_team_plans.js.map +1 -0
  13. package/build/hooks/services/use_teams_i_lead.d.ts +8 -0
  14. package/build/hooks/services/use_teams_i_lead.d.ts.map +1 -0
  15. package/build/hooks/services/use_teams_i_lead.js +34 -0
  16. package/build/hooks/services/use_teams_i_lead.js.map +1 -0
  17. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts +1 -1
  18. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts.map +1 -1
  19. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.js +4 -28
  20. package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.js.map +1 -1
  21. package/build/screens/conversation_new/components/filter_by_plan_options.d.ts +8 -0
  22. package/build/screens/conversation_new/components/filter_by_plan_options.d.ts.map +1 -0
  23. package/build/screens/conversation_new/components/filter_by_plan_options.js +37 -0
  24. package/build/screens/conversation_new/components/filter_by_plan_options.js.map +1 -0
  25. package/build/screens/conversation_new/components/services_form.d.ts +8 -0
  26. package/build/screens/conversation_new/components/services_form.d.ts.map +1 -0
  27. package/build/screens/conversation_new/components/services_form.js +137 -0
  28. package/build/screens/conversation_new/components/services_form.js.map +1 -0
  29. package/build/screens/conversation_new/conversation_new_screen.js +2 -2
  30. package/build/screens/conversation_new/conversation_new_screen.js.map +1 -1
  31. package/build/types/resources/services/team_resource.d.ts +6 -3
  32. package/build/types/resources/services/team_resource.d.ts.map +1 -1
  33. package/build/types/resources/services/team_resource.js.map +1 -1
  34. package/package.json +2 -2
  35. package/src/hooks/services/use_find_or_create_services_conversation.ts +97 -0
  36. package/src/hooks/services/use_team_members_for_new_conversation.ts +40 -0
  37. package/src/hooks/services/use_team_plans.ts +42 -0
  38. package/src/hooks/services/use_teams_i_lead.ts +44 -0
  39. package/src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts +5 -48
  40. package/src/screens/conversation_new/components/filter_by_plan_options.tsx +64 -0
  41. package/src/screens/conversation_new/components/services_form.tsx +229 -0
  42. package/src/screens/conversation_new/conversation_new_screen.tsx +2 -2
  43. package/src/types/resources/services/team_resource.ts +7 -3
  44. package/build/screens/conversation_new/components/team_form.d.ts +0 -8
  45. package/build/screens/conversation_new/components/team_form.d.ts.map +0 -1
  46. package/build/screens/conversation_new/components/team_form.js +0 -11
  47. package/build/screens/conversation_new/components/team_form.js.map +0 -1
  48. package/src/screens/conversation_new/components/team_form.tsx +0 -18
@@ -0,0 +1,9 @@
1
+ import { ConversationResource } from '../../types';
2
+ interface Props {
3
+ teamIds: number[];
4
+ planId?: number;
5
+ onSuccess?: (conversation: ConversationResource) => void;
6
+ }
7
+ export declare function useFindOrCreateServicesConversation({ teamIds, planId, onSuccess }: Props): import("@tanstack/react-query").UseMutationResult<ConversationResource, Error, void, unknown>;
8
+ export {};
9
+ //# sourceMappingURL=use_find_or_create_services_conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_find_or_create_services_conversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/services/use_find_or_create_services_conversation.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,oBAAoB,EAGrB,MAAM,aAAa,CAAA;AAGpB,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,oBAAoB,KAAK,IAAI,CAAA;CACzD;AAED,wBAAgB,mCAAmC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,iGA6BxF"}
@@ -0,0 +1,72 @@
1
+ import { useMutation } from '@tanstack/react-query';
2
+ import { useApiClient } from '../use_api_client';
3
+ export function useFindOrCreateServicesConversation({ teamIds, planId, onSuccess }) {
4
+ const teamAndPlanParams = {
5
+ team_id: teamIds.join(','),
6
+ ...(planId ? { plan_id: planId } : {}),
7
+ };
8
+ const apiClient = useApiClient();
9
+ return useMutation({
10
+ throwOnError: true,
11
+ onSuccess: result => {
12
+ onSuccess && onSuccess(result);
13
+ },
14
+ mutationFn: async () => {
15
+ const foundConversations = await getGroupIdsFromServices(apiClient, teamAndPlanParams)
16
+ .then(res => res.data.groupIdentifiers)
17
+ .then(groupIdentifiers => findConversationWithExactTeams(apiClient, groupIdentifiers))
18
+ .catch(() => null);
19
+ const foundConversation = foundConversations?.data[0];
20
+ if (foundConversation?.id) {
21
+ return foundConversation;
22
+ }
23
+ return fetchServicesPayload(apiClient, teamAndPlanParams)
24
+ .then(res => res.data.payload)
25
+ .then(payload => createConversation(apiClient, payload))
26
+ .then(res => res.data);
27
+ },
28
+ });
29
+ }
30
+ function fetchServicesPayload(apiClient, teamAndPlanParams) {
31
+ return apiClient.services.get({
32
+ url: `/chat`,
33
+ data: {
34
+ ...teamAndPlanParams,
35
+ fields: {
36
+ Chat: ['payload'],
37
+ },
38
+ },
39
+ });
40
+ }
41
+ function getGroupIdsFromServices(apiClient, teamAndPlanParams) {
42
+ return apiClient.services.get({
43
+ url: '/chat',
44
+ data: {
45
+ ...teamAndPlanParams,
46
+ fields: {
47
+ Chat: ['group_identifiers'],
48
+ },
49
+ },
50
+ });
51
+ }
52
+ function findConversationWithExactTeams(apiClient, groupIdentifiers) {
53
+ return apiClient.chat.get({
54
+ url: '/me/conversations',
55
+ data: {
56
+ fields: {
57
+ Conversation: ['stream_channel'],
58
+ },
59
+ filter: 'with_exact_groups',
60
+ gids: groupIdentifiers.join(','),
61
+ },
62
+ });
63
+ }
64
+ function createConversation(apiClient, payload) {
65
+ return apiClient.chat.post({
66
+ url: '/me/conversations',
67
+ data: {
68
+ data: { type: 'Conversation', attributes: { payload } },
69
+ },
70
+ });
71
+ }
72
+ //# sourceMappingURL=use_find_or_create_services_conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_find_or_create_services_conversation.js","sourceRoot":"","sources":["../../../src/hooks/services/use_find_or_create_services_conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAQnD,OAAO,EAAa,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAQ3D,MAAM,UAAU,mCAAmC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAS;IACvF,MAAM,iBAAiB,GAAsB;QAC3C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvC,CAAA;IAED,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,OAAO,WAAW,CAAC;QACjB,YAAY,EAAE,IAAI;QAClB,SAAS,EAAE,MAAM,CAAC,EAAE;YAClB,SAAS,IAAI,SAAS,CAAC,MAAM,CAAC,CAAA;QAChC,CAAC;QACD,UAAU,EAAE,KAAK,IAAI,EAAE;YACrB,MAAM,kBAAkB,GAAG,MAAM,uBAAuB,CAAC,SAAS,EAAE,iBAAiB,CAAC;iBACnF,I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ED,SAAS,8BAA8B,CAAC,SAAoB,EAAE,gBAA0B;IACtF,OAAO,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;QACxB,GAAG,EAAE,mBAAmB;QACxB,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,YAAY,EAAE,CAAC,gBAAgB,CAAC;aACjC;YACD,MAAM,EAAE,mBAAmB;YAC3B,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;SACjC;KACF,CAAiD,CAAA;AACpD,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAoB,EAAE,OAAe;IAC/D,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QACzB,GAAG,EAAE,mBAAmB;QACxB,IAAI,EAAE;YACJ,IAAI,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,EAAE;SACxD;KACF,CAA+C,CAAA;AAClD,CAAC","sourcesContent":["import { useMutation } from '@tanstack/react-query'\nimport {\n ApiCollection,\n ApiResource,\n ConversationResource,\n ServicesChatGroupIdentifiersResource,\n ServicesChatPayloadResource,\n} from '../../types'\nimport { ApiClient, useApiClient } from '../use_api_client'\n\ninterface Props {\n teamIds: number[]\n planId?: number\n onSuccess?: (conversation: ConversationResource) => void\n}\n\nexport function useFindOrCreateServicesConversation({ teamIds, planId, onSuccess }: Props) {\n const teamAndPlanParams: TeamAndPlanParams = {\n team_id: teamIds.join(','),\n ...(planId ? { plan_id: planId } : {}),\n }\n\n const apiClient = useApiClient()\n return useMutation({\n throwOnError: true,\n onSuccess: result => {\n onSuccess && onSuccess(result)\n },\n mutationFn: async () => {\n const foundConversations = await getGroupIdsFromServices(apiClient, teamAndPlanParams)\n .then(res => res.data.groupIdentifiers)\n .then(groupIdentifiers => findConversationWithExactTeams(apiClient, groupIdentifiers))\n .catch(() => null)\n const foundConversation = foundConversations?.data[0]\n\n if (foundConversation?.id) {\n return foundConversation\n }\n\n return fetchServicesPayload(apiClient, teamAndPlanParams)\n .then(res => res.data.payload)\n .then(payload => createConversation(apiClient, payload))\n .then(res => res.data)\n },\n })\n}\n\ninterface TeamAndPlanParams {\n plan_id?: number | undefined\n team_id: string\n}\n\nfunction fetchServicesPayload(apiClient: ApiClient, teamAndPlanParams: TeamAndPlanParams) {\n return apiClient.services.get({\n url: `/chat`,\n data: {\n ...teamAndPlanParams,\n fields: {\n Chat: ['payload'],\n },\n },\n }) as Promise<ApiResource<ServicesChatPayloadResource>>\n}\n\nfunction getGroupIdsFromServices(apiClient: ApiClient, teamAndPlanParams: TeamAndPlanParams) {\n return apiClient.services.get({\n url: '/chat',\n data: {\n ...teamAndPlanParams,\n fields: {\n Chat: ['group_identifiers'],\n },\n },\n }) as Promise<ApiResource<ServicesChatGroupIdentifiersResource>>\n}\n\nfunction findConversationWithExactTeams(apiClient: ApiClient, groupIdentifiers: string[]) {\n return apiClient.chat.get({\n url: '/me/conversations',\n data: {\n fields: {\n Conversation: ['stream_channel'],\n },\n filter: 'with_exact_groups',\n gids: groupIdentifiers.join(','),\n },\n }) as Promise<ApiCollection<ConversationResource>>\n}\n\nfunction createConversation(apiClient: ApiClient, payload: string) {\n return apiClient.chat.post({\n url: '/me/conversations',\n data: {\n data: { type: 'Conversation', attributes: { payload } },\n },\n }) as Promise<ApiResource<ConversationResource>>\n}\n"]}
@@ -0,0 +1,176 @@
1
+ import { MemberResource, TeamPeopleResource } from '../../types';
2
+ interface Props {
3
+ teamIds: number[];
4
+ planId?: number;
5
+ }
6
+ export declare function useTeamMembersForNewConversation({ teamIds, planId }: Props): {
7
+ error: import("../../types").ApiError;
8
+ isError: true;
9
+ isPending: false;
10
+ isLoading: false;
11
+ isLoadingError: false;
12
+ isRefetchError: true;
13
+ isSuccess: false;
14
+ isPlaceholderData: false;
15
+ status: "error";
16
+ dataUpdatedAt: number;
17
+ errorUpdatedAt: number;
18
+ failureCount: number;
19
+ failureReason: import("../../types").ApiError | null;
20
+ errorUpdateCount: number;
21
+ isFetched: boolean;
22
+ isFetchedAfterMount: boolean;
23
+ isFetching: boolean;
24
+ isInitialLoading: boolean;
25
+ isPaused: boolean;
26
+ isRefetching: boolean;
27
+ isStale: boolean;
28
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("../../types").ApiResource<TeamPeopleResource>, import("../../types").ApiError>>;
29
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
30
+ promise: Promise<import("../../types").ApiResource<TeamPeopleResource>>;
31
+ links?: Record<string, string> | undefined;
32
+ meta?: Record<string, unknown> | undefined;
33
+ members: MemberResource[];
34
+ } | {
35
+ error: null;
36
+ isError: false;
37
+ isPending: false;
38
+ isLoading: false;
39
+ isLoadingError: false;
40
+ isRefetchError: false;
41
+ isSuccess: true;
42
+ isPlaceholderData: false;
43
+ status: "success";
44
+ dataUpdatedAt: number;
45
+ errorUpdatedAt: number;
46
+ failureCount: number;
47
+ failureReason: import("../../types").ApiError | null;
48
+ errorUpdateCount: number;
49
+ isFetched: boolean;
50
+ isFetchedAfterMount: boolean;
51
+ isFetching: boolean;
52
+ isInitialLoading: boolean;
53
+ isPaused: boolean;
54
+ isRefetching: boolean;
55
+ isStale: boolean;
56
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("../../types").ApiResource<TeamPeopleResource>, import("../../types").ApiError>>;
57
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
58
+ promise: Promise<import("../../types").ApiResource<TeamPeopleResource>>;
59
+ links?: Record<string, string> | undefined;
60
+ meta?: Record<string, unknown> | undefined;
61
+ members: MemberResource[];
62
+ } | {
63
+ error: import("../../types").ApiError;
64
+ isError: true;
65
+ isPending: false;
66
+ isLoading: false;
67
+ isLoadingError: true;
68
+ isRefetchError: false;
69
+ isSuccess: false;
70
+ isPlaceholderData: false;
71
+ status: "error";
72
+ dataUpdatedAt: number;
73
+ errorUpdatedAt: number;
74
+ failureCount: number;
75
+ failureReason: import("../../types").ApiError | null;
76
+ errorUpdateCount: number;
77
+ isFetched: boolean;
78
+ isFetchedAfterMount: boolean;
79
+ isFetching: boolean;
80
+ isInitialLoading: boolean;
81
+ isPaused: boolean;
82
+ isRefetching: boolean;
83
+ isStale: boolean;
84
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("../../types").ApiResource<TeamPeopleResource>, import("../../types").ApiError>>;
85
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
86
+ promise: Promise<import("../../types").ApiResource<TeamPeopleResource>>;
87
+ links?: Record<string, string> | undefined;
88
+ meta?: Record<string, unknown> | undefined;
89
+ members: MemberResource[];
90
+ } | {
91
+ error: null;
92
+ isError: false;
93
+ isPending: true;
94
+ isLoading: true;
95
+ isLoadingError: false;
96
+ isRefetchError: false;
97
+ isSuccess: false;
98
+ isPlaceholderData: false;
99
+ status: "pending";
100
+ dataUpdatedAt: number;
101
+ errorUpdatedAt: number;
102
+ failureCount: number;
103
+ failureReason: import("../../types").ApiError | null;
104
+ errorUpdateCount: number;
105
+ isFetched: boolean;
106
+ isFetchedAfterMount: boolean;
107
+ isFetching: boolean;
108
+ isInitialLoading: boolean;
109
+ isPaused: boolean;
110
+ isRefetching: boolean;
111
+ isStale: boolean;
112
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("../../types").ApiResource<TeamPeopleResource>, import("../../types").ApiError>>;
113
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
114
+ promise: Promise<import("../../types").ApiResource<TeamPeopleResource>>;
115
+ links?: Record<string, string> | undefined;
116
+ meta?: Record<string, unknown> | undefined;
117
+ members: MemberResource[];
118
+ } | {
119
+ error: null;
120
+ isError: false;
121
+ isPending: true;
122
+ isLoadingError: false;
123
+ isRefetchError: false;
124
+ isSuccess: false;
125
+ isPlaceholderData: false;
126
+ status: "pending";
127
+ dataUpdatedAt: number;
128
+ errorUpdatedAt: number;
129
+ failureCount: number;
130
+ failureReason: import("../../types").ApiError | null;
131
+ errorUpdateCount: number;
132
+ isFetched: boolean;
133
+ isFetchedAfterMount: boolean;
134
+ isFetching: boolean;
135
+ isLoading: boolean;
136
+ isInitialLoading: boolean;
137
+ isPaused: boolean;
138
+ isRefetching: boolean;
139
+ isStale: boolean;
140
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("../../types").ApiResource<TeamPeopleResource>, import("../../types").ApiError>>;
141
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
142
+ promise: Promise<import("../../types").ApiResource<TeamPeopleResource>>;
143
+ links?: Record<string, string> | undefined;
144
+ meta?: Record<string, unknown> | undefined;
145
+ members: MemberResource[];
146
+ } | {
147
+ isError: false;
148
+ error: null;
149
+ isPending: false;
150
+ isLoading: false;
151
+ isLoadingError: false;
152
+ isRefetchError: false;
153
+ isSuccess: true;
154
+ isPlaceholderData: true;
155
+ status: "success";
156
+ dataUpdatedAt: number;
157
+ errorUpdatedAt: number;
158
+ failureCount: number;
159
+ failureReason: import("../../types").ApiError | null;
160
+ errorUpdateCount: number;
161
+ isFetched: boolean;
162
+ isFetchedAfterMount: boolean;
163
+ isFetching: boolean;
164
+ isInitialLoading: boolean;
165
+ isPaused: boolean;
166
+ isRefetching: boolean;
167
+ isStale: boolean;
168
+ refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<import("../../types").ApiResource<TeamPeopleResource>, import("../../types").ApiError>>;
169
+ fetchStatus: import("@tanstack/query-core").FetchStatus;
170
+ promise: Promise<import("../../types").ApiResource<TeamPeopleResource>>;
171
+ links?: Record<string, string> | undefined;
172
+ meta?: Record<string, unknown> | undefined;
173
+ members: MemberResource[];
174
+ };
175
+ export {};
176
+ //# sourceMappingURL=use_team_members_for_new_conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_team_members_for_new_conversation.d.ts","sourceRoot":"","sources":["../../../src/hooks/services/use_team_members_for_new_conversation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAA0B,MAAM,aAAa,CAAA;AAGxF,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,gCAAgC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2B1E"}
@@ -0,0 +1,29 @@
1
+ import { isNil, omitBy } from 'lodash';
2
+ import { useApiGet } from '../use_api';
3
+ import { useMemo } from 'react';
4
+ export function useTeamMembersForNewConversation({ teamIds, planId }) {
5
+ const params = omitBy({ team_id: teamIds.join(','), plan_id: planId }, isNil);
6
+ const { data, ...rest } = useApiGet({
7
+ url: '/chat',
8
+ data: {
9
+ ...params,
10
+ fields: {
11
+ Chat: ['people'],
12
+ },
13
+ },
14
+ app: 'services',
15
+ });
16
+ const people = data?.people || stableEmptyPersonArray;
17
+ const members = useMemo(() => {
18
+ return people.map(person => ({
19
+ ...person,
20
+ type: 'Member',
21
+ }));
22
+ }, [people]);
23
+ return {
24
+ members,
25
+ ...rest,
26
+ };
27
+ }
28
+ const stableEmptyPersonArray = [];
29
+ //# sourceMappingURL=use_team_members_for_new_conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_team_members_for_new_conversation.js","sourceRoot":"","sources":["../../../src/hooks/services/use_team_members_for_new_conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAO/B,MAAM,UAAU,gCAAgC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAS;IACzE,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAA;IAE7E,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,SAAS,CAAqB;QACtD,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE;YACJ,GAAG,MAAM;YACT,MAAM,EAAE;gBACN,IAAI,EAAE,CAAC,QAAQ,CAAC;aACjB;SACF;QACD,GAAG,EAAE,UAAU;KAChB,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,sBAAsB,CAAA;IAErD,MAAM,OAAO,GAAqB,OAAO,CAAC,GAAG,EAAE;QAC7C,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC3B,GAAG,MAAM;YACT,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC,CAAA;IACL,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAEZ,OAAO;QACL,OAAO;QACP,GAAG,IAAI;KACR,CAAA;AACH,CAAC;AAED,MAAM,sBAAsB,GAA6B,EAAE,CAAA","sourcesContent":["import { isNil, omitBy } from 'lodash'\nimport { useApiGet } from '../use_api'\nimport { MemberResource, TeamPeopleResource, TeamPersonResponseItem } from '../../types'\nimport { useMemo } from 'react'\n\ninterface Props {\n teamIds: number[]\n planId?: number\n}\n\nexport function useTeamMembersForNewConversation({ teamIds, planId }: Props) {\n const params = omitBy({ team_id: teamIds.join(','), plan_id: planId }, isNil)\n\n const { data, ...rest } = useApiGet<TeamPeopleResource>({\n url: '/chat',\n data: {\n ...params,\n fields: {\n Chat: ['people'],\n },\n },\n app: 'services',\n })\n\n const people = data?.people || stableEmptyPersonArray\n\n const members: MemberResource[] = useMemo(() => {\n return people.map(person => ({\n ...person,\n type: 'Member',\n }))\n }, [people])\n\n return {\n members,\n ...rest,\n }\n}\n\nconst stableEmptyPersonArray: TeamPersonResponseItem[] = []\n"]}
@@ -0,0 +1,8 @@
1
+ export declare function useTeamPlans({ teamIds }: {
2
+ teamIds: number[];
3
+ }): {
4
+ planOptions: import("../../types").PlansResponseItem[];
5
+ isFetching: boolean;
6
+ isError: boolean;
7
+ };
8
+ //# sourceMappingURL=use_team_plans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_team_plans.d.ts","sourceRoot":"","sources":["../../../src/hooks/services/use_team_plans.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE;;;;EAqB9D"}
@@ -0,0 +1,37 @@
1
+ import { useApiClient } from '../use_api_client';
2
+ import { useMemo } from 'react';
3
+ import { useQueries } from '@tanstack/react-query';
4
+ import { uniqBy } from 'lodash';
5
+ export function useTeamPlans({ teamIds }) {
6
+ const apiClient = useApiClient();
7
+ const planQueries = useQueries({
8
+ queries: teamIds.map(teamId => ({
9
+ queryKey: ['plansForTeam', teamId],
10
+ queryFn: () => fetchTeamPlans(apiClient, teamId),
11
+ initialData: NULL_RESPONSE,
12
+ retry: false,
13
+ })),
14
+ });
15
+ const uniqPlanOptions = useMemo(() => {
16
+ const planOptions = planQueries.flatMap(({ data }) => data?.data.plans).filter(p => !!p);
17
+ return uniqBy(planOptions, 'value');
18
+ }, [planQueries]);
19
+ return {
20
+ planOptions: uniqPlanOptions,
21
+ isFetching: planQueries.some(({ isFetching }) => isFetching),
22
+ isError: planQueries.some(({ isError }) => isError),
23
+ };
24
+ }
25
+ const NULL_RESPONSE = { data: { id: 0, plans: [], type: 'Chat' }, links: {}, meta: {} };
26
+ function fetchTeamPlans(apiClient, teamId) {
27
+ return apiClient.services.get({
28
+ url: '/chat',
29
+ data: {
30
+ team_id: teamId,
31
+ fields: {
32
+ Chat: ['plans'],
33
+ },
34
+ },
35
+ });
36
+ }
37
+ //# sourceMappingURL=use_team_plans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_team_plans.js","sourceRoot":"","sources":["../../../src/hooks/services/use_team_plans.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,EAAyB;IAC7D,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,WAAW,GAAG,UAAU,CAAC;QAC7B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC9B,QAAQ,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC;YAClC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC;YAChD,WAAW,EAAE,aAAa;YAC1B,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;KACJ,CAAC,CAAA;IAEF,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE;QACnC,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACxF,OAAO,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAEjB,OAAO;QACL,WAAW,EAAE,eAAe;QAC5B,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC;QAC5D,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC;KACpD,CAAA;AACH,CAAC;AAED,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAA;AAEvF,SAAS,cAAc,CAAC,SAAoB,EAAE,MAAc;IAC1D,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,CAA6B;QACxD,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM;YACf,MAAM,EAAE;gBACN,IAAI,EAAE,CAAC,OAAO,CAAC;aAChB;SACF;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { ApiResource, PlansResource } from '../../types'\nimport { ApiClient, useApiClient } from '../use_api_client'\nimport { useMemo } from 'react'\nimport { useQueries } from '@tanstack/react-query'\nimport { uniqBy } from 'lodash'\n\nexport function useTeamPlans({ teamIds }: { teamIds: number[] }) {\n const apiClient = useApiClient()\n const planQueries = useQueries({\n queries: teamIds.map(teamId => ({\n queryKey: ['plansForTeam', teamId],\n queryFn: () => fetchTeamPlans(apiClient, teamId),\n initialData: NULL_RESPONSE,\n retry: false,\n })),\n })\n\n const uniqPlanOptions = useMemo(() => {\n const planOptions = planQueries.flatMap(({ data }) => data?.data.plans).filter(p => !!p)\n return uniqBy(planOptions, 'value')\n }, [planQueries])\n\n return {\n planOptions: uniqPlanOptions,\n isFetching: planQueries.some(({ isFetching }) => isFetching),\n isError: planQueries.some(({ isError }) => isError),\n }\n}\n\nconst NULL_RESPONSE = { data: { id: 0, plans: [], type: 'Chat' }, links: {}, meta: {} }\n\nfunction fetchTeamPlans(apiClient: ApiClient, teamId: number) {\n return apiClient.services.get<ApiResource<PlansResource>>({\n url: '/chat',\n data: {\n team_id: teamId,\n fields: {\n Chat: ['plans'],\n },\n },\n })\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { TeamResponseItem } from '../../types';
2
+ export declare function useTeamsILead(): {
3
+ teamsILead: TeamResponseItem[];
4
+ isFetching: boolean;
5
+ isError: boolean;
6
+ noServicesAccess: boolean;
7
+ };
8
+ //# sourceMappingURL=use_teams_i_lead.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_teams_i_lead.d.ts","sourceRoot":"","sources":["../../../src/hooks/services/use_teams_i_lead.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9D,wBAAgB,aAAa;;;;;EAgC5B"}
@@ -0,0 +1,34 @@
1
+ import { useCallback } from 'react';
2
+ import { useApiGet } from '../../hooks/use_api';
3
+ export function useTeamsILead() {
4
+ const response = useApiGet({
5
+ url: `/chat`,
6
+ data: {
7
+ fields: {
8
+ Chat: ['teams_i_lead'],
9
+ },
10
+ },
11
+ app: 'services',
12
+ });
13
+ const { data, isFetching, isError, error } = response;
14
+ const teamsILead = data?.teamsILead || stableEmptyTeamResponseArray;
15
+ const hasNoServicesAccess = useCallback(() => {
16
+ if (isError && error) {
17
+ const errorArray = error;
18
+ const allErrors = errorArray.errors.map(e => e.detail);
19
+ if (allErrors.some(e => e.includes(NOT_IN_APPLICATION_CODE))) {
20
+ return true;
21
+ }
22
+ }
23
+ return false;
24
+ }, [isError, error]);
25
+ return {
26
+ teamsILead,
27
+ isFetching,
28
+ isError,
29
+ noServicesAccess: hasNoServicesAccess(),
30
+ };
31
+ }
32
+ const stableEmptyTeamResponseArray = [];
33
+ const NOT_IN_APPLICATION_CODE = 'TRASH_PANDA';
34
+ //# sourceMappingURL=use_teams_i_lead.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_teams_i_lead.js","sourceRoot":"","sources":["../../../src/hooks/services/use_teams_i_lead.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAG/C,MAAM,UAAU,aAAa;IAC3B,MAAM,QAAQ,GAAG,SAAS,CAAuB;QAC/C,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,IAAI,EAAE,CAAC,cAAc,CAAC;aACvB;SACF;QACD,GAAG,EAAE,UAAU;KAChB,CAAC,CAAA;IAEF,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAA;IAErD,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,4BAA4B,CAAA;IAEnE,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC3C,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;YACrB,MAAM,UAAU,GAAG,KAAK,CAAA;YACxB,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;YACtD,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,EAAE,CAAC;gBAC7D,OAAO,IAAI,CAAA;YACb,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAEpB,OAAO;QACL,UAAU;QACV,UAAU;QACV,OAAO;QACP,gBAAgB,EAAE,mBAAmB,EAAE;KACxC,CAAA;AACH,CAAC;AAMD,MAAM,4BAA4B,GAAuB,EAAE,CAAA;AAC3D,MAAM,uBAAuB,GAAG,aAAa,CAAA","sourcesContent":["import { useCallback } from 'react'\nimport { useApiGet } from '../../hooks/use_api'\nimport { ResourceObject, TeamResponseItem } from '../../types'\n\nexport function useTeamsILead() {\n const response = useApiGet<ServicesChatResource>({\n url: `/chat`,\n data: {\n fields: {\n Chat: ['teams_i_lead'],\n },\n },\n app: 'services',\n })\n\n const { data, isFetching, isError, error } = response\n\n const teamsILead = data?.teamsILead || stableEmptyTeamResponseArray\n\n const hasNoServicesAccess = useCallback(() => {\n if (isError && error) {\n const errorArray = error\n const allErrors = errorArray.errors.map(e => e.detail)\n if (allErrors.some(e => e.includes(NOT_IN_APPLICATION_CODE))) {\n return true\n }\n }\n return false\n }, [isError, error])\n\n return {\n teamsILead,\n isFetching,\n isError,\n noServicesAccess: hasNoServicesAccess(),\n }\n}\n\ninterface ServicesChatResource extends ResourceObject {\n teamsILead: TeamResponseItem[]\n}\n\nconst stableEmptyTeamResponseArray: TeamResponseItem[] = []\nconst NOT_IN_APPLICATION_CODE = 'TRASH_PANDA'\n"]}
@@ -1,8 +1,8 @@
1
1
  import { ServiceTypeWithTeams } from '../types';
2
2
  export declare function useServiceTypesWithTeams(): {
3
- serviceTypes: ServiceTypeWithTeams[];
4
3
  isFetching: boolean;
5
4
  isError: boolean;
6
5
  noServicesAccess: boolean;
6
+ serviceTypes: ServiceTypeWithTeams[];
7
7
  };
8
8
  //# sourceMappingURL=use_service_types_with_teams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use_service_types_with_teams.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAG/C,wBAAgB,wBAAwB;;;;;EAoCvC"}
1
+ {"version":3,"file":"use_service_types_with_teams.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAI/C,wBAAgB,wBAAwB;;;;;EAWvC"}
@@ -1,36 +1,14 @@
1
- import { useCallback, useMemo } from 'react';
2
- import { useApiGet } from '../../../hooks/use_api';
1
+ import { useMemo } from 'react';
3
2
  import { uniqBy } from 'lodash';
3
+ import { useTeamsILead } from '../../../hooks/services/use_teams_i_lead';
4
4
  export function useServiceTypesWithTeams() {
5
- const response = useApiGet({
6
- url: `/chat`,
7
- data: {
8
- fields: {
9
- Chat: ['teams_i_lead'],
10
- },
11
- },
12
- app: 'services',
13
- });
14
- const { data, isFetching, isError, error } = response;
15
- const teamsILead = data?.teamsILead || stableEmptyTeamResponseArray;
5
+ const { teamsILead, ...data } = useTeamsILead();
16
6
  const decoratedResponse = useMemo(() => {
17
7
  return decorateTeamResponseItems(teamsILead);
18
8
  }, [teamsILead]);
19
- const hasNoServicesAccess = useCallback(() => {
20
- if (isError && error) {
21
- const errorArray = error;
22
- const allErrors = errorArray.errors.map(e => e.detail);
23
- if (allErrors.some(e => e.includes(NOT_IN_APPLICATION_CODE))) {
24
- return true;
25
- }
26
- }
27
- return false;
28
- }, [isError, error]);
29
9
  return {
30
10
  serviceTypes: decoratedResponse,
31
- isFetching,
32
- isError,
33
- noServicesAccess: hasNoServicesAccess(),
11
+ ...data,
34
12
  };
35
13
  }
36
14
  function decorateTeamResponseItems(teamResponseItems) {
@@ -60,6 +38,4 @@ function decorateTeamResponseItems(teamResponseItems) {
60
38
  return acc;
61
39
  }, []);
62
40
  }
63
- const stableEmptyTeamResponseArray = [];
64
- const NOT_IN_APPLICATION_CODE = 'TRASH_PANDA';
65
41
  //# sourceMappingURL=use_service_types_with_teams.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use_service_types_with_teams.js","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,SAAS,EA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tE,OAAO,iBAAiB;SACrB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,YAAY,EAAE;YACZ,EAAE,EAAE,KAAK,CAAC,aAAa;YACvB,IAAI,EAAE,eAAe;SACtB;QACD,IAAI,EAAE;YACJ,EAAE,EAAE,KAAK,CAAC,MAAM;YAChB,IAAI,EAAE,QAAQ;SACf;KACF,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,GAA2B,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE;QAC9D,IAAI,gBAAgB,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,YAAY,CAAC,EAAE,CAAC,CAAA;QAEtE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,gBAAgB,GAAG;gBACjB,EAAE,EAAE,YAAY,CAAC,EAAE;gBACnB,IAAI,EAAE,YAAY,CAAC,IAAI;gBACvB,KAAK,EAAE,EAAE;aACV,CAAA;YACD,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;QAC5B,CAAC;QACD,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,CAAA;QAC3C,gBAAgB,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,GAAG,YAAY,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QAC9D,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AACV,CAAC;AAiBD,MAAM,4BAA4B,GAAuB,EAAE,CAAA;AAC3D,MAAM,uBAAuB,GAAG,aAAa,CAAA","sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { useApiGet } from '../../../hooks/use_api'\nimport { ResourceObject } from '../../../types'\nimport { ServiceTypeWithTeams } from '../types'\nimport { uniqBy } from 'lodash'\n\nexport function useServiceTypesWithTeams() {\n const response = useApiGet<ServicesChatResource>({\n url: `/chat`,\n data: {\n fields: {\n Chat: ['teams_i_lead'],\n },\n },\n app: 'services',\n })\n\n const { data, isFetching, isError, error } = response\n\n const teamsILead = data?.teamsILead || stableEmptyTeamResponseArray\n\n const decoratedResponse = useMemo(() => {\n return decorateTeamResponseItems(teamsILead)\n }, [teamsILead])\n\n const hasNoServicesAccess = useCallback(() => {\n if (isError && error) {\n const errorArray = error\n const allErrors = errorArray.errors.map(e => e.detail)\n if (allErrors.some(e => e.includes(NOT_IN_APPLICATION_CODE))) {\n return true\n }\n }\n return false\n }, [isError, error])\n\n return {\n serviceTypes: decoratedResponse,\n isFetching,\n isError,\n noServicesAccess: hasNoServicesAccess(),\n }\n}\n\nfunction decorateTeamResponseItems(teamResponseItems: TeamResponseItem[]) {\n return teamResponseItems\n .map(({ value, serviceTypeName, teamName }) => ({\n service_type: {\n id: value.serviceTypeId,\n name: serviceTypeName,\n },\n team: {\n id: value.teamId,\n name: teamName,\n },\n }))\n .reduce((acc: ServiceTypeWithTeams[], { service_type, team }) => {\n let serviceTypeEntry = acc.find(entry => entry.id === service_type.id)\n\n if (!serviceTypeEntry) {\n serviceTypeEntry = {\n id: service_type.id,\n name: service_type.name,\n teams: [],\n }\n acc.push(serviceTypeEntry)\n }\n const initialTeams = serviceTypeEntry.teams\n serviceTypeEntry.teams = uniqBy([...initialTeams, team], 'id')\n return acc\n }, [])\n}\n\ninterface TeamResponseItem {\n value: {\n teamId: number\n serviceTypeId: number\n }\n name: string\n teamName: string\n serviceTypeName: string\n order: string[]\n}\n\ninterface ServicesChatResource extends ResourceObject {\n teamsILead: TeamResponseItem[]\n}\n\nconst stableEmptyTeamResponseArray: TeamResponseItem[] = []\nconst NOT_IN_APPLICATION_CODE = 'TRASH_PANDA'\n"]}
1
+ {"version":3,"file":"use_service_types_with_teams.js","sourceRoot":"","sources":["../../../../src/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,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gB,CAAC,KAAK,CAAA;QAC3C,gBAAgB,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,GAAG,YAAY,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QAC9D,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AACV,CAAC","sourcesContent":["import { useMemo } from 'react'\nimport { TeamResponseItem } from '../../../types'\nimport { ServiceTypeWithTeams } from '../types'\nimport { uniqBy } from 'lodash'\nimport { useTeamsILead } from '../../../hooks/services/use_teams_i_lead'\n\nexport function useServiceTypesWithTeams() {\n const { teamsILead, ...data } = useTeamsILead()\n\n const decoratedResponse = useMemo(() => {\n return decorateTeamResponseItems(teamsILead)\n }, [teamsILead])\n\n return {\n serviceTypes: decoratedResponse,\n ...data,\n }\n}\n\nfunction decorateTeamResponseItems(teamResponseItems: TeamResponseItem[]) {\n return teamResponseItems\n .map(({ value, serviceTypeName, teamName }) => ({\n service_type: {\n id: value.serviceTypeId,\n name: serviceTypeName,\n },\n team: {\n id: value.teamId,\n name: teamName,\n },\n }))\n .reduce((acc: ServiceTypeWithTeams[], { service_type, team }) => {\n let serviceTypeEntry = acc.find(entry => entry.id === service_type.id)\n\n if (!serviceTypeEntry) {\n serviceTypeEntry = {\n id: service_type.id,\n name: service_type.name,\n teams: [],\n }\n acc.push(serviceTypeEntry)\n }\n const initialTeams = serviceTypeEntry.teams\n serviceTypeEntry.teams = uniqBy([...initialTeams, team], 'id')\n return acc\n }, [])\n}\n"]}
@@ -0,0 +1,8 @@
1
+ interface Props {
2
+ teamIds: number[];
3
+ planId?: number;
4
+ onChange: (planId: number | undefined) => void;
5
+ }
6
+ export declare function FilterByPlanOptions({ teamIds, planId, onChange }: Props): import("react").JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=filter_by_plan_options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter_by_plan_options.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversation_new/components/filter_by_plan_options.tsx"],"names":[],"mappings":"AAIA,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAA;CAC/C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,KAAK,+BAuCvE"}
@@ -0,0 +1,37 @@
1
+ import { Pressable, StyleSheet, View } from 'react-native';
2
+ import { Banner, Spinner, Text } from '../../../components';
3
+ import { useTeamPlans } from '../../../hooks/services/use_team_plans';
4
+ export function FilterByPlanOptions({ teamIds, planId, onChange }) {
5
+ const styles = useStyles();
6
+ const { planOptions, isFetching, isError } = useTeamPlans({ teamIds });
7
+ if (isFetching) {
8
+ return (<View style={styles.spinnerContainer}>
9
+ <Spinner size={20}/>
10
+ </View>);
11
+ }
12
+ if (isError) {
13
+ return (<Banner appearance="error" description="An error occurred while fetching plans. Please try again."/>);
14
+ }
15
+ if (!planOptions || planOptions.length === 0) {
16
+ return (<Banner appearance="neutral" description="No plans available with the selected service type."/>);
17
+ }
18
+ return (<View style={styles.filterByPlanSectionRow}>
19
+ {planOptions.map(plan => (<Pressable onPress={() => onChange(plan.value)} key={plan.value}>
20
+ <Text style={[planId === plan.value ? styles.selectedFilter : null]}>{plan.name}</Text>
21
+ </Pressable>))}
22
+ </View>);
23
+ }
24
+ const useStyles = () => {
25
+ return StyleSheet.create({
26
+ spinnerContainer: {
27
+ marginVertical: 8,
28
+ },
29
+ filterByPlanSectionRow: {
30
+ gap: 8,
31
+ },
32
+ selectedFilter: {
33
+ fontWeight: '800',
34
+ },
35
+ });
36
+ };
37
+ //# sourceMappingURL=filter_by_plan_options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter_by_plan_options.js","sourceRoot":"","sources":["../../../../src/screens/conversation_new/components/filter_by_plan_options.tsx"],"names":[],"mappings":"AA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CAAC,KAAK,CAAC,CAC9D;UAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CACxF;QAAA,EAAE,SAAS,CAAC,CACb,CAAC,CACJ;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE;YAChB,cAAc,EAAE,CAAC;SAClB;QACD,sBAAsB,EAAE;YACtB,GAAG,EAAE,CAAC;SACP;QACD,cAAc,EAAE;YACd,UAAU,EAAE,KAAK;SAClB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { Pressable, StyleSheet, View } from 'react-native'\nimport { Banner, Spinner, Text } from '../../../components'\nimport { useTeamPlans } from '../../../hooks/services/use_team_plans'\n\ninterface Props {\n teamIds: number[]\n planId?: number\n onChange: (planId: number | undefined) => void\n}\n\nexport function FilterByPlanOptions({ teamIds, planId, onChange }: Props) {\n const styles = useStyles()\n const { planOptions, isFetching, isError } = useTeamPlans({ teamIds })\n\n if (isFetching) {\n return (\n <View style={styles.spinnerContainer}>\n <Spinner size={20} />\n </View>\n )\n }\n\n if (isError) {\n return (\n <Banner\n appearance=\"error\"\n description=\"An error occurred while fetching plans. Please try again.\"\n />\n )\n }\n\n if (!planOptions || planOptions.length === 0) {\n return (\n <Banner\n appearance=\"neutral\"\n description=\"No plans available with the selected service type.\"\n />\n )\n }\n\n return (\n <View style={styles.filterByPlanSectionRow}>\n {planOptions.map(plan => (\n <Pressable onPress={() => onChange(plan.value)} key={plan.value}>\n <Text style={[planId === plan.value ? styles.selectedFilter : null]}>{plan.name}</Text>\n </Pressable>\n ))}\n </View>\n )\n}\n\nconst useStyles = () => {\n return StyleSheet.create({\n spinnerContainer: {\n marginVertical: 8,\n },\n filterByPlanSectionRow: {\n gap: 8,\n },\n selectedFilter: {\n fontWeight: '800',\n },\n })\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ type ServicesFormProps = {
3
+ initialTeamIds?: number[];
4
+ initialPlanId?: number;
5
+ };
6
+ export declare const ServicesForm: ({ initialTeamIds, initialPlanId }: ServicesFormProps) => React.JSX.Element;
7
+ export {};
8
+ //# sourceMappingURL=services_form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services_form.d.ts","sourceRoot":"","sources":["../../../../src/screens/conversation_new/components/services_form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAyC,MAAM,OAAO,CAAA;AAa7D,KAAK,iBAAiB,GAAG;IACvB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,YAAY,sCAAuC,iBAAiB,sBA6DhF,CAAA"}