Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Changes for removing warnings during npm run build #44

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/AdDetailsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const AdDetailsContent = (params) => {
<tbody>
<tr><td>Ad Type:</td><td>{params.details.type}</td></tr>
<tr><td>Entities:</td><td>{params.details.entities}</td></tr>
<tr><td>Cluster Topics:</td><td>{params.details.topics}<br /><a href='#' onClick={handleShow}>Suggest more topics?</a></td></tr>
<tr><td>Cluster Topics:</td><td>{params.details.topics}<br /><a href='# ' onClick={handleShow}>Suggest more topics?</a></td></tr>
<tr><td>Number of ads in cluster:</td><td>{params.details.cluster_size}</td></tr>
<tr><td>Canonical ad archive ID:</td><td>{params.details.canonical_archive_id}</td></tr>
</tbody>
Expand Down
37 changes: 18 additions & 19 deletions src/AdDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,30 @@ import AdDetailsContent from "./AdDetailsContent.js";
const getClusterURL = "/archive-id";

function AdDetailsPage() {
const [adIdParam, setAdIdParam] = useQueryParam('ad_id', StringParam);
const adIdParam = useQueryParam('ad_id', StringParam);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is why /cluster is broken. adIdParam is not a string now. it's an array of string and function. https://reactjs.org/docs/hooks-state.html#tip-what-do-square-brackets-mean

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now, leave this line as is, and disable lint on it with a comment like https://github.com/OnlinePoliticalTransparency/ad_screener/blob/master/src/AdScreenerTool.js#L299

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! Will do.

const [adClusterData, setAdClusterData] = useState([]);
const [isAdClusterDataLoaded, setIsAdClusterDataLoaded] = useState(false);
const [isAdClusterDataEmpty, setIsAdClusterDataEmpty] = useState(false);

const getAdClusterData = () => {
axios
.get(getClusterURL + '/' + adIdParam + '/cluster')
.then((response) => {
console.log(response.data);
setAdClusterData(response.data);
setIsAdClusterDataLoaded(true);
})
.catch((error) => {
console.log(error);
if (error.response.status === 404) {
setIsAdClusterDataEmpty(true);
}
})
.finally(() => {});
};

useEffect(() => {
const getAdClusterData = () => {
axios
.get(getClusterURL + '/' + adIdParam + '/cluster')
.then((response) => {
console.log(response.data);
setAdClusterData(response.data);
setIsAdClusterDataLoaded(true);
})
.catch((error) => {
console.log(error);
if (error.response.status === 404) {
setIsAdClusterDataEmpty(true);
}
})
.finally(() => {});
};
getAdClusterData();
}, []);
}, [adIdParam]);

if (isAdClusterDataEmpty) {
return (<div><br /><br /><br /><h3 align="center">No results found</h3></div>);
Expand Down
2 changes: 0 additions & 2 deletions src/AdUnit.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ const AdDetails = (params) => {
if (!(params.details && params.details.length !== 0)) {
return(<div></div>);
}
var ad_url =
"https://www.facebook.com/ads/library/?id=" + params.details.canonical_archive_id;

return (
<Modal
Expand Down
1 change: 1 addition & 0 deletions src/FilterSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const FilterSelector = params => {
const handleChange = selectedOption => {
params.setState({ selectedOption });
setParam(selectedOption.value);
console.log(param);
console.log(`Option selected:`, selectedOption);
};
console.log(params.option)
Expand Down
8 changes: 3 additions & 5 deletions src/NewTopicSuggestionForAdClusterForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import axios from "axios";


const NewTopicSuggestionForAdClusterForm = params => {
var labelName = "";
const [validated, setValidated] = useState(false);
const [showSubmitStatusMessage, setShowSubmitStatusMessage] = useState(false);
const [message, setMessage] = useState("");
const [style, setStyle] = useState({});
Expand All @@ -25,19 +23,19 @@ const NewTopicSuggestionForAdClusterForm = params => {
event.preventDefault();

var topicName = form.user_suggested_topic.value;
var comments = form.comments.value != "" ? form.comments.value : "None"
var comments = form.comments.value !== "" ? form.comments.value : "None"
var topics = form.topic_options;
var selected_topics = [];
for (var i = 0; i < topics.length; i++) {
if (topics.options[i].selected) selected_topics.push(topics.options[i].value);
}
if(topicName != ""){
if(topicName !== ""){
selected_topics.push(topicName);
}
console.log(comments);
console.log(selected_topics);

if(selected_topics.length == 0) {
if(selected_topics.length === 0) {
setShowSubmitStatusMessage(true);
setMessage("Please select or enter a topic name!");
setStyle({color: 'red'});
Expand Down
3 changes: 2 additions & 1 deletion src/TimePeriodPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const TimePeriodPicker = (params) => {
};
console.log(params.startDate);
console.log(params.endDate);

console.log(startingDate);
console.log(endingDate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these needed?

Copy link
Contributor Author

@swaaaaaathii swaaaaaathii Jul 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had added them to remove an unused variable warning. I'll disable lint instead.

return (
<div>
<div>
Expand Down