ordering-ui-react-native 0.14.85 → 0.14.86-release

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 (134) hide show
  1. package/package.json +6 -3
  2. package/src/DeliveryApp.tsx +34 -2
  3. package/src/assets/images/no-network.png +0 -0
  4. package/src/components/BusinessTypeFilter/index.tsx +9 -2
  5. package/src/components/BusinessTypeFilter/styles.tsx +1 -1
  6. package/src/components/BusinessesListing/index.tsx +1 -1
  7. package/src/components/Cart/index.tsx +1 -1
  8. package/src/components/Checkout/index.tsx +0 -1
  9. package/src/components/Home/index.tsx +3 -5
  10. package/src/components/LanguageSelector/index.tsx +65 -97
  11. package/src/components/LanguageSelector/styles.tsx +4 -17
  12. package/src/components/Messages/index.tsx +38 -30
  13. package/src/components/MomentOption/index.tsx +3 -1
  14. package/src/components/OrderDetails/index.tsx +26 -5
  15. package/src/components/PaymentOptions/index.tsx +7 -16
  16. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  17. package/src/components/ProductForm/index.tsx +1 -1
  18. package/src/components/ProductForm/styles.tsx +1 -0
  19. package/src/components/StripeElementsForm/index.tsx +27 -48
  20. package/src/components/UserProfileForm/index.tsx +35 -1
  21. package/src/components/VerifyPhone/styles.tsx +1 -2
  22. package/src/config.json +0 -2
  23. package/src/pages/Checkout.tsx +1 -1
  24. package/src/providers/AlertProvider.tsx +4 -1
  25. package/src/theme.json +2 -1
  26. package/src/types/index.tsx +2 -9
  27. package/src/utils/index.tsx +196 -1
  28. package/themes/business/index.tsx +4 -0
  29. package/themes/business/src/components/Chat/index.tsx +32 -31
  30. package/themes/business/src/components/NetworkError/index.tsx +61 -0
  31. package/themes/business/src/components/NetworkError/styles.tsx +11 -0
  32. package/themes/business/src/components/OrderDetails/Business.tsx +1 -0
  33. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +85 -17
  34. package/themes/business/src/components/OrdersListManager/index.tsx +871 -0
  35. package/themes/business/src/components/OrdersListManager/styles.tsx +123 -0
  36. package/themes/business/src/components/OrdersListManager/utils.tsx +216 -0
  37. package/themes/business/src/components/OrdersOption/index.tsx +351 -59
  38. package/themes/business/src/components/OrdersOption/styles.tsx +95 -7
  39. package/themes/business/src/components/PreviousOrders/index.tsx +65 -46
  40. package/themes/business/src/components/PreviousOrders/styles.tsx +5 -10
  41. package/themes/business/src/components/ReviewCustomer/index.tsx +11 -8
  42. package/themes/business/src/types/index.tsx +4 -0
  43. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  44. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  45. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  46. package/themes/kiosk/index.tsx +2 -0
  47. package/themes/kiosk/src/components/BusinessController/index.tsx +27 -6
  48. package/themes/kiosk/src/components/BusinessController/styles.tsx +1 -1
  49. package/themes/kiosk/src/components/BusinessProductsListing/index.tsx +51 -24
  50. package/themes/kiosk/src/components/Cart/index.tsx +1 -1
  51. package/themes/kiosk/src/components/CartBottomSheet/index.tsx +1 -1
  52. package/themes/kiosk/src/components/CartBottomSheet/styles.tsx +1 -1
  53. package/themes/kiosk/src/components/CartContent/index.tsx +13 -3
  54. package/themes/kiosk/src/components/CartItem/index.tsx +20 -8
  55. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +7 -5
  56. package/themes/kiosk/src/components/CustomerName/index.tsx +89 -88
  57. package/themes/kiosk/src/components/Intro/index.tsx +13 -13
  58. package/themes/kiosk/src/components/LanguageSelector/index.tsx +12 -8
  59. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  60. package/themes/kiosk/src/components/NetworkError/index.tsx +60 -0
  61. package/themes/kiosk/src/components/NetworkError/styles.tsx +11 -0
  62. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  63. package/themes/kiosk/src/components/OrderDetails/index.tsx +2 -2
  64. package/themes/kiosk/src/components/OrderSummary/index.tsx +1 -1
  65. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  66. package/themes/kiosk/src/components/ProductForm/index.tsx +172 -124
  67. package/themes/kiosk/src/components/ProductForm/styles.tsx +1 -1
  68. package/themes/kiosk/src/components/ProductOption/index.tsx +1 -0
  69. package/themes/kiosk/src/components/ProductOption/styles.tsx +1 -0
  70. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  71. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  72. package/themes/kiosk/src/components/shared/OCard.tsx +112 -78
  73. package/themes/kiosk/src/types/index.d.ts +4 -0
  74. package/themes/original/index.tsx +26 -6
  75. package/themes/original/src/components/AnalyticsSegment/index.tsx +127 -0
  76. package/themes/original/src/components/BusinessBasicInformation/index.tsx +11 -7
  77. package/themes/original/src/components/BusinessController/index.tsx +3 -3
  78. package/themes/original/src/components/BusinessMenuList/index.tsx +4 -2
  79. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -121
  80. package/themes/original/src/components/BusinessProductsList/index.tsx +50 -6
  81. package/themes/original/src/components/BusinessProductsListing/index.tsx +13 -10
  82. package/themes/original/src/components/BusinessReviews/index.tsx +4 -3
  83. package/themes/original/src/components/BusinessesListing/index.tsx +23 -22
  84. package/themes/original/src/components/Cart/index.tsx +43 -10
  85. package/themes/original/src/components/Checkout/index.tsx +54 -17
  86. package/themes/original/src/components/Checkout/styles.tsx +7 -0
  87. package/themes/original/src/components/CouponControl/index.tsx +1 -0
  88. package/themes/original/src/components/DriverTips/index.tsx +1 -1
  89. package/themes/original/src/components/ForgotPasswordForm/index.tsx +8 -12
  90. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +9 -2
  91. package/themes/original/src/components/LoginForm/index.tsx +83 -68
  92. package/themes/original/src/components/Messages/index.tsx +19 -21
  93. package/themes/original/src/components/MomentOption/index.tsx +127 -152
  94. package/themes/original/src/components/MomentOption/styles.tsx +42 -18
  95. package/themes/original/src/components/NetworkError/index.tsx +61 -0
  96. package/themes/original/src/components/NetworkError/styles.tsx +11 -0
  97. package/themes/original/src/components/OrderDetails/index.tsx +103 -124
  98. package/themes/original/src/components/OrderProgress/index.tsx +2 -3
  99. package/themes/original/src/components/OrderSummary/index.tsx +34 -1
  100. package/themes/original/src/components/OrdersOption/index.tsx +16 -40
  101. package/themes/original/src/components/OrdersOption/styles.tsx +0 -5
  102. package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -1
  103. package/themes/original/src/components/PaymentOptions/index.tsx +20 -23
  104. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -8
  105. package/themes/original/src/components/PlaceSpot/index.tsx +114 -0
  106. package/themes/original/src/components/PlaceSpot/styles.tsx +11 -0
  107. package/themes/original/src/components/PreviousOrders/index.tsx +4 -0
  108. package/themes/original/src/components/ProductForm/index.tsx +35 -20
  109. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  110. package/themes/original/src/components/ProductOptionSubOption/index.tsx +81 -74
  111. package/themes/original/src/components/ReviewDriver/index.tsx +315 -0
  112. package/themes/original/src/components/ReviewDriver/styles.tsx +38 -0
  113. package/themes/original/src/components/ReviewOrder/index.tsx +307 -186
  114. package/themes/original/src/components/ReviewOrder/styles.tsx +24 -13
  115. package/themes/original/src/components/ReviewProducts/index.tsx +116 -0
  116. package/themes/original/src/components/ReviewProducts/styles.tsx +16 -0
  117. package/themes/original/src/components/SignupForm/index.tsx +173 -154
  118. package/themes/original/src/components/SingleProductCard/index.tsx +6 -13
  119. package/themes/original/src/components/SingleProductCard/styles.tsx +1 -1
  120. package/themes/original/src/components/SingleProductReview/index.tsx +166 -0
  121. package/themes/original/src/components/SingleProductReview/styles.tsx +27 -0
  122. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -72
  123. package/themes/original/src/components/UpsellingProducts/index.tsx +6 -6
  124. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  125. package/themes/original/src/components/UserFormDetails/index.tsx +2 -14
  126. package/themes/original/src/components/UserProfile/index.tsx +13 -6
  127. package/themes/original/src/components/UserProfileForm/index.tsx +16 -8
  128. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  129. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  130. package/themes/original/src/layouts/FloatingBottomContainer.tsx +26 -0
  131. package/themes/original/src/types/index.tsx +47 -10
  132. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +5 -5
  133. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  134. package/src/components/StripeMethodForm/index.tsx +0 -163
