@developer_tribe/react-native-comnyx 0.4.5 → 0.4.6
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/lib/commonjs/App.js +13 -3
- package/lib/commonjs/App.js.map +1 -1
- package/lib/commonjs/api/api.js +2 -1
- package/lib/commonjs/api/api.js.map +1 -1
- package/lib/commonjs/api/customers.js +3 -1
- package/lib/commonjs/api/customers.js.map +1 -1
- package/lib/commonjs/components/ChatList.js +12 -12
- package/lib/commonjs/components/ChatList.js.map +1 -1
- package/lib/commonjs/components/CustomerForm.js +4 -4
- package/lib/commonjs/components/CustomerForm.js.map +1 -1
- package/lib/commonjs/components/MessageInput.js +1 -2
- package/lib/commonjs/components/MessageInput.js.map +1 -1
- package/lib/commonjs/hooks/usePolling.js +5 -5
- package/lib/commonjs/hooks/usePolling.js.map +1 -1
- package/lib/commonjs/register.js +4 -7
- package/lib/commonjs/register.js.map +1 -1
- package/lib/commonjs/store.js +1 -12
- package/lib/commonjs/store.js.map +1 -1
- package/lib/module/App.js +13 -3
- package/lib/module/App.js.map +1 -1
- package/lib/module/api/api.js +2 -1
- package/lib/module/api/api.js.map +1 -1
- package/lib/module/api/customers.js +3 -1
- package/lib/module/api/customers.js.map +1 -1
- package/lib/module/components/ChatList.js +12 -12
- package/lib/module/components/ChatList.js.map +1 -1
- package/lib/module/components/CustomerForm.js +4 -4
- package/lib/module/components/CustomerForm.js.map +1 -1
- package/lib/module/components/MessageInput.js +1 -2
- package/lib/module/components/MessageInput.js.map +1 -1
- package/lib/module/hooks/usePolling.js +5 -5
- package/lib/module/hooks/usePolling.js.map +1 -1
- package/lib/module/register.js +4 -7
- package/lib/module/register.js.map +1 -1
- package/lib/module/store.js +1 -12
- package/lib/module/store.js.map +1 -1
- package/lib/typescript/commonjs/src/App.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/api/api.d.ts +1 -1
- package/lib/typescript/commonjs/src/api/api.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/api/customers.d.ts +3 -1
- package/lib/typescript/commonjs/src/api/customers.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/ChatList.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/MessageInput.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/register.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/store.d.ts +0 -5
- package/lib/typescript/commonjs/src/store.d.ts.map +1 -1
- package/lib/typescript/module/src/App.d.ts.map +1 -1
- package/lib/typescript/module/src/api/api.d.ts +1 -1
- package/lib/typescript/module/src/api/api.d.ts.map +1 -1
- package/lib/typescript/module/src/api/customers.d.ts +3 -1
- package/lib/typescript/module/src/api/customers.d.ts.map +1 -1
- package/lib/typescript/module/src/components/ChatList.d.ts.map +1 -1
- package/lib/typescript/module/src/components/MessageInput.d.ts.map +1 -1
- package/lib/typescript/module/src/register.d.ts.map +1 -1
- package/lib/typescript/module/src/store.d.ts +0 -5
- package/lib/typescript/module/src/store.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/App.tsx +13 -4
- package/src/api/api.ts +2 -1
- package/src/api/customers.ts +2 -2
- package/src/components/ChatList.tsx +20 -15
- package/src/components/CustomerForm.tsx +4 -4
- package/src/components/MessageInput.tsx +1 -2
- package/src/hooks/usePolling.ts +5 -5
- package/src/register.ts +4 -5
- package/src/store.ts +1 -11
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CreateCustomerRequest, Customer } from '../types/Customer';
|
|
2
2
|
import type { ApiOptions } from '../types/ApiOptions';
|
|
3
|
-
export declare function createCustomer(customerData: CreateCustomerRequest, options: ApiOptions, externalId: string): Promise<
|
|
3
|
+
export declare function createCustomer(customerData: CreateCustomerRequest, options: ApiOptions, externalId: string): Promise<{
|
|
4
|
+
customer: Customer;
|
|
5
|
+
}>;
|
|
4
6
|
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../../../../src/api/customers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAItD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,qBAAqB,EACnC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../../../../src/api/customers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAItD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,qBAAqB,EACnC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,CAYjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatList.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatList.tsx"],"names":[],"mappings":"AAwCA,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"ChatList.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatList.tsx"],"names":[],"mappings":"AAwCA,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,2CA0nB3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/MessageInput.tsx"],"names":[],"mappings":"AAWA,wBAAgB,YAAY,CAAC,EAC3B,cAAc,GACf,EAAE;IACD,cAAc,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,
|
|
1
|
+
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/MessageInput.tsx"],"names":[],"mappings":"AAWA,wBAAgB,YAAY,CAAC,EAC3B,cAAc,GACf,EAAE;IACD,cAAc,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,2CAuHA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/register.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,eAAe,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/register.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,eAAe,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,QAmBA"}
|
|
@@ -4,10 +4,8 @@ import type { LanguageCode } from './types/Language';
|
|
|
4
4
|
interface AppStoreState {
|
|
5
5
|
baseHeight: number;
|
|
6
6
|
baseWidth: number;
|
|
7
|
-
initialized: boolean;
|
|
8
7
|
customer: Customer | null;
|
|
9
8
|
data: AppConversationMessage[] | null;
|
|
10
|
-
externalId: string | null;
|
|
11
9
|
language: LanguageCode;
|
|
12
10
|
theme: 'light' | 'dark';
|
|
13
11
|
fake: boolean;
|
|
@@ -15,9 +13,6 @@ interface AppStoreState {
|
|
|
15
13
|
firstMessage: AppConversationMessage | null;
|
|
16
14
|
setData: (cb: (prevData: AppConversationMessage[] | null) => AppConversationMessage[] | null) => void;
|
|
17
15
|
setFirstMessage: (message: AppConversationMessage | null) => void;
|
|
18
|
-
init: ({ externalId }: {
|
|
19
|
-
externalId: string;
|
|
20
|
-
}) => void;
|
|
21
16
|
setCustomer: (createCustomerResponse: Customer) => void;
|
|
22
17
|
setLanguage: (language: LanguageCode) => void;
|
|
23
18
|
setTheme: (theme: 'light' | 'dark') => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,sBAAsB,EAAE,GAAG,IAAI,CAAC;IACtC,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,YAAY,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC5C,OAAO,EAAE,CACP,EAAE,EAAE,CACF,QAAQ,EAAE,sBAAsB,EAAE,GAAG,IAAI,KACtC,sBAAsB,EAAE,GAAG,IAAI,KACjC,IAAI,CAAC;IACV,eAAe,EAAE,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,KAAK,IAAI,CAAC;IAClE,WAAW,EAAE,CAAC,sBAAsB,EAAE,QAAQ,KAAK,IAAI,CAAC;IACxD,WAAW,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;IAC9C,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,oBAAoB,EAAE,CAAC,MAAM,EAAE;QAC7B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,KAAK,IAAI,CAAC;IACX,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACnC;AA+CD,eAAO,MAAM,WAAW;;;;;;;;;;EAmBvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../src/App.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAMrD,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,wBAAgB,MAAM,CAAC,EACrB,QAAe,EACf,KAAc,EACd,IAAY,EACZ,MAAM,EACN,MAAM,GACP,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../src/App.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAMrD,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,wBAAgB,MAAM,CAAC,EACrB,QAAe,EACf,KAAc,EACd,IAAY,EACZ,MAAM,EACN,MAAM,GACP,EAAE,WAAW,2CA4Cb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/api/api.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,+BAOjB,CAAC;AAEH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../../src/api/api.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,+BAOjB,CAAC;AAEH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAIxD;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CreateCustomerRequest, Customer } from '../types/Customer';
|
|
2
2
|
import type { ApiOptions } from '../types/ApiOptions';
|
|
3
|
-
export declare function createCustomer(customerData: CreateCustomerRequest, options: ApiOptions, externalId: string): Promise<
|
|
3
|
+
export declare function createCustomer(customerData: CreateCustomerRequest, options: ApiOptions, externalId: string): Promise<{
|
|
4
|
+
customer: Customer;
|
|
5
|
+
}>;
|
|
4
6
|
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../../../../src/api/customers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAItD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,qBAAqB,EACnC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../../../../src/api/customers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAItD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,qBAAqB,EACnC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,CAYjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatList.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatList.tsx"],"names":[],"mappings":"AAwCA,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"ChatList.d.ts","sourceRoot":"","sources":["../../../../../src/components/ChatList.tsx"],"names":[],"mappings":"AAwCA,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,2CA0nB3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/MessageInput.tsx"],"names":[],"mappings":"AAWA,wBAAgB,YAAY,CAAC,EAC3B,cAAc,GACf,EAAE;IACD,cAAc,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,
|
|
1
|
+
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/MessageInput.tsx"],"names":[],"mappings":"AAWA,wBAAgB,YAAY,CAAC,EAC3B,cAAc,GACf,EAAE;IACD,cAAc,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,2CAuHA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/register.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,eAAe,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/register.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,eAAe,EAAE;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,QAmBA"}
|
|
@@ -4,10 +4,8 @@ import type { LanguageCode } from './types/Language';
|
|
|
4
4
|
interface AppStoreState {
|
|
5
5
|
baseHeight: number;
|
|
6
6
|
baseWidth: number;
|
|
7
|
-
initialized: boolean;
|
|
8
7
|
customer: Customer | null;
|
|
9
8
|
data: AppConversationMessage[] | null;
|
|
10
|
-
externalId: string | null;
|
|
11
9
|
language: LanguageCode;
|
|
12
10
|
theme: 'light' | 'dark';
|
|
13
11
|
fake: boolean;
|
|
@@ -15,9 +13,6 @@ interface AppStoreState {
|
|
|
15
13
|
firstMessage: AppConversationMessage | null;
|
|
16
14
|
setData: (cb: (prevData: AppConversationMessage[] | null) => AppConversationMessage[] | null) => void;
|
|
17
15
|
setFirstMessage: (message: AppConversationMessage | null) => void;
|
|
18
|
-
init: ({ externalId }: {
|
|
19
|
-
externalId: string;
|
|
20
|
-
}) => void;
|
|
21
16
|
setCustomer: (createCustomerResponse: Customer) => void;
|
|
22
17
|
setLanguage: (language: LanguageCode) => void;
|
|
23
18
|
setTheme: (theme: 'light' | 'dark') => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,sBAAsB,EAAE,GAAG,IAAI,CAAC;IACtC,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,YAAY,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC5C,OAAO,EAAE,CACP,EAAE,EAAE,CACF,QAAQ,EAAE,sBAAsB,EAAE,GAAG,IAAI,KACtC,sBAAsB,EAAE,GAAG,IAAI,KACjC,IAAI,CAAC;IACV,eAAe,EAAE,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,KAAK,IAAI,CAAC;IAClE,WAAW,EAAE,CAAC,sBAAsB,EAAE,QAAQ,KAAK,IAAI,CAAC;IACxD,WAAW,EAAE,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;IAC9C,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACjC,oBAAoB,EAAE,CAAC,MAAM,EAAE;QAC7B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,KAAK,IAAI,CAAC;IACX,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACnC;AA+CD,eAAO,MAAM,WAAW;;;;;;;;;;EAmBvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@developer_tribe/react-native-comnyx",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "React Native chat component with integrated support panel, enabling real-time customer communication and efficient agent workflow management.",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
package/src/App.tsx
CHANGED
|
@@ -23,12 +23,19 @@ export function Comnyx({
|
|
|
23
23
|
onBack,
|
|
24
24
|
themes,
|
|
25
25
|
}: ComnyxProps) {
|
|
26
|
-
const {
|
|
27
|
-
|
|
26
|
+
const { customer, formSubmitted } = useAppStore((s) => ({
|
|
27
|
+
customer: s.customer,
|
|
28
28
|
formSubmitted: s.formSubmitted,
|
|
29
29
|
}));
|
|
30
30
|
const themeColors = useThemeColors();
|
|
31
31
|
usePolling();
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (customer === null || !customer.external_id) {
|
|
35
|
+
useAppStore.setState({ data: [] });
|
|
36
|
+
}
|
|
37
|
+
}, [customer, customer?.external_id]);
|
|
38
|
+
|
|
32
39
|
useEffect(() => {
|
|
33
40
|
useAppStore.getState().setLanguage(language);
|
|
34
41
|
useAppStore.getState().setTheme(theme);
|
|
@@ -37,8 +44,9 @@ export function Comnyx({
|
|
|
37
44
|
useAppStore.getState().setThemes(themes);
|
|
38
45
|
}
|
|
39
46
|
}, [language, theme, fake, themes]);
|
|
40
|
-
|
|
41
|
-
if (!
|
|
47
|
+
console.log('formSubmitted', formSubmitted);
|
|
48
|
+
if (!customer) {
|
|
49
|
+
//NOTE: customer yoksa register hiç çalışmamış
|
|
42
50
|
return (
|
|
43
51
|
<View
|
|
44
52
|
style={[styles.container, { backgroundColor: themeColors.background }]}
|
|
@@ -47,6 +55,7 @@ export function Comnyx({
|
|
|
47
55
|
</View>
|
|
48
56
|
);
|
|
49
57
|
} else if (!formSubmitted) {
|
|
58
|
+
//NOTE: customer var ama forSubmitted false (name===null)
|
|
50
59
|
return <CustomerForm onBack={onBack} />;
|
|
51
60
|
}
|
|
52
61
|
|
package/src/api/api.ts
CHANGED
|
@@ -8,9 +8,10 @@ const axiosInstance = axios.create({
|
|
|
8
8
|
timeout: 1000,
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
export function initApi(token: string) {
|
|
11
|
+
export function initApi(token: string, externalId: string) {
|
|
12
12
|
axiosInstance.defaults.headers.common['Content-Type'] = 'application/json';
|
|
13
13
|
axiosInstance.defaults.headers.common.Authorization = 'Bearer ' + token;
|
|
14
|
+
axiosInstance.defaults.headers.common['external-id'] = externalId;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export { axiosInstance };
|
package/src/api/customers.ts
CHANGED
|
@@ -7,9 +7,9 @@ export function createCustomer(
|
|
|
7
7
|
customerData: CreateCustomerRequest,
|
|
8
8
|
options: ApiOptions,
|
|
9
9
|
externalId: string
|
|
10
|
-
): Promise<Customer> {
|
|
10
|
+
): Promise<{ customer: Customer }> {
|
|
11
11
|
if (options.fake) {
|
|
12
|
-
return Promise.resolve(getFakeCustomer(customerData));
|
|
12
|
+
return Promise.resolve({ customer: getFakeCustomer(customerData) });
|
|
13
13
|
}
|
|
14
14
|
console.info('[Comnyx] Adding customer info');
|
|
15
15
|
return axiosInstance
|
|
@@ -47,10 +47,10 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
|
|
|
47
47
|
(windowHeight - FLATLIST_PADDING) / MESSAGE_MIN_HEIGHT
|
|
48
48
|
);
|
|
49
49
|
const [loading, setLoading] = useState(true);
|
|
50
|
-
const { data, setData,
|
|
50
|
+
const { data, setData, customer } = useAppStore((s) => ({
|
|
51
51
|
data: s.data,
|
|
52
52
|
setData: s.setData,
|
|
53
|
-
|
|
53
|
+
customer: s.customer,
|
|
54
54
|
}));
|
|
55
55
|
const ref = useRef<SectionList<AppConversationMessage>>(null);
|
|
56
56
|
const [page, setPage] = useState(1);
|
|
@@ -131,7 +131,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
|
|
|
131
131
|
}, [data]);
|
|
132
132
|
|
|
133
133
|
const resendMessage = useCallback(() => {
|
|
134
|
-
if (selectedMessage &&
|
|
134
|
+
if (selectedMessage && customer?.external_id) {
|
|
135
135
|
const currentMessage = useAppStore.getState().data || [];
|
|
136
136
|
const messageIndex = currentMessage.findIndex(
|
|
137
137
|
(msg) => msg.content === selectedMessage
|
|
@@ -155,7 +155,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
|
|
|
155
155
|
data: updatedValue,
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
sendCustomerMessage(
|
|
158
|
+
sendCustomerMessage(customer.external_id, selectedMessage, {
|
|
159
159
|
fake: useAppStore.getState().fake,
|
|
160
160
|
})
|
|
161
161
|
.then((res: any) => {
|
|
@@ -214,21 +214,26 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
|
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
}, [selectedMessage,
|
|
217
|
+
}, [selectedMessage, customer]);
|
|
218
218
|
|
|
219
219
|
const nextPage = useCallback(() => {
|
|
220
220
|
if (nextPageStatus.current) {
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
223
|
nextPageStatus.current = 'loading';
|
|
224
|
-
if (
|
|
224
|
+
if (customer?.external_id) {
|
|
225
225
|
const newPage = page + 1;
|
|
226
226
|
setPage(newPage);
|
|
227
227
|
const firstMessage = useAppStore.getState().firstMessage;
|
|
228
|
-
getCustomerConversation(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
getCustomerConversation(
|
|
229
|
+
customer.external_id,
|
|
230
|
+
firstMessage?.created_at,
|
|
231
|
+
newPage,
|
|
232
|
+
{
|
|
233
|
+
fake: useAppStore.getState().fake,
|
|
234
|
+
per_page: MESSAGES_PER_PAGE,
|
|
235
|
+
}
|
|
236
|
+
)
|
|
232
237
|
.then((newData) => {
|
|
233
238
|
listChangedRef.current = true;
|
|
234
239
|
setData((prevData) => {
|
|
@@ -277,7 +282,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
|
|
|
277
282
|
setLoading(false);
|
|
278
283
|
});
|
|
279
284
|
}
|
|
280
|
-
}, [MESSAGES_PER_PAGE,
|
|
285
|
+
}, [MESSAGES_PER_PAGE, customer, page, setData]);
|
|
281
286
|
|
|
282
287
|
const renderItem = useCallback(
|
|
283
288
|
({ item }: { item: AppConversationMessage }) => {
|
|
@@ -412,8 +417,8 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
|
|
|
412
417
|
);
|
|
413
418
|
|
|
414
419
|
useEffect(() => {
|
|
415
|
-
if (
|
|
416
|
-
getCustomerConversation(
|
|
420
|
+
if (customer?.external_id && !initFailed) {
|
|
421
|
+
getCustomerConversation(customer?.external_id, new Date(), 1, {
|
|
417
422
|
fake: useAppStore.getState().fake,
|
|
418
423
|
per_page: MESSAGES_PER_PAGE,
|
|
419
424
|
})
|
|
@@ -437,7 +442,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
|
|
|
437
442
|
if (processedMessages.length === 0) {
|
|
438
443
|
setLoading(false);
|
|
439
444
|
}
|
|
440
|
-
return [...
|
|
445
|
+
return [...processedMessages];
|
|
441
446
|
} else {
|
|
442
447
|
// Handle the case where there's no previous data
|
|
443
448
|
const processedMessages = newMessages.map((u) => ({
|
|
@@ -463,7 +468,7 @@ export function ChatList({ onBack }: { onBack?: () => void }) {
|
|
|
463
468
|
setLoading(false);
|
|
464
469
|
});
|
|
465
470
|
}
|
|
466
|
-
}, [MESSAGES_PER_PAGE,
|
|
471
|
+
}, [MESSAGES_PER_PAGE, customer?.external_id, initFailed, setData]);
|
|
467
472
|
|
|
468
473
|
// Initialize the current section when sections are loaded
|
|
469
474
|
useEffect(() => {
|
|
@@ -72,17 +72,17 @@ export function CustomerForm({ onBack }: { onBack: () => void }) {
|
|
|
72
72
|
|
|
73
73
|
const onSubmit = async (data: CustomerFormData) => {
|
|
74
74
|
try {
|
|
75
|
-
const
|
|
75
|
+
const res = await createCustomer(
|
|
76
76
|
{
|
|
77
77
|
...data,
|
|
78
78
|
language: 'en',
|
|
79
79
|
customParameters: [],
|
|
80
80
|
},
|
|
81
81
|
{ fake: useAppStore.getState().fake },
|
|
82
|
-
useAppStore.getState().
|
|
82
|
+
useAppStore.getState().customer?.external_id ?? ''
|
|
83
83
|
);
|
|
84
|
-
if (
|
|
85
|
-
useAppStore.getState().setForm(customer);
|
|
84
|
+
if (res) {
|
|
85
|
+
useAppStore.getState().setForm(res.customer);
|
|
86
86
|
}
|
|
87
87
|
} catch (error) {
|
|
88
88
|
console.error('Error creating customer:', error);
|
|
@@ -17,7 +17,6 @@ export function MessageInput({
|
|
|
17
17
|
}) {
|
|
18
18
|
const [value, setValue] = useState('');
|
|
19
19
|
const customer = useAppStore((s) => s.customer!);
|
|
20
|
-
const externalId = useAppStore((s) => s.externalId);
|
|
21
20
|
const themeColors = useThemeColors();
|
|
22
21
|
const localize = useLocalize();
|
|
23
22
|
|
|
@@ -37,7 +36,7 @@ export function MessageInput({
|
|
|
37
36
|
},
|
|
38
37
|
...(data ?? []),
|
|
39
38
|
]);
|
|
40
|
-
sendCustomerMessage(
|
|
39
|
+
sendCustomerMessage(customer.external_id as string, value, {
|
|
41
40
|
fake: useAppStore.getState().fake,
|
|
42
41
|
})
|
|
43
42
|
.then((res) => {
|
package/src/hooks/usePolling.ts
CHANGED
|
@@ -5,18 +5,18 @@ import { getNewCustomerConversation } from '../api';
|
|
|
5
5
|
const NEW_MESSAGES_CHECK_INTERVAL = 10000;
|
|
6
6
|
|
|
7
7
|
export function usePolling() {
|
|
8
|
-
const { data, setData,
|
|
8
|
+
const { data, setData, customer } = useAppStore((s) => ({
|
|
9
9
|
data: s.data,
|
|
10
10
|
setData: s.setData,
|
|
11
|
-
|
|
11
|
+
customer: s.customer,
|
|
12
12
|
}));
|
|
13
13
|
const lastMessage = data ? data[data.length - 1] : null;
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
const created_at = lastMessage?.created_at;
|
|
16
16
|
let interval: NodeJS.Timeout | null = null;
|
|
17
|
-
if (
|
|
17
|
+
if (customer && created_at) {
|
|
18
18
|
interval = setInterval(() => {
|
|
19
|
-
getNewCustomerConversation(
|
|
19
|
+
getNewCustomerConversation(customer?.external_id, created_at, {
|
|
20
20
|
fake: useAppStore.getState().fake,
|
|
21
21
|
}).then((newData) => {
|
|
22
22
|
setData((prevData) => {
|
|
@@ -42,5 +42,5 @@ export function usePolling() {
|
|
|
42
42
|
clearInterval(interval);
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
}, [
|
|
45
|
+
}, [customer, lastMessage?.created_at, setData]);
|
|
46
46
|
}
|
package/src/register.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { accumulator } from './Accumulator';
|
|
2
2
|
import { initApi } from './api/api';
|
|
3
3
|
import { useAppStore } from './store';
|
|
4
|
-
import { createCustomer } from './api
|
|
4
|
+
import { createCustomer } from './api';
|
|
5
5
|
import type { CreateCustomerRequest } from './types/Customer';
|
|
6
6
|
|
|
7
7
|
export function registerComnyx(registerOptions: {
|
|
@@ -15,16 +15,15 @@ export function registerComnyx(registerOptions: {
|
|
|
15
15
|
throw new Error('Authentication token is required');
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
initApi(registerOptions.token);
|
|
19
|
-
useAppStore.getState().init({ externalId: registerOptions.externalId });
|
|
18
|
+
initApi(registerOptions.token, registerOptions.externalId);
|
|
20
19
|
accumulator.register(async (accumulatedData: CreateCustomerRequest) => {
|
|
21
|
-
const
|
|
20
|
+
const data = await createCustomer(
|
|
22
21
|
accumulatedData,
|
|
23
22
|
{
|
|
24
23
|
fake: false,
|
|
25
24
|
},
|
|
26
25
|
registerOptions.externalId
|
|
27
26
|
);
|
|
28
|
-
useAppStore.getState().setCustomer(customer);
|
|
27
|
+
useAppStore.getState().setCustomer(data.customer);
|
|
29
28
|
});
|
|
30
29
|
}
|
package/src/store.ts
CHANGED
|
@@ -10,10 +10,8 @@ import type { LanguageCode } from './types/Language';
|
|
|
10
10
|
interface AppStoreState {
|
|
11
11
|
baseHeight: number;
|
|
12
12
|
baseWidth: number;
|
|
13
|
-
initialized: boolean;
|
|
14
13
|
customer: Customer | null;
|
|
15
14
|
data: AppConversationMessage[] | null;
|
|
16
|
-
externalId: string | null;
|
|
17
15
|
language: LanguageCode;
|
|
18
16
|
theme: 'light' | 'dark';
|
|
19
17
|
fake: boolean;
|
|
@@ -25,7 +23,6 @@ interface AppStoreState {
|
|
|
25
23
|
) => AppConversationMessage[] | null
|
|
26
24
|
) => void;
|
|
27
25
|
setFirstMessage: (message: AppConversationMessage | null) => void;
|
|
28
|
-
init: ({ externalId }: { externalId: string }) => void;
|
|
29
26
|
setCustomer: (createCustomerResponse: Customer) => void;
|
|
30
27
|
setLanguage: (language: LanguageCode) => void;
|
|
31
28
|
setTheme: (theme: 'light' | 'dark') => void;
|
|
@@ -45,7 +42,6 @@ const storeCreator: StateCreator<AppStoreState> = (set, get) => ({
|
|
|
45
42
|
initialized: false,
|
|
46
43
|
customer: null,
|
|
47
44
|
data: null,
|
|
48
|
-
externalId: null,
|
|
49
45
|
language: 'en',
|
|
50
46
|
theme: 'light',
|
|
51
47
|
fake: false,
|
|
@@ -59,14 +55,10 @@ const storeCreator: StateCreator<AppStoreState> = (set, get) => ({
|
|
|
59
55
|
setFirstMessage: (message) => {
|
|
60
56
|
set({ firstMessage: message });
|
|
61
57
|
},
|
|
62
|
-
init: ({ externalId }: { externalId: string }) => {
|
|
63
|
-
set({ externalId: externalId });
|
|
64
|
-
},
|
|
65
58
|
setCustomer: (createCustomerResponse: Customer) => {
|
|
66
59
|
set({
|
|
67
60
|
customer: createCustomerResponse,
|
|
68
|
-
|
|
69
|
-
formSubmitted: !createCustomerResponse.name,
|
|
61
|
+
formSubmitted: !!createCustomerResponse.name,
|
|
70
62
|
});
|
|
71
63
|
},
|
|
72
64
|
setLanguage: (language: LanguageCode) => {
|
|
@@ -96,8 +88,6 @@ export const useAppStore = createWithEqualityFn<AppStoreState>()(
|
|
|
96
88
|
skipHydration: false,
|
|
97
89
|
partialize: (state) => ({
|
|
98
90
|
customer: state.customer,
|
|
99
|
-
externalId: state.externalId,
|
|
100
|
-
initialized: state.initialized,
|
|
101
91
|
formSubmitted: state.formSubmitted,
|
|
102
92
|
data: state.data
|
|
103
93
|
?.filter((message) => message.approved)
|