gatsby-core-theme 44.4.21 → 44.4.23
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 +14 -0
- package/package.json +1 -1
- package/src/components/molecules/comment/index.js +2 -2
- package/src/components/molecules/leave-comment-form/index.js +5 -4
- package/src/components/organisms/form/index.js +15 -4
- package/src/resolver/comments.mjs +2 -0
- package/src/resolver/comments.test.js +1 -0
- package/tests/factories/comments/comments.factory.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [44.4.23](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.4.22...v44.4.23) (2025-07-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* comments enhancing ([f81d966](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/f81d966f04711a59c67088c44707a18507453ea9))
|
|
7
|
+
|
|
8
|
+
## [44.4.22](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.4.21...v44.4.22) (2025-07-24)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* removed typecasting from comment id ([7e84117](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/7e84117d6425fbfd31b0c347208805b2a02312dd))
|
|
14
|
+
|
|
1
15
|
## [44.4.21](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.4.20...v44.4.21) (2025-07-23)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import useTranslate from '~hooks/useTranslate/useTranslate';
|
|
|
12
12
|
import styles from './comment.module.scss';
|
|
13
13
|
|
|
14
14
|
const Comment = ({ pageContext, comment, authors, isReply }) => {
|
|
15
|
-
const commentName = comment?.author_id ? authors?.[comment?.author_id]?.name : comment.
|
|
15
|
+
const commentName = comment?.author_id ? authors?.[comment?.author_id]?.name : comment.author_name;
|
|
16
16
|
const commentJobTitle = comment?.author_id ? authors?.[comment?.author_id]?.author_title : undefined;
|
|
17
17
|
const date = new Date(comment.updated_at);
|
|
18
18
|
const day = String(date.getUTCDate()).padStart(2, '0');
|
|
@@ -89,7 +89,7 @@ Comment.propTypes = {
|
|
|
89
89
|
comment: PropTypes.shape({
|
|
90
90
|
comment_id: PropTypes.number,
|
|
91
91
|
author_id: PropTypes.number,
|
|
92
|
-
|
|
92
|
+
author_name: PropTypes.string,
|
|
93
93
|
email: PropTypes.string,
|
|
94
94
|
comment: PropTypes.string,
|
|
95
95
|
updated_at: PropTypes.string,
|
|
@@ -15,19 +15,19 @@ const LeaveCommentForm = ({
|
|
|
15
15
|
showLabels = true,
|
|
16
16
|
showButtonIcon = false,
|
|
17
17
|
buttonLabel = 'Add Comment',
|
|
18
|
-
successMessage = 'Comment
|
|
18
|
+
successMessage = 'Comment Submitted for Approval',
|
|
19
19
|
failMessage = 'Comment Not Added',
|
|
20
20
|
validationMessage = 'Fill all required fields',
|
|
21
21
|
buttonIcon = <FaArrowRight fontSize={20} title="Right-pointing Arrow Icon" />,
|
|
22
22
|
}) => {
|
|
23
23
|
const activeMarket = page?.market;
|
|
24
24
|
|
|
25
|
-
const customSubmit = (form) => {
|
|
25
|
+
const customSubmit = (form, resetForm) => {
|
|
26
26
|
const formData = new FormData(form);
|
|
27
27
|
const data = Object.fromEntries(formData.entries());
|
|
28
28
|
|
|
29
29
|
if(data?.["g-recaptcha-response"] === '' || !data?.tnc) return;
|
|
30
|
-
if(parentCommentID) data.parent_id =
|
|
30
|
+
if(parentCommentID) data.parent_id = parentCommentID;
|
|
31
31
|
|
|
32
32
|
data.reference_id = page?.id;
|
|
33
33
|
data.site_id = parseInt(process.env.SITE_ID);
|
|
@@ -35,7 +35,7 @@ const LeaveCommentForm = ({
|
|
|
35
35
|
|
|
36
36
|
data.market_short_code = activeMarket;
|
|
37
37
|
|
|
38
|
-
if(data?.post_anonymously)
|
|
38
|
+
if(!data?.post_anonymously) data.author_name = data?.name;
|
|
39
39
|
if(!data?.rate) delete data?.rate;
|
|
40
40
|
|
|
41
41
|
delete data?.post_anonymously;
|
|
@@ -53,6 +53,7 @@ const LeaveCommentForm = ({
|
|
|
53
53
|
.post('/api/post-comment', data, headers)
|
|
54
54
|
.then((response) => {
|
|
55
55
|
response.ok = response.status === 200;
|
|
56
|
+
if (response.ok) resetForm();
|
|
56
57
|
resolve(response);
|
|
57
58
|
})
|
|
58
59
|
.catch((error) => reject(error?.response?.data?.errors?.join() || error.message));
|
|
@@ -50,6 +50,17 @@ const FormComponent = ({
|
|
|
50
50
|
setElements({ ...elements, [name]: value });
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
const resetForm = () => {
|
|
54
|
+
const clearedValues = Object.keys(elements).reduce((acc, key) => {
|
|
55
|
+
acc[key] = '';
|
|
56
|
+
return acc;
|
|
57
|
+
}, {});
|
|
58
|
+
|
|
59
|
+
setElements(clearedValues);
|
|
60
|
+
formRef?.current?.reset();
|
|
61
|
+
recaptchaRef?.current?.reset();
|
|
62
|
+
};
|
|
63
|
+
|
|
53
64
|
async function postData(url = '', data = {}) {
|
|
54
65
|
return fetch(url, {
|
|
55
66
|
method: 'POST',
|
|
@@ -75,7 +86,7 @@ const FormComponent = ({
|
|
|
75
86
|
try {
|
|
76
87
|
let response;
|
|
77
88
|
if (customeSubmit) {
|
|
78
|
-
response = await customeSubmit(form);
|
|
89
|
+
response = await customeSubmit(form, resetForm);
|
|
79
90
|
} else {
|
|
80
91
|
response = await postData(submitUrl, new FormData(form));
|
|
81
92
|
}
|
|
@@ -203,9 +214,9 @@ const FormComponent = ({
|
|
|
203
214
|
)}
|
|
204
215
|
{!customError && (state.success || state.failed || !state.isValid) && (
|
|
205
216
|
<div className={styles.formAlerts || ''}>
|
|
206
|
-
{state.success && <div className={styles.alertSuccess || ''}>{useTranslate("success_message",successMessage)}</div>}
|
|
207
|
-
{state.failed && <div className={styles.alertDanger || ''}>{useTranslate('fail_message', failMessage)}</div>}
|
|
208
|
-
{!state.isValid && (
|
|
217
|
+
{!state.loading && state.success && <div className={styles.alertSuccess || ''}>{useTranslate("success_message",successMessage)}</div>}
|
|
218
|
+
{!state.loading && state.failed && <div className={styles.alertDanger || ''}>{useTranslate('fail_message', failMessage)}</div>}
|
|
219
|
+
{!state.loading && !state.isValid && (
|
|
209
220
|
<div className={styles.alertWarning || ''}>{useTranslate('validation_message',validationMessage)}</div>
|
|
210
221
|
)}
|
|
211
222
|
</div>
|
|
@@ -7,6 +7,7 @@ export function transformComments(comments) {
|
|
|
7
7
|
if (!transformedComments[refId]) {
|
|
8
8
|
transformedComments[refId] = [];
|
|
9
9
|
}
|
|
10
|
+
|
|
10
11
|
if(comment.approved){
|
|
11
12
|
transformedComments[refId].push({
|
|
12
13
|
replies: transformComments(comment?.replies)[refId],
|
|
@@ -17,6 +18,7 @@ export function transformComments(comments) {
|
|
|
17
18
|
comment: comment?.comment,
|
|
18
19
|
rate: comment?.rate,
|
|
19
20
|
author_id: comment?.author_id,
|
|
21
|
+
author_name: comment?.author_name,
|
|
20
22
|
votes_down: comment.votes_down,
|
|
21
23
|
votes_up: comment.votes_up,
|
|
22
24
|
created_at: comment?.created_at,
|