gatsby-matrix-theme 7.1.13 → 7.1.14

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/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [7.1.14](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v7.1.13...v7.1.14) (2022-05-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add privacyText ([e54910f](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/e54910f1f2dfab1c611d7615f263e22ac2bd46f0))
7
+ * clean up the code ([8363435](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/83634355e60027bf4cf5e5d50194cd9e0de54eee))
8
+ * cleanup ([be930bb](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/be930bb11c4d595b0942152bc61816be895fc5ee))
9
+ * fix bug ([43d433e](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/43d433e7f89299d88cef87e59d8977605a03a292))
10
+ * fix the logic ([1928992](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/1928992b62f8688afc9480390e5706e2ae073fd7))
11
+ * fix validation ([083924d](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/083924d90aed68d03cc2b7bd975a968df374d74f))
12
+ * validation email ([6d8da87](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/6d8da87172a1539fcf463c8ca11700d5e0ec1baf))
13
+
14
+
15
+ * Merge branch 'jetmir/fixLogicNewsletter' into 'master' ([19cd274](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/19cd274d4e4f8d1173d10e8c6b1c955451eccd6d))
16
+
1
17
  ## [7.1.13](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v7.1.12...v7.1.13) (2022-05-26)
2
18
 
3
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-matrix-theme",
3
- "version": "7.1.13",
3
+ "version": "7.1.14",
4
4
  "main": "index.js",
5
5
  "description": "Matrix Theme NPM Package",
6
6
  "author": "",
@@ -10,12 +10,13 @@ import styles from './newsletter-form.module.scss';
10
10
  const NewsletterForm = ({
11
11
  handleApi,
12
12
  setErr,
13
+ setLogading,
13
14
  redirectUrl,
14
- privacyText,
15
+ privacyText = 'By subscribing, you confirm that you are over 18 years of age and that you accept our',
15
16
  formText = {
16
17
  placeholderName: 'John Doe',
17
18
  placeholderEmail: 'johndoe@email.com',
18
- placeholderPhoneNumber: '123456789',
19
+ placeholderPhoneNumber: '08XXXXXXXX',
19
20
  buttonText: 'Submit',
20
21
  thankYouText: null,
21
22
  textAboveEmail: 'Email address',
@@ -23,8 +24,6 @@ const NewsletterForm = ({
23
24
  textAbovePhoneNumber: 'Phone number',
24
25
  mainText: 'You get more than 405 free spins',
25
26
  subscribeText: 'Subscribe to our newsletter and get more than 405 free spins instantly.',
26
- redirectUrl,
27
- privacyText,
28
27
  },
29
28
  }) => {
30
29
  // eslint-disable-next-line react/destructuring-assignment
@@ -32,7 +31,7 @@ const NewsletterForm = ({
32
31
  const form = useRef(null);
33
32
  const [ip, setIP] = useState('');
34
33
  const [error, setError] = useState(false);
35
- const [toggleSubscribe, setToggleSubscribe] = useState(false);
34
+ const [loading, setLoading] = useState(false);
36
35
  const { translations } = useContext(Context) || {};
37
36
 
38
37
  const validationForm = (e) => {
@@ -48,7 +47,7 @@ const NewsletterForm = ({
48
47
  e.name.classList.remove(styles.error);
49
48
  }
50
49
 
51
- if (!e.email.value.match(/^([\w.%+-]+)@([\w-]+\.)+([\w]{2,})$/i)) {
50
+ if (!e.phone?.value && !e.email.value.match(/^([\w.%+-]+)@([\w-]+\.)+([\w]{2,})$/i)) {
52
51
  emailValidate = false;
53
52
  e.email.classList.add(styles.error);
54
53
  } else {
@@ -56,7 +55,7 @@ const NewsletterForm = ({
56
55
  e.email.classList.remove(styles.error);
57
56
  }
58
57
 
59
- if (e.phone) {
58
+ if (e.phone && !e.email?.value) {
60
59
  if (!e.phone.value && e.phone.value.trim() === '') {
61
60
  numberValidate = false;
62
61
  e.phone.classList.add(styles.error);
@@ -67,7 +66,6 @@ const NewsletterForm = ({
67
66
  }
68
67
 
69
68
  if (nameValidate && (emailValidate || numberValidate)) {
70
- setToggleSubscribe(true);
71
69
  return true;
72
70
  }
73
71
  return false;
@@ -91,6 +89,7 @@ const NewsletterForm = ({
91
89
  const bacomApi = async (name, email) => {
92
90
  // eslint-disable-next-line no-bitwise
93
91
  const timestamp = (Date.now() / 1000) | 0;
92
+ setLoading(true);
94
93
  await fetch(
95
94
  `https://bacom.dk/subscribe/gig/?firstname=${name}&user_ip=${ip}&ref_name=${process.env.BACOM_REF_NAME}&ref_url=${process.env.BACOM_REF_URL}&timestamp=${timestamp}&country=${process.env.COUNTRY}&email=${email}`,
96
95
  {
@@ -103,6 +102,7 @@ const NewsletterForm = ({
103
102
  ).then((res) =>
104
103
  res.text().then((text) => {
105
104
  text === 'OK' ? (window.location.href = redirectUrl) : setError(true);
105
+ setLoading(false);
106
106
  })
107
107
  );
108
108
  };
@@ -123,49 +123,54 @@ const NewsletterForm = ({
123
123
 
124
124
  return (
125
125
  <>
126
- {!toggleSubscribe && <p className={styles.maintext}>{formText.mainText}</p>}
127
- {!toggleSubscribe && (
128
- <p
129
- dangerouslySetInnerHTML={{ __html: formText.subscribeText }}
130
- className={styles.subscribe}
131
- />
132
- )}
133
- {!error && !toggleSubscribe ? (
134
- <form ref={form} onSubmit={handelSubmit}>
135
- {formText.textAboveName ? (
136
- <p className={styles.textAboveInput}>{formText.textAboveName}</p>
137
- ) : null}
138
-
139
- <input
140
- className={styles.input}
141
- placeholder={formText.placeholderName}
142
- type="text"
143
- name="name"
144
- />
145
- {formText.textAboveEmail ? (
146
- <p className={styles.textAboveInput}>{formText.textAboveEmail}</p>
147
- ) : null}
148
-
149
- <input
150
- className={styles.input}
151
- placeholder={formText.placeholderEmail}
152
- type="email"
153
- name="email"
126
+ {!error ? (
127
+ <>
128
+ <p className={styles.maintext}>{formText.mainText}</p>
129
+ <p
130
+ dangerouslySetInnerHTML={{ __html: formText.subscribeText }}
131
+ className={styles.subscribe}
154
132
  />
155
- {formText.textAbovePhoneNumber ? (
156
- <p className={styles.textAboveInput}>{formText.textAbovePhoneNumber}</p>
157
- ) : null}
158
133
 
159
- {formText.placeholderPhoneNumber && (
134
+ <form ref={form} onSubmit={handelSubmit}>
135
+ {formText.textAboveName ? (
136
+ <p className={styles.textAboveInput}>{formText.textAboveName}</p>
137
+ ) : null}
138
+
139
+ <input
140
+ className={styles.input}
141
+ placeholder={formText.placeholderName}
142
+ type="text"
143
+ name="name"
144
+ />
145
+ {formText.textAboveEmail ? (
146
+ <p className={styles.textAboveInput}>{formText.textAboveEmail}</p>
147
+ ) : null}
148
+
160
149
  <input
161
150
  className={styles.input}
162
- placeholder={formText.placeholderPhoneNumber}
163
- type="tel"
164
- name="phone"
151
+ placeholder={formText.placeholderEmail}
152
+ type="email"
153
+ name="email"
154
+ />
155
+ {formText.textAbovePhoneNumber ? (
156
+ <p className={styles.textAboveInput}>{formText.textAbovePhoneNumber}</p>
157
+ ) : null}
158
+
159
+ {formText.placeholderPhoneNumber && (
160
+ <input
161
+ className={styles.input}
162
+ placeholder={formText.placeholderPhoneNumber}
163
+ type="tel"
164
+ name="phone"
165
+ />
166
+ )}
167
+ <PrivacyandSuccess
168
+ loading={setLogading || loading}
169
+ btnText={formText.buttonText}
170
+ privacyText={privacyText}
165
171
  />
166
- )}
167
- <PrivacyandSuccess btnText={formText.buttonText} privacyText={formText.privacyText} />
168
- </form>
172
+ </form>
173
+ </>
169
174
  ) : (
170
175
  <span>
171
176
  {translate(
@@ -194,6 +199,7 @@ NewsletterForm.propTypes = {
194
199
  setErr: PropTypes.bool,
195
200
  redirectUrl: PropTypes.string,
196
201
  privacyText: PropTypes.string,
202
+ setLogading: PropTypes.bool,
197
203
  };
198
204
 
199
205
  export default NewsletterForm;
@@ -3,18 +3,19 @@ import PropTypes from 'prop-types';
3
3
  import Button from 'gatsby-core-theme/src/components/atoms/button';
4
4
  import styles from './newsletter-privacy&button.module.scss';
5
5
 
6
- const PrivacyandSuccess = ({ privacyText, btnText }) => (
6
+ const PrivacyandSuccess = ({ privacyText, btnText, loading }) => (
7
7
  <div className={styles.display}>
8
8
  {privacyText ? (
9
9
  <p className={styles.privacytext} dangerouslySetInnerHTML={{ __html: privacyText }} />
10
10
  ) : null}
11
- <Button className={styles.button} btnText={btnText} isButton />
11
+ <Button disabled={loading} className={styles.button} btnText={btnText} isButton />
12
12
  </div>
13
13
  );
14
14
 
15
15
  PrivacyandSuccess.propTypes = {
16
16
  privacyText: PropTypes.string,
17
17
  btnText: PropTypes.string,
18
+ loading: PropTypes.bool,
18
19
  };
19
20
 
20
21
  export default PrivacyandSuccess;
@@ -11,21 +11,7 @@ import Button from '../../atoms/newsletter/toggle-button/index';
11
11
  import Form from '../../atoms/newsletter/form/index';
12
12
  import styles from './newsletter.module.scss';
13
13
 
14
- const Newsletter = ({
15
- page,
16
- mainText = 'You get more than 405 free spins',
17
- subscribeText = 'Subscribe to our newsletter and get more than 405 free spins instantly.',
18
- placeholderName = 'Name',
19
- textAboveName = 'Name',
20
- placeholderEmail = 'Email',
21
- textAboveEmail = 'Something to be added',
22
- placeholderPhoneNumber = '00000000',
23
- textAbovePhoneNumber = 'Something to be added',
24
- privacyText = 'By subscribing, you confirm that you are over 18 years of age and that you accept our',
25
- openBtnText = 'FÅ 405 FREE SPINS UMIDDELBART',
26
- buttonText = 'Hent dine freespins',
27
- footer = false,
28
- }) => {
14
+ const Newsletter = ({ page, openBtnText = 'Unlock Exclusive Bonuses', footer = false }) => {
29
15
  const [toggleNewsetter, setToggleNewsletter] = useState(false);
30
16
  const redirectUrl =
31
17
  page?.path === '/'
@@ -56,19 +42,7 @@ const Newsletter = ({
56
42
  : styles.newsletter
57
43
  }
58
44
  >
59
- <Form
60
- placeholderName={placeholderName}
61
- textAboveName={textAboveName}
62
- placeholderEmail={placeholderEmail}
63
- textAboveEmail={textAboveEmail}
64
- placeholderPhoneNumber={placeholderPhoneNumber}
65
- textAbovePhoneNumber={textAbovePhoneNumber}
66
- buttonText={buttonText}
67
- redirectUrl={redirectUrl}
68
- privacyText={privacyText}
69
- mainText={mainText}
70
- subscribeText={subscribeText}
71
- />
45
+ <Form redirectUrl={redirectUrl} />
72
46
  {!footer ? (
73
47
  <MdClose className={styles.closeBtn} onClick={() => setToggleNewsletter(false)} />
74
48
  ) : null}
@@ -78,17 +52,7 @@ const Newsletter = ({
78
52
  };
79
53
 
80
54
  Newsletter.propTypes = {
81
- placeholderName: PropTypes.string,
82
- textAboveName: PropTypes.string,
83
- placeholderEmail: PropTypes.string,
84
- privacyText: PropTypes.string,
85
55
  openBtnText: PropTypes.string,
86
- buttonText: PropTypes.string,
87
- textAboveEmail: PropTypes.string,
88
- placeholderPhoneNumber: PropTypes.string,
89
- textAbovePhoneNumber: PropTypes.string,
90
- mainText: PropTypes.string,
91
- subscribeText: PropTypes.string,
92
56
  page: PropTypes.shape({
93
57
  path: PropTypes.string,
94
58
  template: PropTypes.string,
@@ -345,4 +345,4 @@
345
345
 
346
346
 
347
347
 
348
- window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/**/**/*.stories.js","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.js)$"},{"titlePrefix":"","directory":"./src","files":"**/**/**/**/*.stories.js","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.js)$"},{"titlePrefix":"","directory":"./src","files":"**/**/**/**/**/*.stories.js","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.js)$"}];</script><script src="runtime~main.7aedec23.iframe.bundle.js"></script><script src="40.ddf44139.iframe.bundle.js"></script><script src="main.6d5b234e.iframe.bundle.js"></script></body></html>
348
+ window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/**/**/*.stories.js","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.js)$"},{"titlePrefix":"","directory":"./src","files":"**/**/**/**/*.stories.js","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.js)$"},{"titlePrefix":"","directory":"./src","files":"**/**/**/**/**/*.stories.js","importPathMatcher":"^\\.[\\\\/](?:src(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.js)$"}];</script><script src="runtime~main.7aedec23.iframe.bundle.js"></script><script src="40.ddf44139.iframe.bundle.js"></script><script src="main.18c621ed.iframe.bundle.js"></script></body></html>