@capillarytech/creatives-library 7.17.141 → 7.17.142

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.
@@ -9,6 +9,7 @@ import { get, isEmpty, cloneDeep, isEqual } from 'lodash';
9
9
  import styled from 'styled-components';
10
10
  import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
11
11
  import CapRow from '@capillarytech/cap-ui-library/CapRow';
12
+ import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
12
13
  import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
13
14
  import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
14
15
  import CapTooltipWithInfo from '@capillarytech/cap-ui-library/CapTooltipWithInfo';
@@ -850,7 +851,11 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
850
851
  const extraSecurityFooter = ({ target: { checked = false } } = {}) => {
851
852
  setSecurityWarningReqd(checked);
852
853
  setExpiryMinutes(0);
853
- setTemplateFooter('');
854
+ if (checked) {
855
+ setTemplateFooter(formatMessage(messages.codeExpiryNumMinutes).replace(formatMessage(messages.numMinutes), ''));
856
+ } else {
857
+ setTemplateFooter("");
858
+ }
854
859
  const error = templateMessageErrorHandler(templateMessage);
855
860
  setTemplateMessageError(error);
856
861
  };
@@ -903,35 +908,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
903
908
  </>
904
909
  );
905
910
  };
906
-
907
- const renderExtraSecurityText = () => {
908
- const isDisabled =
909
- isEditFlow ||
910
- templateMessage?.length + UNSUBSCRIBE_TEXT_LENGTH >
911
- TEMPLATE_MESSAGE_MAX_LENGTH;
912
-
913
- return (
914
- <>
915
- <CapColumn span={12}>
916
- <CapCheckbox
917
- className={`whatsapp-unsubscribe-checkbox ${
918
- isEditFlow
919
- ? 'whatsapp-edit-unsubscribe-checkbox'
920
- : 'whatsapp-create-unsubscribe-checkbox'
921
- }`}
922
- onChange={unsubscribeHandler}
923
- checked={unsubscribeRequired}
924
- disabled={isDisabled}
925
- autoFocus={true}
926
- >
927
- <CapLabel.CapLabelInline type="label9">
928
- {formatMessage(messages.templateSecurityDisclaimer)}
929
- </CapLabel.CapLabelInline>
930
- </CapCheckbox>
931
- </CapColumn>
932
- </>
933
- );
934
- };
911
+
935
912
  const maxLengthByType = (type) => {
936
913
  switch (type) {
937
914
  case MESSAGE_TEXT:
@@ -1115,7 +1092,10 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1115
1092
  if (value === WHATSAPP_CATEGORIES.authentication) {
1116
1093
  setTemplateHeader('');
1117
1094
  setTemplateFooter('');
1095
+ setExpiryMinutes(0);
1118
1096
  setUnsubscribeRequired(false);
1097
+ setCtadata({});
1098
+ setQuickReplyData({});
1119
1099
  setTemplateMessage(formatMessage(messages.authenticationMsg));
1120
1100
  } else {
1121
1101
  setTemplateMessage('');
@@ -1626,16 +1606,22 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1626
1606
  </CapHeading>
1627
1607
  }
1628
1608
  suffix={
1629
- <CapButton
1630
- type="flat"
1631
- isAddBtn
1632
- onClick={onMessageAddVar}
1633
- disabled={
1634
- (addedVarCount >= 19 || templateMessageError) && templateMessage
1635
- }
1636
- >
1637
- {formatMessage(messages.addVar)}
1638
- </CapButton>
1609
+ <>
1610
+ {!isAuthenticationTemplate && (
1611
+ <CapButton
1612
+ data-testid="suffix-button"
1613
+ type="flat"
1614
+ isAddBtn
1615
+ onClick={onMessageAddVar}
1616
+ disabled={
1617
+ (addedVarCount >= 19 || templateMessageError) &&
1618
+ templateMessage
1619
+ }
1620
+ >
1621
+ {formatMessage(messages.addVar)}
1622
+ </CapButton>
1623
+ )}
1624
+ </>
1639
1625
  }
1640
1626
  />
1641
1627
  <CapRow className="whatsapp-create-template-message-input">
@@ -1654,7 +1640,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1654
1640
  value={templateMessage || ""}
1655
1641
  disabled={isAuthenticationTemplate}
1656
1642
  />
1657
- {isAuthenticationTemplate ? renderExtraSecurityText() : renderUnsubscribeText()}
1643
+ {renderUnsubscribeText()}
1658
1644
  </CapRow>
1659
1645
  {renderMessageLength(MESSAGE_TEXT)}
1660
1646
  {/* this section if for footer in create mode */}
@@ -1680,52 +1666,87 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1680
1666
  }
1681
1667
  />
1682
1668
  <CapRow className="whatsapp-create-template-message-input whatsapp-create-template-header-input">
1683
- {isAuthenticationTemplate ?
1669
+ {isAuthenticationTemplate ? (
1684
1670
  <CapRow className="whatsapp-extra-security-footer">
1685
1671
  <CapCheckbox
1686
1672
  onChange={extraSecurityFooter}
1687
1673
  checked={securityWarningReqd}
1688
1674
  disabled={isEditFlow}
1689
1675
  autoFocus={true}
1690
- children={formatMessage(messages.expirationWarning)}
1691
- className="whatsapp-extra-security-footer-checkbox"
1692
- />
1693
- {securityWarningReqd && <>
1694
- <CapRow className='whatsapp-extra-security-footer-input'>
1695
- {formatMessage(messages.codeExpiresIn)}
1696
- <CapInput.Number min={0} placeholder={formatMessage(messages.enterExpiryTime)} onChange={(event) => changeExpiryMinutes(event)} />
1697
- {formatMessage(messages.minutes)}
1698
- </CapRow>
1699
- <CapRow className='whatsapp-extra-security-footer-note' >
1700
- {formatMessage(messages.expiryCodeNote)}
1701
- <CapTooltip title={formatMessage(messages.checkExpiryCode)}>
1702
- <CapButton type="flat" className="add-btn" onClick={() =>
1703
- window.open(
1704
- `${window.location.origin}${OTP_CONFIG_URI}`,
1705
- '_blank',
1706
- )
1707
- }>{formatMessage(messages.checkExpiryCode)}
1708
- </CapButton>
1709
- </CapTooltip>
1710
- </CapRow>
1711
- </>}
1712
- </CapRow> :
1713
- <TextArea
1714
- id="whatsapp-create-template-message-input"
1715
- autosize={{ minRows: 1, maxRows: 5 }}
1716
- placeholder={formatMessage(messages.templateMessagePlaceholder)}
1717
- onChange={onTemplateFooterChanges}
1718
- errorMessage={
1719
- templateFooterError && (
1720
- <CapError className="whatsapp-template-message-error">
1721
- {templateFooterError}
1722
- </CapError>
1723
- )
1724
- }
1725
- value={templateFooter || ""}
1726
- disabled={isAuthenticationTemplate}
1727
- />
1728
- }
1676
+ className="whatsapp-unsubscribe-checkbox"
1677
+ >
1678
+ <CapLabel.CapLabelInline
1679
+ type="label2"
1680
+ className="whatsapp-render-unsubscribe-text"
1681
+ >
1682
+ {formatMessage(messages.expirationWarning)}
1683
+ </CapLabel.CapLabelInline>
1684
+ </CapCheckbox>
1685
+ {securityWarningReqd && (
1686
+ <>
1687
+ <CapRow className="whatsapp-extra-security-footer-input">
1688
+ {formatMessage(messages.codeExpiresIn)}
1689
+ <CapInput.Number
1690
+ min={0}
1691
+ max={90}
1692
+ placeholder={formatMessage(messages.enterExpiryTime)}
1693
+ onChange={(event) => changeExpiryMinutes(event)}
1694
+ />
1695
+ {formatMessage(messages.minutes)}
1696
+ </CapRow>
1697
+ <CapRow className="whatsapp-extra-security-footer-note">
1698
+ {formatMessage(messages.expiryCodeNote)}
1699
+ <CapTooltip
1700
+ title={
1701
+ <CapHeader
1702
+ titleClass="whatsapp-tooltip-header"
1703
+ descriptionClass="whatsapp-tooltip-header"
1704
+ size="regular"
1705
+ title={formatMessage(
1706
+ messages.checkExpiryTooltipHeader
1707
+ )}
1708
+ description={formatMessage(
1709
+ messages.checkExpiryTooltipDesc
1710
+ )}
1711
+ />
1712
+ }
1713
+ >
1714
+
1715
+ <CapButton
1716
+ type="flat"
1717
+ className="add-btn"
1718
+ onClick={() =>
1719
+ window.open(
1720
+ `${window.location.origin}${OTP_CONFIG_URI}`,
1721
+ "_blank"
1722
+ )
1723
+ }
1724
+ >
1725
+ {formatMessage(messages.checkExpiryCode)}
1726
+ <CapIcon size="s" type="launch"/>
1727
+ </CapButton>
1728
+ </CapTooltip>
1729
+ </CapRow>
1730
+ </>
1731
+ )}
1732
+ </CapRow>
1733
+ ) : (
1734
+ <TextArea
1735
+ id="whatsapp-create-template-message-input"
1736
+ autosize={{ minRows: 1, maxRows: 5 }}
1737
+ placeholder={formatMessage(messages.templateMessagePlaceholder)}
1738
+ onChange={onTemplateFooterChanges}
1739
+ errorMessage={
1740
+ templateFooterError && (
1741
+ <CapError className="whatsapp-template-message-error">
1742
+ {templateFooterError}
1743
+ </CapError>
1744
+ )
1745
+ }
1746
+ value={templateFooter || ""}
1747
+ disabled={isAuthenticationTemplate}
1748
+ />
1749
+ )}
1729
1750
  </CapRow>
1730
1751
  {renderMessageLength(FOOTER_TEXT)}
1731
1752
  </>
@@ -2158,7 +2179,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2158
2179
  ctaData,
2159
2180
  }),
