Skip to content

Commit 2388890

Browse files
committed
chore: format project with prettier
1 parent 2b208a4 commit 2388890

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1074
-1045
lines changed
File renamed without changes.

src/components/AddJournal/AddJournal.js

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-alert */
22
import { React, useState } from 'react';
33
import { Row, Col, Form, Button } from 'react-bootstrap';
4-
import { showSuccessMessage, showErrorMessage } from "../../helpers/alerts"
4+
import { showSuccessMessage, showErrorMessage } from '../../helpers/alerts';
55
import { JournalValidation } from '../../helpers/validate';
66

77
function AddJournal() {
@@ -15,56 +15,62 @@ function AddJournal() {
1515
const [lastYear, setLastYear] = useState('');
1616
const [policyType, setPolicyType] = useState('');
1717
const [domain, setDomain] = useState('');
18-
const [success,setSuccess] = useState("");
19-
const [error,setError]=useState("");
18+
const [success, setSuccess] = useState('');
19+
const [error, setError] = useState('');
2020

21-
const emptyFields=()=>{
22-
setTitle("");
23-
setUrl("");
24-
setIssn("");
25-
setRating("");
26-
setDate("");
27-
setPolicyTitle("");
28-
setFirstYear("");
29-
setLastYear("");
30-
setPolicyType("");
31-
setDomain("");
32-
}
21+
const emptyFields = () => {
22+
setTitle('');
23+
setUrl('');
24+
setIssn('');
25+
setRating('');
26+
setDate('');
27+
setPolicyTitle('');
28+
setFirstYear('');
29+
setLastYear('');
30+
setPolicyType('');
31+
setDomain('');
32+
};
3333
const handleSubmit = (e) => {
3434
e.preventDefault();
35-
setSuccess("");
36-
setError("");
37-
const check = JournalValidation(title, url, issn, rating, policyTitle, firstYear,
38-
lastYear, policyType, domain, date)
39-
if(check){
40-
const policies = {
41-
title: policyTitle,
42-
first_year: firstYear,
43-
last_year: lastYear,
44-
type: policyType,
45-
};
46-
const journal = { title, url, issn, rating, date, policies, domain };
35+
setSuccess('');
36+
setError('');
37+
const check = JournalValidation(
38+
title,
39+
url,
40+
issn,
41+
rating,
42+
policyTitle,
43+
firstYear,
44+
lastYear,
45+
policyType,
46+
domain,
47+
date,
48+
);
49+
if (check) {
50+
const policies = {
51+
title: policyTitle,
52+
first_year: firstYear,
53+
last_year: lastYear,
54+
type: policyType,
55+
};
56+
const journal = { title, url, issn, rating, date, policies, domain };
4757

48-
try{
49-
window.scrollTo(0,0);
50-
fetch('https://journal-policy-tracker.herokuapp.com/api/journals', {
51-
method: 'POST',
52-
headers: { 'Content-Type': 'application/json' },
53-
body: JSON.stringify(journal),
54-
})
55-
emptyFields();
56-
setSuccess("Journal Added Successfuly")
57-
}
58-
catch(err)
59-
{
60-
setError("Cannot Add Journal")
58+
try {
59+
window.scrollTo(0, 0);
60+
fetch('https://journal-policy-tracker.herokuapp.com/api/journals', {
61+
method: 'POST',
62+
headers: { 'Content-Type': 'application/json' },
63+
body: JSON.stringify(journal),
64+
});
65+
emptyFields();
66+
setSuccess('Journal Added Successfuly');
67+
} catch (err) {
68+
setError('Cannot Add Journal');
69+
}
70+
} else {
71+
window.scrollTo(0, 0);
72+
setError('Invalid Input');
6173
}
62-
}
63-
else{
64-
window.scrollTo(0,0);
65-
setError("Invalid Input")
66-
}
67-
6874
};
6975

7076
return (
@@ -84,8 +90,12 @@ function AddJournal() {
8490
</Form.Group>
8591
<Form.Group className='mb-3' controlId='formBasicUrl'>
8692
<Form.Label>URL</Form.Label>
87-
<Form.Control type='text' placeholder='URL'
88-
onChange={(e) => setUrl(e.target.value)} value={url} />
93+
<Form.Control
94+
type='text'
95+
placeholder='URL'
96+
onChange={(e) => setUrl(e.target.value)}
97+
value={url}
98+
/>
8999
</Form.Group>
90100
<Form.Group className='mb-3' controlId='formBasicIssn'>
91101
<Form.Label>ISSN</Form.Label>

src/components/Authentication/FormSuccess.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ const FormSuccess = () => {
1212
);
1313
};
1414

15-
export default FormSuccess;
15+
export default FormSuccess;

src/components/Authentication/Login/Login.js

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,68 @@
33
/* eslint-disable jsx-a11y/label-has-associated-control */
44
/* eslint-disable react/function-component-definition */
55
/* eslint-disable jsx-a11y/anchor-is-valid */
6-
import React from 'react'
6+
import React from 'react';
77
import { Link } from 'react-router-dom';
88
import useFormLogin from './useFormLogin';
99
import validateLoginInfo from './validateLoginInfo.js';
10-
import { FormContentRight, FormDiv, FormH1, FormInputs, FormInputsP, FormLabel, FormInput, FormInputBtn, ButtonContainer, FormH2} from './styles';
10+
import {
11+
FormContentRight,
12+
FormDiv,
13+
FormH1,
14+
FormInputs,
15+
FormInputsP,
16+
FormLabel,
17+
FormInput,
18+
FormInputBtn,
19+
ButtonContainer,
20+
FormH2,
21+
} from './styles';
1122
import { signup } from '../../../config/content';
1223

13-
14-
const FormLogin = ({submitForm}) => {
15-
const {handleChange, values, handleSubmit, errors} = useFormLogin(submitForm, validateLoginInfo);
24+
const FormLogin = ({ submitForm }) => {
25+
const { handleChange, values, handleSubmit, errors } = useFormLogin(
26+
submitForm,
27+
validateLoginInfo,
28+
);
1629

1730
return (
1831
<FormContentRight>
19-
<FormDiv onSubmit={handleSubmit}>
32+
<FormDiv onSubmit={handleSubmit}>
2033
<FormH1>{signup.head}</FormH1>
2134
<FormH2>{signup.head2}</FormH2>
2235
<FormInputs>
23-
<FormLabel htmlFor='email'>
24-
{signup.labelEmail}
25-
</FormLabel>
26-
<FormInput
27-
id='email'
28-
type='email'
29-
name='email'
30-
value={values.email}
31-
onChange={handleChange}
32-
/>
33-
{errors.email && <FormInputsP>{errors.email}</FormInputsP>}
36+
<FormLabel htmlFor='email'>{signup.labelEmail}</FormLabel>
37+
<FormInput
38+
id='email'
39+
type='email'
40+
name='email'
41+
value={values.email}
42+
onChange={handleChange}
43+
/>
44+
{errors.email && <FormInputsP>{errors.email}</FormInputsP>}
3445
</FormInputs>
3546
<FormInputs>
36-
<FormLabel htmlFor='password'>
37-
{signup.labelPassword}
38-
</FormLabel>
39-
<FormInput
40-
id='password'
41-
type='password'
42-
name='password'
43-
value={values.password}
44-
onChange={handleChange}
45-
/>
46-
{errors.password && <FormInputsP>{errors.password}</FormInputsP>}
47+
<FormLabel htmlFor='password'>{signup.labelPassword}</FormLabel>
48+
<FormInput
49+
id='password'
50+
type='password'
51+
name='password'
52+
value={values.password}
53+
onChange={handleChange}
54+
/>
55+
{errors.password && <FormInputsP>{errors.password}</FormInputsP>}
4756
</FormInputs>
4857
<ButtonContainer>
49-
<FormInputBtn type='submit'>
50-
{signup.buttonLogin}
51-
</FormInputBtn>
52-
<FormInputBtn primary type="button">
53-
<Link to='/Signup' style={{color: '#EA8900', hover: '#fff' }}>
54-
{signup.button}
58+
<FormInputBtn type='submit'>{signup.buttonLogin}</FormInputBtn>
59+
<FormInputBtn primary type='button'>
60+
<Link to='/Signup' style={{ color: '#EA8900', hover: '#fff' }}>
61+
{signup.button}
5562
</Link>
56-
</FormInputBtn>
63+
</FormInputBtn>
5764
</ButtonContainer>
58-
</FormDiv>
65+
</FormDiv>
5966
</FormContentRight>
60-
);
67+
);
6168
};
6269

63-
export default FormLogin;
70+
export default FormLogin;

src/components/Authentication/Login/LoginForm.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,9 @@ const LoginForm = () => {
1818
return (
1919
<>
2020
<FormContainer>
21-
{!isSubmitted ? (
22-
<FormLogin submitForm={submitForm} />
23-
) : (
24-
<FormSuccess />
25-
)}
21+
{!isSubmitted ? <FormLogin submitForm={submitForm} /> : <FormSuccess />}
2622
<FormContentLeft>
27-
<Logo src={signup.logo.src} alt={signup.logo.alt}/>
23+
<Logo src={signup.logo.src} alt={signup.logo.alt} />
2824
<RightH2>{signup.formHead}</RightH2>
2925
<FormImg src={signup.img.src} alt={signup.img.alt} />
3026
</FormContentLeft>
@@ -33,4 +29,4 @@ const LoginForm = () => {
3329
);
3430
};
3531

36-
export default LoginForm;
32+
export default LoginForm;

0 commit comments

Comments
 (0)