Skip to content

Commit b4bae9d

Browse files
authored
Merge pull request #3380 from OneCommunityGlobal/amalesh-linting-pr
Amalesh - Fixing Linting Errors in "Common" and "EmailSubscribeForm" folders
2 parents 894f20d + 0d2ea6e commit b4bae9d

19 files changed

Lines changed: 366 additions & 315 deletions

File tree

.eslintignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Ignore build folders
99
/node_modules/
1010
/public/
11+
/build/
1112

1213
# Ignore test files inside /src/components
1314
src/__tests__/**
@@ -24,9 +25,7 @@ src/components/Reports/PeopleReport/components/PeopleTasksPieChart.test.jsx
2425
# Ignore folders in /src
2526
src/actions/**
2627
src/components/Badge/**
27-
src/components/common/**
2828
src/components/Dashboard/**
29-
src/components/EmailSubscribeForm/**
3029
src/components/Projects/**
3130
src/components/SummaryManagement/**
3231
src/components/TaskEditSuggestions/**
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import React from 'react';
2-
import styles from './ConfirmationMessage.module.css'; // Make sure to create this CSS module
31
import { useHistory } from 'react-router-dom';
2+
import styles from './ConfirmationMessage.module.css'; // Make sure to create this CSS module
43

5-
const ConfirmationMessage = ({ message, isSuccess, confirmationMessageCallback }) => {
4+
function ConfirmationMessage({ message, isSuccess, confirmationMessageCallback }) {
65
const history = useHistory();
76
return (
87
<div className={styles.confirmationContainer}>
9-
{isSuccess && <div className={styles.oneCommunityIcon}></div>}
10-
<p></p>
8+
{isSuccess && <div className={styles.oneCommunityIcon} />}
9+
<p />
1110
{isSuccess && (
1211
<div className={styles.envelope}>
1312
<div className={styles.iconContainer}>
@@ -22,17 +21,10 @@ const ConfirmationMessage = ({ message, isSuccess, confirmationMessageCallback }
2221
</div>
2322
</div>
2423
)}
25-
{!isSuccess ? (
26-
<h2>
27-
{' '}
28-
<p></p>
29-
{message}
30-
</h2>
31-
) : (
32-
<h2></h2>
33-
)}
24+
{!isSuccess && <h2>{message}</h2>}
3425
<div className={styles.buttonsContainer}>
3526
<button
27+
type="button"
3628
className={styles.button}
3729
onClick={() => {
3830
history.push('/email-subscribe');
@@ -44,6 +36,6 @@ const ConfirmationMessage = ({ message, isSuccess, confirmationMessageCallback }
4436
</div>
4537
</div>
4638
);
47-
};
39+
}
4840

4941
export default ConfirmationMessage;
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1+
// eslint-disable-next-line no-unused-vars
12
import React from 'react';
2-
import styles from './ConfirmationMessage.module.css'; // Make sure to create this CSS module
33
import { useHistory } from 'react-router-dom';
4+
import styles from './ConfirmationMessage.module.css'; // Make sure to create this CSS module
45

5-
const ConfirmationMessage = ({ message, isSuccess, confirmationMessageCallback }) => {
6+
// function ConfirmationMessage({ message, isSuccess, confirmationMessageCallback }) {
7+
function ConfirmationMessage({ isSuccess, confirmationMessageCallback }) {
68
const history = useHistory();
79
return (
810
<div className={styles.confirmationContainer}>
9-
{isSuccess && <div className={styles.oneCommunityIcon}></div>}
10-
<p></p>
11-
<p></p>
11+
{isSuccess && <div className={styles.oneCommunityIcon} />}
12+
<p />
13+
<p />
1214
<div className={styles.envelope}>
1315
<div className={styles.iconContainer}>
1416
<div className={styles.checkmark}></div>
1517
</div>
1618
</div>
17-
<p></p>
19+
<p />
1820
<div className={styles.buttonsContainer}>
1921
<button
2022
className={styles.button}
23+
type="button"
2124
onClick={() => {
2225
history.push('/email-subscribe');
2326
confirmationMessageCallback();
@@ -28,6 +31,6 @@ const ConfirmationMessage = ({ message, isSuccess, confirmationMessageCallback }
2831
</div>
2932
</div>
3033
);
31-
};
34+
}
3235

3336
export default ConfirmationMessage;

src/components/EmailSubscribeForm/Unsubscribe/index.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1+
// eslint-disable-next-line no-unused-vars
12
import React, { useState, useEffect } from 'react';
3+
import { useLocation } from 'react-router-dom';
4+
import { useDispatch } from 'react-redux';
5+
// import { set } from 'lodash';
26
import styles from './SubscribePage.module.css'; // Import the CSS module
37
import {
48
removeNonHgnUserEmailSubscription,
59
addNonHgnUserEmailSubscription,
610
} from '../../../actions/sendEmails';
7-
import { useLocation } from 'react-router-dom';
8-
import { useDispatch } from 'react-redux';
911
import ConfirmationMessage from './ConfirmationMessage';
10-
import { set } from 'lodash';
1112

12-
const SubscribePage = () => {
13+
function SubscribePage() {
1314
const dispatch = useDispatch();
1415
const query = new URLSearchParams(useLocation().search);
1516
const [email, setEmail] = useState('');
1617
const [error, setError] = useState('');
1718
const [confirmationMessage, setConfirmationMessage] = useState('');
1819
const [confirmationStatus, setConfirmationStatus] = useState(false);
1920
useEffect(() => {
20-
const email = query.get('email');
21-
if (email) {
21+
const queryemail = query.get('email');
22+
if (queryemail) {
2223
removeNonHgnUserEmailSubscription(email).then(result => {
2324
if (result.success) {
2425
// Handle success
@@ -33,8 +34,8 @@ const SubscribePage = () => {
3334
}
3435
}, [query]);
3536

36-
const validateEmail = email => {
37-
return /\S+@\S+\.\S+/.test(email);
37+
const validateEmail = emailval => {
38+
return /\S+@\S+\.\S+/.test(emailval);
3839
};
3940

4041
const confirmationMessageCallback = () => {
@@ -45,7 +46,7 @@ const SubscribePage = () => {
4546
event.preventDefault();
4647
if (validateEmail(email)) {
4748
dispatch(addNonHgnUserEmailSubscription(email));
48-
console.log('Email valid, submit to the server:', email);
49+
// console.log('Email valid, submit to the server:', email);
4950
setEmail('');
5051
setError('');
5152
} else {
@@ -55,13 +56,11 @@ const SubscribePage = () => {
5556

5657
if (confirmationMessage) {
5758
return (
58-
<>
59-
<ConfirmationMessage
60-
message={confirmationMessage}
61-
isSuccess={confirmationStatus}
62-
confirmationMessageCallback={confirmationMessageCallback}
63-
/>
64-
</>
59+
<ConfirmationMessage
60+
message={confirmationMessage}
61+
isSuccess={confirmationStatus}
62+
confirmationMessageCallback={confirmationMessageCallback}
63+
/>
6564
);
6665
}
6766

@@ -70,9 +69,9 @@ const SubscribePage = () => {
7069
<h1 className={styles.header}>Subscribe for Weekly Updates</h1>
7170
{/* ... */}
7271
<p className={styles.description}>
73-
Join our mailing list for updates. We'll send a confirmation to ensure you're the owner of
74-
the email provided. Once confirmed, we promise only a single email per week. Don't forget to
75-
check your spam folder if you didn't receive the confirmation!
72+
Join our mailing list for updates. We&apos;ll send a confirmation to ensure you&apos;re the
73+
owner of the email provided. Once confirmed, we promise only a single email per week.
74+
Don&apos;t forget to check your spam folder if you didn&apos;t receive the confirmation!
7675
</p>
7776
<p className={styles.note}>
7877
Want to opt out later? No problem, every email has an unsubscribe link at the bottom.
@@ -92,6 +91,6 @@ const SubscribePage = () => {
9291
{/* ... */}
9392
</div>
9493
);
95-
};
94+
}
9695

