Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
131 changes: 121 additions & 10 deletions data/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
"journaltype": "RESEARCH ARTICLE",
"topic": "General Computing",
"published": "12 July 2022",
"issn": "issn-615-682456"
"issn": "issn-615-682456",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": false,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 2,
Expand All @@ -20,7 +31,19 @@
"journaltype": "RESEARCH ARTICLE",
"topic": "General Computing",
"published": "12 July 2022",
"issn": "issn-615-682543"
"issn": "issn-615-682543",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",

"policies": {
"policy": "Policy 1",
"dataavail": false,
"datashared": true,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 3,
Expand All @@ -31,7 +54,18 @@
"journaltype": "AI Journal",
"topic": "Computer Science",
"published": "23 July 2022",
"issn": "issn-615-892543"
"issn": "issn-615-892543",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": true,
"peerreview": false,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 4,
Expand All @@ -42,7 +76,18 @@
"journaltype": "Book",
"topic": "Networking / LINUX",
"published": "29 January 2008",
"issn": "issn-615-892643"
"issn": "issn-615-892643",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": true,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 5,
Expand All @@ -53,7 +98,18 @@
"journaltype": "RESEARCH ARTICLE",
"topic": "General Computing",
"published": "12 July 2022",
"issn": "issn-615-682456"
"issn": "issn-615-682456",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": true,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 6,
Expand All @@ -64,7 +120,18 @@
"journaltype": "RESEARCH ARTICLE",
"topic": "General Computing",
"published": "12 July 2022",
"issn": "issn-615-682543"
"issn": "issn-615-682543",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": true,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 7,
Expand All @@ -75,7 +142,18 @@
"journaltype": "Book",
"topic": "Networking / LINUX",
"published": "29 January 2008",
"issn": "issn-615-892643"
"issn": "issn-615-892643",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": true,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 8,
Expand All @@ -86,7 +164,18 @@
"journaltype": "RESEARCH ARTICLE",
"topic": "General Computing",
"published": "12 July 2022",
"issn": "issn-615-682456"
"issn": "issn-615-682456",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": true,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 9,
Expand All @@ -97,7 +186,18 @@
"journaltype": "AI Journal",
"topic": "Computer Science",
"published": "23 July 2022",
"issn": "issn-615-892543"
"issn": "issn-615-892543",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": true,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
},
{
"id": 10,
Expand All @@ -108,7 +208,18 @@
"journaltype": "RESEARCH ARTICLE",
"topic": "General Computing",
"published": "12 July 2022",
"issn": "issn-615-682456"
"issn": "issn-615-682456",
"updated": "16th Aug 2022",
"link": "https://doi.org/10.1002/agg2.20287",
"policies": {
"policy": "Policy 1",
"dataavail": true,
"datashared": true,
"peerreview": true,
"enforced": "Yes - before application",
"enforcedevidence": "Random String"

}
}
]
}
106 changes: 58 additions & 48 deletions src/components/AddJournal/AddJournal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-alert */
import { React, useState } from 'react';
import { Row, Col, Form, Button } from 'react-bootstrap';
import { showSuccessMessage, showErrorMessage } from "../../helpers/alerts"
import { showSuccessMessage, showErrorMessage } from '../../helpers/alerts';
import { JournalValidation } from '../../helpers/validate';

function AddJournal() {
Expand All @@ -15,56 +15,62 @@ function AddJournal() {
const [lastYear, setLastYear] = useState('');
const [policyType, setPolicyType] = useState('');
const [domain, setDomain] = useState('');
const [success,setSuccess] = useState("");
const [error,setError]=useState("");
const [success, setSuccess] = useState('');
const [error, setError] = useState('');

const emptyFields=()=>{
setTitle("");
setUrl("");
setIssn("");
setRating("");
setDate("");
setPolicyTitle("");
setFirstYear("");
setLastYear("");
setPolicyType("");
setDomain("");
}
const emptyFields = () => {
setTitle('');
setUrl('');
setIssn('');
setRating('');
setDate('');
setPolicyTitle('');
setFirstYear('');
setLastYear('');
setPolicyType('');
setDomain('');
};
const handleSubmit = (e) => {
e.preventDefault();
setSuccess("");
setError("");
const check = JournalValidation(title, url, issn, rating, policyTitle, firstYear,
lastYear, policyType, domain, date)
if(check){
const policies = {
title: policyTitle,
first_year: firstYear,
last_year: lastYear,
type: policyType,
};
const journal = { title, url, issn, rating, date, policies, domain };
setSuccess('');
setError('');
const check = JournalValidation(
title,
url,
issn,
rating,
policyTitle,
firstYear,
lastYear,
policyType,
domain,
date,
);
if (check) {
const policies = {
title: policyTitle,
first_year: firstYear,
last_year: lastYear,
type: policyType,
};
const journal = { title, url, issn, rating, date, policies, domain };

try{
window.scrollTo(0,0);
fetch('https://journal-policy-tracker.herokuapp.com/api/journals', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(journal),
})
emptyFields();
setSuccess("Journal Added Successfuly")
}
catch(err)
{
setError("Cannot Add Journal")
try {
window.scrollTo(0, 0);
fetch('https://journal-policy-tracker.herokuapp.com/api/journals', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(journal),
});
emptyFields();
setSuccess('Journal Added Successfuly');
} catch (err) {
setError('Cannot Add Journal');
}
} else {
window.scrollTo(0, 0);
setError('Invalid Input');
}
}
else{
window.scrollTo(0,0);
setError("Invalid Input")
}

};

return (
Expand All @@ -84,8 +90,12 @@ function AddJournal() {
</Form.Group>
<Form.Group className='mb-3' controlId='formBasicUrl'>
<Form.Label>URL</Form.Label>
<Form.Control type='text' placeholder='URL'
onChange={(e) => setUrl(e.target.value)} value={url} />
<Form.Control
type='text'
placeholder='URL'
onChange={(e) => setUrl(e.target.value)}
value={url}
/>
</Form.Group>
<Form.Group className='mb-3' controlId='formBasicIssn'>
<Form.Label>ISSN</Form.Label>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Authentication/FormSuccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ const FormSuccess = () => {
);
};

export default FormSuccess;
export default FormSuccess;
Loading