2160
2181
  ...(isAuthenticationTemplate && {
2161
- ctaData : [{text: formatMessage(globalMessages.autofill)}]
2182
+ ctaData : [{text: formatMessage(globalMessages.autofill), type: WHATSAPP_CATEGORIES.authentication}]
2162
2183
  }),
2163
2184
  ...(isBtnTypeQuickReply && {
2164
2185
  quickReplyData,
@@ -205,7 +205,7 @@
205
205
  font-weight: $FONT_WEIGHT_MEDIUM;
206
206
  }
207
207
  .whatsapp-extra-security-footer {
208
- margin-bottom: $CAP_SPACE_04;
208
+ margin-bottom: 1rem;
209
209
  display: flex;
210
210
  justify-content: flex-start;
211
211
  flex-direction: column;
@@ -213,6 +213,7 @@
213
213
  gap: $CAP_SPACE_08;
214
214
 
215
215
  .whatsapp-extra-security-footer-note {
216
+ font-size: small;
216
217
  margin-top: $CAP_SPACE_04;
217
218
  display: inline-flex;
218
219
  padding-left: $CAP_SPACE_12;
@@ -220,10 +221,11 @@
220
221
  background: $CAP_PURPLE04;
221
222
  align-items: center;
222
223
  justify-content: space-between;
223
- margin-right: $CAP_SPACE_12;
224
224
 
225
225
  .add-btn {
226
+ display: flex;
226
227
  background-color: inherit;
228
+ align-items: center;
227
229
  }
228
230
  }
229
231
 
@@ -232,9 +234,9 @@
232
234
  align-items: center;
233
235
  gap: $CAP_SPACE_04;
234
236
  }
235
-
236
- .whatsapp-extra-security-footer-checkbox {
237
- margin-right: auto;
238
- }
239
237
  }
