vdb-ai-chat 1.0.8 → 1.0.9

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/src/api.ts CHANGED
@@ -251,6 +251,18 @@ export async function getProducts(
251
251
  });
252
252
  }
253
253
 
254
+ let depth_percent_from: number | undefined;
255
+ let depth_percent_to: number | undefined;
256
+ let table_percent_from: number | undefined;
257
+ let table_percent_to: number | undefined;
258
+
259
+ if (userInfo?.user?.max_search_key_values) {
260
+ depth_percent_from = userInfo.user.max_search_key_values.min_depth;
261
+ depth_percent_to = userInfo.user.max_search_key_values.max_depth;
262
+ table_percent_from = userInfo.user.max_search_key_values.min_table;
263
+ table_percent_to = userInfo.user.max_search_key_values.max_table;
264
+ }
265
+
254
266
  const res = await fetch(
255
267
  "https://pdpdemo1.demo.customvirtual.app/v3/vdb/search_diamonds",
256
268
  {
@@ -268,6 +280,18 @@ export async function getProducts(
268
280
  pair: sectionName === "Single Stones" ? "other" : "pair",
269
281
  with_available_items: false,
270
282
  page_number: 1,
283
+ ...(depth_percent_from !== undefined && depth_percent_to !== undefined
284
+ ? {
285
+ depth_percent_from: depth_percent_from,
286
+ depth_percent_to: depth_percent_to,
287
+ }
288
+ : {}),
289
+ ...(table_percent_from !== undefined && table_percent_to !== undefined
290
+ ? {
291
+ table_percent_from: table_percent_from,
292
+ table_percent_to: table_percent_to,
293
+ }
294
+ : {}),
271
295
  },
272
296
  }),
273
297
  }
@@ -14,6 +14,7 @@ import {
14
14
  Text,
15
15
  TextInput,
16
16
  KeyboardAvoidingView,
17
+ Keyboard,
17
18
  DeviceEventEmitter,
18
19
  Platform,
19
20
  } from "react-native";
@@ -217,13 +218,10 @@ export const ChatWidget = forwardRef<ChatWidgetRef, ChatWidgetProps>(
217
218
  const initialAssistant: ChatMessage = {
218
219
  id: "",
219
220
  role: "assistant",
220
- text: "Hello! How can I help you today?",
221
+ text: "Search our diamond inventory instantly. Try asking for a '1.5ct Round under $2,000 VS' or 'Pear 2ct VS2+ $10000'",
221
222
  createdAt: Date.now(),
222
223
  isLoading: false,
223
- suggestions: [
224
- "Search Natural Diamonds",
225
- "Search Lab-Grown Diamonds",
226
- ],
224
+ suggestions: [],
227
225
  search_payload: {},
228
226
  reaction: "0",
229
227
  };
@@ -452,6 +450,27 @@ export const ChatWidget = forwardRef<ChatWidgetRef, ChatWidgetProps>(
452
450
  }
453
451
  }, []);
454
452
 
453
+ useEffect(() => {
454
+ const scrollToBottom = () => {
455
+ setTimeout(() => {
456
+ try {
457
+ scrollRef.current?.scrollToEnd({ animated: true });
458
+ } catch (_) {}
459
+ }, 100);
460
+ };
461
+
462
+ const showEvent = Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow";
463
+ const hideEvent = Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide";
464
+
465
+ const subShow = Keyboard.addListener(showEvent, scrollToBottom);
466
+ const subHide = Keyboard.addListener(hideEvent, scrollToBottom);
467
+
468
+ return () => {
469
+ subShow.remove();
470
+ subHide.remove();
471
+ };
472
+ }, []);
473
+
455
474
  useEffect(() => {
456
475
  DeviceEventEmitter.addListener("clearChat", handleClearChat);
457
476
  DeviceEventEmitter.addListener(
@@ -516,13 +535,10 @@ export const ChatWidget = forwardRef<ChatWidgetRef, ChatWidgetProps>(
516
535
  const initialAssistant: ChatMessage = {
517
536
  id: "",
518
537
  role: "assistant",
519
- text: "Hello! How can I help you today?",
538
+ text: "Search our diamond inventory instantly. Try asking for a '1.5ct Round under $2,000 VS' or 'Pear 2ct VS2+ $10000'",
520
539
  createdAt: Date.now(),
521
540
  isLoading: false,
522
- suggestions: [
523
- "Search Natural Diamonds",
524
- "Search Lab-Grown Diamonds",
525
- ],
541
+ suggestions: [],
526
542
  reaction: "0",
527
543
  search_payload: {},
528
544
  };
@@ -834,10 +850,10 @@ const BottomContainer = styled.View<{ theme: DefaultTheme }>`
834
850
  ${({ theme }: { theme: DefaultTheme }) =>
835
851
  theme.isTablet &&
836
852
  css`
837
- maxWidth: 608,
853
+ max-width: 608px;
838
854
  align-self: center;
839
855
  width: 100%;
840
- `}
856
+ `};
841
857
  `;
842
858
 
843
859
  const LineView = styled.View<{ theme: DefaultTheme }>`