@@ -0,0 +1,16 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const ReviewProductsContainer = styled.ScrollView`
4
+ padding: 20px 40px;
5
+ margin-bottom: 100px;
6
+ `
7
+
8
+ export const ActionContainer = styled.View`
9
+ flex-direction: row;
10
+ align-items: center;
11
+ justify-content: space-between;
12
+ padding: 3px 30px;
13
+ `
14
+
15
+ export const SkipButton = styled.TouchableOpacity`
16
+ `
@@ -68,7 +68,6 @@ const SignupFormUI = (props: SignupParams) => {
68
68
 
69
69
  const theme = useTheme();
70
70
 
71
-
72
71
  const style = StyleSheet.create({
73
72
  btnOutline: {
74
73
  backgroundColor: '#FFF',
@@ -77,7 +76,6 @@ const SignupFormUI = (props: SignupParams) => {
77
76
  inputStyle: {
78
77
  marginBottom: 20,
79
78
  borderWidth: 1,
80
- borderColor: theme.colors.border,
81
79
  borderRadius: 7.6,
82
80
  },
83
81
  wrappText: {
@@ -102,7 +100,7 @@ const SignupFormUI = (props: SignupParams) => {
102
100
  const [, t] = useLanguage();
103
101
  const [, { login }] = useSession();
104
102
  const [{ configs }] = useConfig();
105
- const { control, handleSubmit, errors } = useForm();
103
+ const { control, handleSubmit, errors, register, setValue } = useForm();
106
104
 
107
105
  const [passwordSee, setPasswordSee] = useState(false);
108
106
  const [formValues, setFormValues] = useState(null);
@@ -227,7 +225,7 @@ const SignupFormUI = (props: SignupParams) => {
227
225
  handleButtonSignupClick &&
228
226
  handleButtonSignupClick({
229
227
  ...values,
230
- ...phoneInputData.phone,
228
+ ...((phoneInputData.phone.cellphone !== null && phoneInputData.phone.country_phone_code !== null) && {...phoneInputData.phone}),
231
229
  });
232
230
  if (
233
231
  !formState.loading &&
@@ -298,36 +296,23 @@ const SignupFormUI = (props: SignupParams) => {
298
296
 
299
297
  useEffect(() => {
300
298
  if (Object.keys(errors).length > 0) {
301
- // Convert all errors in one string to show in toast provider
302
- const list = Object.values(errors);
303
- if (phoneInputData.error) {
304
- list.push({ message: phoneInputData.error });
305
- }
306
- if (
307
- !phoneInputData.error &&
308
- !phoneInputData.phone.country_phone_code &&
309
- !phoneInputData.phone.cellphone &&
310
- ((validationFields?.fields?.checkout?.cellphone?.enabled &&
311
- validationFields?.fields?.checkout?.cellphone?.required) ||
312
- configs?.verification_phone_required?.value === '1')
313
- ) {
314
- list.push({
315
- message: t(
316
- 'VALIDATION_ERROR_MOBILE_PHONE_REQUIRED',
317
- 'The field Mobile phone is required.',
318
- ),
319
- });
320
- }
321
- let stringError = '';
322
- list.map((item: any, i: number) => {
323
- stringError +=
324
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
325
- });
326
- showToast(ToastType.Error, stringError);
327
299
  setIsLoadingVerifyModal(false);
328
300
  }
329
301
  }, [errors]);
330
302
 
303
+ useEffect(() => {
304
+ register('cellphone', {
305
+ required: isRequiredField('cellphone')
306
+ ? t('VALIDATION_ERROR_MOBILE_PHONE_REQUIRED', 'The field Mobile phone is required').replace('_attribute_', t('CELLPHONE', 'Cellphone'))
307
+ : null
308
+ })
309
+ }, [register])
310
+
311
+ useEffect(() => {
312
+ if (phoneInputData?.phone?.cellphone) setValue('cellphone', phoneInputData?.phone?.cellphone, '')
313
+ else setValue('cellphone', '')
314
+ }, [phoneInputData?.phone?.cellphone])
315
+
331
316
  useEffect(() => {
332
317
  if (verifyPhoneState && !verifyPhoneState?.loading) {
333
318
  if (verifyPhoneState.result?.error) {
@@ -412,48 +397,58 @@ const SignupFormUI = (props: SignupParams) => {
412
397
  !notValidationFields.includes(field.code) &&
413
398
  showField &&
414
399
  showField(field.code) && (
415
- <Controller
416
- key={field.id}
417
- control={control}
418
- render={({ onChange, value }: any) => (
419
- <OInput
420
- placeholder={t(field.name)}
421
- style={style.inputStyle}
422
- icon={
423
- field.code === 'email'
424
- ? theme.images.general.email
425
- : theme.images.general.user
426
- }
427
- value={value}
428
- onChange={(val: any) =>
429
- field.code !== 'email'
430
- ? onChange(val)
431
- : handleChangeInputEmail(val, onChange)
432
- }
433
- autoCapitalize={
434
- field.code === 'email' ? 'none' : 'sentences'
435
- }
436
- autoCorrect={field.code === 'email' && false}
437
- type={
438
- field.code === 'email' ? 'email-address' : 'default'
439
- }
440
- autoCompleteType={
441
- field.code === 'email' ? 'email' : 'off'
442
- }
443
- returnKeyType="next"
444
- blurOnSubmit={false}
445
- forwardRef={(ref: any) => handleRefs(ref, field.code)}
446
- onSubmitEditing={() =>
447
- field.code === 'email'
448
- ? phoneRef?.current?.focus?.()
449
- : handleFocusRef(getNextFieldCode(i))
450
- }
451
- />
400
+ <React.Fragment key={field.id}>
401
+ {errors?.[`${field.code}`] && (
402
+ <OText
403
+ size={14}
404
+ color={theme.colors.danger5}
405
+ weight={'normal'}>
406
+ {errors?.[`${field.code}`]?.message} {errors?.[`${field.code}`]?.type === 'required' && '*'}
407
+ </OText>
452
408
  )}
453
- name={field.code}
454
- rules={getInputRules(field)}
455
- defaultValue=""
456
- />
409
+ <Controller
410
+ control={control}
411
+ render={({ onChange, value }: any) => (
412
+ <OInput
413
+ placeholder={t(field.name)}
414
+ style={style.inputStyle}
415
+ icon={
416
+ field.code === 'email'
417
+ ? theme.images.general.email
418
+ : theme.images.general.user
419
+ }
420
+ value={value}
421
+ onChange={(val: any) =>
422
+ field.code !== 'email'
423
+ ? onChange(val)
424
+ : handleChangeInputEmail(val, onChange)
425
+ }
426
+ autoCapitalize={
427
+ field.code === 'email' ? 'none' : 'sentences'
428
+ }
429
+ autoCorrect={field.code === 'email' && false}
430
+ type={
431
+ field.code === 'email' ? 'email-address' : 'default'
432
+ }
433
+ autoCompleteType={
434
+ field.code === 'email' ? 'email' : 'off'
435
+ }
436
+ returnKeyType="next"
437
+ blurOnSubmit={false}
438
+ forwardRef={(ref: any) => handleRefs(ref, field.code)}
439
+ onSubmitEditing={() =>
440
+ field.code === 'email'
441
+ ? phoneRef?.current?.focus?.()
442
+ : handleFocusRef(getNextFieldCode(i))
443
+ }
444
+ borderColor={errors?.[`${field.code}`] ? theme.colors.danger5 : theme.colors.border}
445
+ />
446
+ )}
447
+ name={field.code}
448
+ rules={getInputRules(field)}
449
+ defaultValue=""
450
+ />
451
+ </React.Fragment>
457
452
  ),
458
453
  )}
459
454
 
@@ -467,6 +462,7 @@ const SignupFormUI = (props: SignupParams) => {
467
462
  returnKeyType: 'next',
468
463
  onSubmitEditing: () => passwordRef?.current?.focus?.(),
469
464
  }}
465
+ isStartValidation={errors?.cellphone}
470
466
  />
471
467
  </View>
472
468
  )}
@@ -499,99 +495,122 @@ const SignupFormUI = (props: SignupParams) => {
499
495
  </View>
500
496
 
501
497
  {configs?.terms_and_conditions?.value === 'true' && (
502
- <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
498
+ <>
499
+ {errors?.termsAccept && (
500
+ <OText
501
+ size={14}
502
+ color={theme.colors.danger5}
503
+ weight={'normal'}>
504
+ {errors?.termsAccept?.message}*
505
+ </OText>
506
+ )}
507
+ <View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20 }}>
508
+ <Controller
509
+ control={control}
510
+ render={({ onChange, value }: any) => (
511
+ <CheckBox
512
+ value={value}
513
+ onValueChange={newValue => {
514
+ onChange(newValue)
515
+ }}
516
+ boxType={'square'}
517
+ tintColors={{
518
+ true: theme.colors.primary,
519
+ false: theme.colors.disabled
520
+ }}
521
+ tintColor={theme.colors.disabled}
522
+ onCheckColor={theme.colors.primary}
523
+ onTintColor={theme.colors.primary}
524
+ style={Platform.OS === 'ios' && style.checkBoxStyle}
525
+ />
526
+ )}
527
+ name='termsAccept'
528
+ rules={{
529
+ required: t('VALIDATION_ERROR_ACCEPTED', 'The _attribute_ must be accepted.').replace('_attribute_', t('TERMS_AND_CONDITIONS', 'Terms & Conditions'))
530
+ }}
531
+ defaultValue={false}
532
+ />
533
+ <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('TERMS_AND_CONDITIONS_TEXT', 'I agree with')}</OText>
534
+ <OButton
535
+ imgRightSrc={null}
536
+ text={t('TERMS_AND_CONDITIONS', 'Terms & Conditions')}
537
+ bgColor='#FFF'
538
+ borderColor='#FFF'
539
+ style={{ paddingLeft: 0, paddingRight: 0, height: 30, shadowColor: '#FFF' }}
540
+ textStyle={{ color: theme.colors.primary, marginLeft: 0, marginRight: 0 }}
541
+ onClick={() => handleOpenTermsUrl(configs?.terms_and_conditions_url?.value)}
542
+ />
543
+ </View>
544
+ </>
545
+
546
+ )}
547
+
548
+ {signupTab !== 'cellphone' && (
549
+ <>
550
+ {errors?.password && (
551
+ <OText
552
+ size={14}
553
+ color={theme.colors.danger5}
554
+ weight={'normal'}>
555
+ {errors?.password?.message} {errors?.password?.type === 'required' && '*'}
556
+ </OText>
557
+ )}
503
558
  <Controller
504
559
  control={control}
505
560
  render={({ onChange, value }: any) => (
506
- <CheckBox
561
+ <OInput
562
+ isSecured={!passwordSee ? true : false}
563
+ placeholder={t('PASSWORD', 'Password')}
564
+ style={style.inputStyle}
565
+ icon={theme.images.general.lock}
566
+ iconCustomRight={
567
+ !passwordSee ? (
568
+ <MaterialCommunityIcons
569
+ name="eye-outline"
570
+ color={theme.colors.disabled}
571
+ size={24}
572
+ onPress={() => setPasswordSee(!passwordSee)}
573
+ />
574
+ ) : (
575
+ <MaterialCommunityIcons
576
+ name="eye-off-outline"
577
+ color={theme.colors.disabled}
578
+ size={24}
579
+ onPress={() => setPasswordSee(!passwordSee)}
580
+ />
581
+ )
582
+ }
507
583
  value={value}
508
- onValueChange={newValue => {
509
- onChange(newValue)
510
- }}
511
- boxType={'square'}
512
- tintColors={{
513
- true: theme.colors.primary,
514
- false: theme.colors.disabled
515
- }}
516
- tintColor={theme.colors.disabled}
517
- onCheckColor={theme.colors.primary}
518
- onTintColor={theme.colors.primary}
519
- style={Platform.OS === 'ios' && style.checkBoxStyle}
584
+ onChange={(val: any) => onChange(val)}
585
+ returnKeyType="done"
586
+ onSubmitEditing={handleSubmit(onSubmit)}
587
+ blurOnSubmit
588
+ forwardRef={passwordRef}
589
+ borderColor={errors?.password ? theme.colors.danger5 : theme.colors.border}
520
590
  />
521
591
  )}
522
- name='termsAccept'
592
+ name="password"
523
593
  rules={{
524
- required: t('VALIDATION_ERROR_ACCEPTED', 'The _attribute_ must be accepted.').replace('_attribute_', t('TERMS_AND_CONDITIONS', 'Terms & Conditions'))
594
+ required: isRequiredField('password')
595
+ ? t(
596
+ 'VALIDATION_ERROR_PASSWORD_REQUIRED',
597
+ 'The field Password is required',
598
+ ).replace('_attribute_', t('PASSWORD', 'password'))
599
+ : null,
600
+ minLength: {
601
+ value: 8,
602
+ message: t(
603
+ 'VALIDATION_ERROR_PASSWORD_MIN_STRING',
604
+ 'The Password must be at least 8 characters.',
605
+ )
606
+ .replace('_attribute_', t('PASSWORD', 'Password'))
607
+ .replace('_min_', 8),
608
+ },
525
609
  }}
526
- defaultValue={false}
527
- />
528
- <OText style={{ fontSize: 14, paddingHorizontal: 5 }}>{t('TERMS_AND_CONDITIONS_TEXT', 'I agree with')}</OText>
529
- <OButton
530
- imgRightSrc={null}
531
- text={t('TERMS_AND_CONDITIONS', 'Terms & Conditions')}
532
- bgColor='#FFF'
533
- borderColor='#FFF'
534
- style={{ paddingLeft: 0, paddingRight: 0, height: 30, shadowColor: '#FFF' }}
535
- textStyle={{ color: theme.colors.primary, marginLeft: 0, marginRight: 0 }}
536
- onClick={() => handleOpenTermsUrl(configs?.terms_and_conditions_url?.value)}
610
+ defaultValue=""
537
611
  />
538
- </View>
539
- )}
612
+ </>
540
613
 
541
- {signupTab !== 'cellphone' && (
542
- <Controller
543
- control={control}
544
- render={({ onChange, value }: any) => (
545
- <OInput
546
- isSecured={!passwordSee ? true : false}
547
- placeholder={t('PASSWORD', 'Password')}
548
- style={style.inputStyle}
549
- icon={theme.images.general.lock}
550
- iconCustomRight={
551
- !passwordSee ? (
552
- <MaterialCommunityIcons
553
- name="eye-outline"
554
- color={theme.colors.disabled}
555
- size={24}
556
- onPress={() => setPasswordSee(!passwordSee)}
557
- />
558
- ) : (
559
- <MaterialCommunityIcons
560
- name="eye-off-outline"
561
- color={theme.colors.disabled}
562
- size={24}
563
- onPress={() => setPasswordSee(!passwordSee)}
564
- />
565
- )
566
- }
567
- value={value}
568
- onChange={(val: any) => onChange(val)}
569
- returnKeyType="done"
570
- onSubmitEditing={handleSubmit(onSubmit)}
571
- blurOnSubmit
572
- forwardRef={passwordRef}
573
- />
574
- )}
575
- name="password"
576
- rules={{
577
- required: isRequiredField('password')
578
- ? t(
579
- 'VALIDATION_ERROR_PASSWORD_REQUIRED',
580
- 'The field Password is required',
581
- ).replace('_attribute_', t('PASSWORD', 'password'))
582
- : null,
583
- minLength: {
584
- value: 8,
585
- message: t(
586
- 'VALIDATION_ERROR_PASSWORD_MIN_STRING',
587
- 'The Password must be at least 8 characters.',
588
- )
589
- .replace('_attribute_', t('PASSWORD', 'Password'))
590
- .replace('_min_', 8),
591
- },
592
- }}
593
- defaultValue=""
594
- />
595
614
  )}
596
615
  </>
597
616
  ) : (
@@ -70,25 +70,18 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
70
70
  const editMode = typeof product?.code !== 'undefined';
71
71
 
72
72
  const removeToBalance = editMode ? product?.quantity : 0;
73
- const cart = orderState.carts[`businessId:${businessId}`];
74
- const productCart = cart?.products?.find(
75
- (prod: any) => prod.id === product?.id,
76
- );
77
- const totalBalance = (productCart?.quantity || 0) - removeToBalance;
73
+ const cartProducts: any = Object.values(orderState.carts).reduce((products: any, _cart: any) => [...products, ..._cart?.products], [])
74
+ const productBalance = cartProducts.reduce((sum: any, _product: any) => sum + (_product.id === product?.id ? _product.quantity : 0), 0)
75
+
76
+ const totalBalance = (productBalance || 0) - removeToBalance
78
77
 
79
78
  const maxCartProductConfig =
80
79
  (stateConfig.configs.max_product_amount
81
80
  ? parseInt(stateConfig.configs.max_product_amount)
82
81
  : 100) - totalBalance;
83
82
 
84
- const productBalance =
85
- (cart?.products?.reduce(
86
- (sum: any, _product: any) =>
87
- sum + (product && _product.id === product?.id ? _product.quantity : 0),
88
- 0,
89
- ) || 0) - removeToBalance;
90
83
  let maxCartProductInventory =
91
- (product?.inventoried ? product?.quantity : undefined) - productBalance;
84
+ (product?.inventoried ? product?.quantity : undefined) - totalBalance;
92
85
  maxCartProductInventory = !isNaN(maxCartProductInventory)
93
86
  ? maxCartProductInventory
94
87
  : maxCartProductConfig;
@@ -139,7 +132,7 @@ export const SingleProductCard = (props: SingleProductCardParams) => {
139
132
  <FastImage
140
133
  style={styles.productStyle}
141
134
  source={{
142
- uri: optimizeImage(product?.images, 'h_75,c_limit'),
135
+ uri: optimizeImage(product?.images, 'h_250,c_limit'),
143
136
  priority: FastImage.priority.normal,
144
137
  }}
145
138
  resizeMode={FastImage.resizeMode.cover}
@@ -30,4 +30,4 @@ export const QuantityContainer = styled.View`
30
30
  export const PricesContainer = styled.View`
31
31
  flex-direction: row;
32
32
  align-items: center;
33
- `
33
+ `
@@ -0,0 +1,166 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import { useLanguage } from 'ordering-components/native'
3
+ import { OText, OButton, OInput } from '../shared'
4
+ import { StyleSheet, TouchableOpacity, View } from 'react-native'
5
+ import AntDesignIcons from 'react-native-vector-icons/AntDesign'
6
+ import { useTheme } from 'styled-components/native'
7
+ import { SingleProductReviewParams } from '../../types'
8
+
9
+ import { reviewCommentList } from '../../../../../src/utils'
10
+
11
+ import {
12
+ ProductContainer,
13
+ ProductHeader,
14
+ LikeHandsActionContainer,
15
+ LikeHandsButton,
16
+ CommentsButtonGroup,
17
+ } from './styles'
18
+
19
+ export const SingleProductReview = (props: SingleProductReviewParams) => {
20
+ const {
21
+ product,
22
+ formState,
23
+ handleChangeFormState,
24
+ } = props
25
+
26
+ const [, t] = useLanguage()
27
+ const theme = useTheme()
28
+
29
+ const styles = StyleSheet.create({
30
+ inputTextArea: {
31
+ borderColor: theme.colors.lightGray,
32
+ borderRadius: 8,
33
+ marginTop: 10,
34
+ marginBottom: 40,
35
+ height: 100,
36
+ alignItems: 'flex-start'
37
+ },
38
+ additionalCommentButton: {
39
+ flexDirection: 'row',
40
+ justifyContent: 'center',
41
+ marginVertical: 10,
42
+ },
43
+ })
44
+
45
+ const [comments, setComments] = useState<Array<any>>([])
46
+ const [extraComment, setExtraComment] = useState('')
47
+ const [isShowTextArea, setIsShowTextArea] = useState(false)
48
+ const [qualification, setQualification] = useState(5)
49
+ const [currentValue, setCurrentValue] = useState(5)
50
+
51
+ const commentsList = reviewCommentList('product')
52
+
53
+ const isSelectedComment = (commentKey: number) => {
54
+ const found = comments.find((comment: any) => comment?.key === commentKey)
55
+ return found
56
+ }
57
+
58
+ const handleChangeComment = (commentItem: any) => {
59
+ const found = comments.find((comment: any) => comment?.key === commentItem.key)
60
+ if (found) {
61
+ const _comments = comments.filter((comment: any) => comment?.key !== commentItem.key)
62
+ setComments(_comments)
63
+ } else {
64
+ setComments([...comments, commentItem])
65
+ }
66
+ }
67
+
68
+ useEffect(() => {
69
+ const value = qualification ? 5 : 1
70
+ setCurrentValue(value)
71
+ if (value !== currentValue) setComments([])
72
+ if (comments?.length === 0 && !extraComment && formState.changes?.length === 0 && qualification === 5) return
73
+ let _comments = ''
74
+ if (comments.length > 0) {
75
+ comments.map(comment => (_comments += comment.content + '. '))
76
+ }
77
+ const _comment = _comments + extraComment
78
+ let found = false
79
+ const _changes = formState.changes.map((item: any) => {
80
+ if (item?.product_id === product?.product_id) {
81
+ found = true
82
+ return {
83
+ product_id: product?.product_id,
84
+ comment: _comment,
85
+ qualification: qualification
86
+ }
87
+ }
88
+ return item
89
+ })
90
+ if (!found) {
91
+ _changes.push({
92
+ product_id: product?.product_id,
93
+ comment: _comment,
94
+ qualification: qualification
95
+ })
96
+ }
97
+ handleChangeFormState && handleChangeFormState(_changes)
98
+ }, [comments, extraComment, qualification])
99
+
100
+ return (
101
+ <>
102
+ <ProductContainer>
103
+ <ProductHeader>
104
+ <OText numberOfLines={1} style={{ flex: 1 }} color={theme.colors.textNormal}>{product?.name}</OText>
105
+ <LikeHandsActionContainer>
106
+ <LikeHandsButton
107
+ isLike
108
+ onPress={() => setQualification(5)}
109
+ >
110
+ <AntDesignIcons name='like2' size={20} color={qualification === 5 ? theme.colors.primary : theme.colors.lightGray} />
111
+ </LikeHandsButton>
112
+ <LikeHandsButton onPress={() => setQualification(1)}>
113
+ <AntDesignIcons name='dislike2' size={20} color={qualification === 1 ? theme.colors.primary : theme.colors.lightGray} />
114
+ </LikeHandsButton>
115
+ </LikeHandsActionContainer>
116
+ </ProductHeader>
117
+ <CommentsButtonGroup>
118
+ {commentsList[qualification === 5 ? 'like' : 'dislike']?.map(commentItem => (
119
+ <OButton
120
+ key={commentItem.key}
121
+ text={commentItem.content}
122
+ bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
123
+ borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
124
+ textStyle={{
125
+ color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.textNormal,
126
+ fontSize: 13,
127
+ paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
128
+ }}
129
+ style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
130
+ imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
131
+ imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
132
+ onClick={() => handleChangeComment(commentItem) }
133
+ />
134
+ ))}
135
+ </CommentsButtonGroup>
136
+ <TouchableOpacity
137
+ style={styles.additionalCommentButton}
138
+ onPress={() => setIsShowTextArea(!isShowTextArea)}
139
+ >
140
+ <OText
141
+ color={isShowTextArea ? theme.colors.primary : theme.colors.disabled}
142
+ style={{
143
+ borderBottomColor: isShowTextArea ? theme.colors.primary : theme.colors.disabled,
144
+ borderBottomWidth: 1
145
+ }}
146
+ >
147
+ {t('ADDITIONAL_COMMENTS', 'Additional comments')}
148
+ </OText>
149
+ </TouchableOpacity>
150
+ {isShowTextArea && (
151
+ <View>
152
+ <OText style={{ marginTop: 10 }} color={theme.colors.textNormal}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText>
153
+ <OInput
154
+ name='comments'
155
+ onChange={(val: any) => {
156
+ setExtraComment(val.target.value)
157
+ }}
158
+ style={styles.inputTextArea}
159
+ multiline
160
+ />
161
+ </View>
162
+ )}
163
+ </ProductContainer>
164
+ </>
165
+ )
166
+ }
@@ -0,0 +1,27 @@
1
+ import styled, { css } from 'styled-components/native'
2
+
3
+ export const ProductContainer = styled.View`
4
+ margin-bottom: 15px;
5
+ `
6
+
7
+ export const ProductHeader = styled.View`
8
+ flex-direction: row;
9
+ align-items: center;
10
+ justify-content: space-between;
11
+ margin-bottom: 10px;
12
+ `
13
+
14
+ export const LikeHandsActionContainer = styled.View`
15
+ flex-direction: row;
16
+ `
17
+
18
+ export const LikeHandsButton = styled.TouchableOpacity`
19
+ ${(props: any) => props.isLike && css`
20
+ margin-horizontal: 15px;
21
+ `}
22
+ `
23
+
24
+ export const CommentsButtonGroup = styled.View`
25
+ flex-direction: row;
26
+ flex-wrap: wrap;
27
+ `