238
+
239
+ }
240
+ .whatsapp-tooltip-header{
241
+ color: $CAP_G10;
240
242
  }
@@ -305,7 +305,7 @@ export default defineMessages({
305
305
  },
306
306
  btnDesc: {
307
307
  id: `${prefix}.btnDesc`,
308
- defaultMessage: 'These will be show clickable buttons below your message.',
308
+ defaultMessage: 'These will be clickable buttons below your message.',
309
309
  },
310
310
  btnTypeNone: {
311
311
  id: `${prefix}.btnTypeNone`,
@@ -674,7 +674,7 @@ export default defineMessages({
674
674
  },
675
675
  checkExpiryCode: {
676
676
  id: `${prefix}.checkExpiryCode`,
677
- defaultMessage: 'Check here',
677
+ defaultMessage: 'OTP settings',
678
678
  },
679
679
  expiryCodeNote:{
680
680
  id: `${prefix}.expiryCodeNote`,
@@ -686,7 +686,7 @@ export default defineMessages({
686
686
  },
687
687
  minutes:{
688
688
  id: `${prefix}.minutes`,
689
- defaultMessage: 'Minutes',
689
+ defaultMessage: 'minutes',
690
690
  },
691
691
  codeExpiryNumMinutes:{
692
692
  id: `${prefix}.codeExpiryNumMinutes`,
@@ -707,5 +707,13 @@ export default defineMessages({
707
707
  enterExpiryTime:{
708
708
  id: `${prefix}.enterExpiryTime`,
709
709
  defaultMessage: "Enter expiry time"
710
- }
710
+ },
711
+ checkExpiryTooltipHeader: {
712
+ id: `${prefix}.checkExpiryTooltipHeader`,
713
+ defaultMessage: 'Open OTP settings in new tab',
714
+ },
715
+ checkExpiryTooltipDesc: {
716
+ id: `${prefix}.checkExpiryTooltipDesc`,
717
+ defaultMessage: 'To check the configured expiry time that is same for all OTPs',
718
+ },
711
719
  });