9796
export default SubscribePage;

src/components/EmailSubscribeForm/UnsubscribeForm.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import React, { useState, useEffect } from 'react';
1+
import { useState, useEffect } from 'react';
2+
import { useLocation } from 'react-router-dom';
3+
import { useDispatch } from 'react-redux';
24
import styles from './SubscribePage.module.css'; // Import the CSS module
35
import {
46
addNonHgnUserEmailSubscription,
57
confirmNonHgnUserEmailSubscription,
68
} from '../../actions/sendEmails';
7-
import { useLocation } from 'react-router-dom';
8-
import { useDispatch } from 'react-redux';
99
import ConfirmationMessage from './ConfirmationMessage';
10-
import { set } from 'lodash';
1110

12-
const UnsubscribeForm = () => {
11+
function UnsubscribeForm() {
1312
const dispatch = useDispatch();
1413
const query = new URLSearchParams(useLocation().search);
1514
const [email, setEmail] = useState('');
@@ -33,8 +32,8 @@ const UnsubscribeForm = () => {
3332
}
3433
}, [query]);
3534

36-
const validateEmail = email => {
37-
return /\S+@\S+\.\S+/.test(email);
35+
const validateEmail = emailVal => {
36+
return /\S+@\S+\.\S+/.test(emailVal);
3837
};
3938

4039
const confirmationMessageCallback = () => {
@@ -45,7 +44,7 @@ const UnsubscribeForm = () => {
4544
event.preventDefault();
4645
if (validateEmail(email)) {
4746
dispatch(addNonHgnUserEmailSubscription(email));
48-
console.log('Email valid, submit to the server:', email);
47+
// console.log('Email valid, submit to the server:', email);
4948
setEmail('');
5049
setError('');
5150
} else {
@@ -55,13 +54,11 @@ const UnsubscribeForm = () => {
5554

5655
if (confirmationMessage) {
5756
return (
58-
<>
59-
<ConfirmationMessage
60-
message={confirmationMessage}
61-
isSuccess={confirmationStatus}
62-
confirmationMessageCallback={confirmationMessageCallback}
63-
/>
64-
</>
57+
<ConfirmationMessage
58+
message={confirmationMessage}
59+
isSuccess={confirmationStatus}
60+
confirmationMessageCallback={confirmationMessageCallback}
61+
/>
6562
);
6663
}
6764

@@ -70,9 +67,9 @@ const UnsubscribeForm = () => {
7067
<h1 className={styles.header}>Subscribe for Weekly Updates</h1>
7168
{/* ... */}
7269
<p className={styles.description}>
73-
Join our mailing list for updates. We'll send a confirmation to ensure you're the owner of
74-
the email provided. Once confirmed, we promise only a single email per week. Don't forget to
75-
check your spam folder if you didn't receive the confirmation!
70+
Join our mailing list for updates. We&apo;ll send a confirmation to ensure you&apo;re the
71+
owner of the email provided. Once confirmed, we promise only a single email per week.
72+
Don&apo;t forget to check your spam folder if you didn&apo;t receive the confirmation!
7673
</p>
7774
<p className={styles.note}>
7875
Want to opt out later? No problem, every email has an unsubscribe link at the bottom.
@@ -92,6 +89,6 @@ const UnsubscribeForm = () => {
9289
{/* ... */}
9390
</div>
9491
);
95-
};
92+
}
9693

9794
export default UnsubscribeForm;

src/components/EmailSubscribeForm/index.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
// eslint-disable-next-line no-unused-vars
12
import React, { useState, useEffect } from 'react';
3+
import { useLocation } from 'react-router-dom';
4+
import { useDispatch } from 'react-redux';
25
import styles from './SubscribePage.module.css'; // Import the CSS module
36
import {
47
addNonHgnUserEmailSubscription,
58
confirmNonHgnUserEmailSubscription,
69
} from '../../actions/sendEmails';
7-
import { useLocation } from 'react-router-dom';
8-
import { useDispatch } from 'react-redux';
910
import ConfirmationMessage from './ConfirmationMessage';
10-
import { set } from 'lodash';
1111

12-
const SubscribePage = () => {
12+
function SubscribePage() {
1313
const dispatch = useDispatch();
1414
const query = new URLSearchParams(useLocation().search);
1515
const [email, setEmail] = useState('');
@@ -33,8 +33,8 @@ const SubscribePage = () => {
3333
}
3434
}, [query]);
3535

36-
const validateEmail = email => {
37-
return /\S+@\S+\.\S+/.test(email);
36+
const validateEmail = emailval => {
37+
return /\S+@\S+\.\S+/.test(emailval);
3838
};
3939

4040
const confirmationMessageCallback = () => {
@@ -45,7 +45,7 @@ const SubscribePage = () => {
4545
event.preventDefault();
4646
if (validateEmail(email)) {
4747
dispatch(addNonHgnUserEmailSubscription(email));
48-
console.log('Email valid, submit to the server:', email);
48+
// console.log('Email valid, submit to the server:', email);
4949
setEmail('');
5050
setError('');
5151
} else {
@@ -55,25 +55,23 @@ const SubscribePage = () => {
5555

5656
if (confirmationMessage) {
5757
return (
58-
<>
59-
<ConfirmationMessage
60-
message={confirmationMessage}
61-
isSuccess={confirmationStatus}
62-
confirmationMessageCallback={confirmationMessageCallback}
63-
/>
64-
</>
58+
<ConfirmationMessage
59+
message={confirmationMessage}
60+
isSuccess={confirmationStatus}
61+
confirmationMessageCallback={confirmationMessageCallback}
62+
/>
6563
);
6664
}
6765

6866
return (
6967
<div className={styles.subscribeContainer}>
70-
<div className={styles.oneCommunityIcon}></div>
68+
<div className={styles.oneCommunityIcon} />
7169
<h1 className={styles.header}>Subscribe for Weekly Updates</h1>
7270
{/* ... */}
7371
<p className={styles.description}>
74-
Join our mailing list for updates. We'll send a confirmation to ensure you're the owner of
75-
the email provided. Once confirmed, we promise only a single email per week. Don't forget to
76-
check your spam folder if you didn't receive the confirmation!
72+
Join our mailing list for updates. We&apos;ll send a confirmation to ensure you&apos;re the
73+
owner of the email provided. Once confirmed, we promise only a single email per week.
74+
Don&apos;t forget to check your spam folder if you didn&apos;t receive the confirmation!
7775
</p>
7876
<p className={styles.note}>
7977
Want to opt out later? No problem, every email has an unsubscribe link at the bottom.
@@ -93,6 +91,6 @@ const SubscribePage = () => {
9391
{/* ... */}
9492
</div>
9593
);
96-
};
94+
}
9795

9896
export default SubscribePage;

src/components/common/CPDashboard/CPProtectedRoute/CPProtectedRoute.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const CPProtectedRoute = ({ component: Component, render, auth, fallback, ...res
1414
}
1515
if (auth.user.access && !auth.user.access.canAccessBMPortal) {
1616
return (
17-
<Redirect to={{ pathname: '/communityportal/login', state: { from: props.location } }} />
17+
<Redirect
18+
to={{ pathname: '/communityportal/login', state: { from: props.location } }}
19+
/>
1820
);
1921
}
2022
// eslint-disable-next-line no-nested-ternary
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React from 'react'
2-
import { useLocation } from 'react-router-dom'
3-
import Announcements from 'components/Announcements'
4-
5-
export const EmailSender = () => {
1+
// eslint-disable-next-line no-unused-vars
2+
import React from 'react';
3+
import { useLocation } from 'react-router-dom';
4+
import Announcements from 'components/Announcements';
65

6+
function EmailSender() {
77
const location = useLocation();
8-
const email = location.state.state.email;
8+
const { email } = location.state.state;
9+
10+
return <Announcements title="Email Form" email={email} />;
11+
}
912

10-
return (
11-
<Announcements title='Email Form' email={ email } />
12-
)
13-
};
13+
export default EmailSender;

0 commit comments

Comments
 (0)