Skip to content

Commit

Permalink
openalex feedback on github
Browse files Browse the repository at this point in the history
  • Loading branch information
ericjeangirard committed Mar 6, 2024
1 parent cd7e154 commit 33d5d01
Show file tree
Hide file tree
Showing 6 changed files with 623 additions and 2 deletions.
12 changes: 10 additions & 2 deletions client/src/components/button-dropdown/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import useToast from '../../hooks/useToast';

import Button from '../button';
import { export2Csv, export2FosmCsv, export2jsonl } from '../../utils/files';
import { sendGitHubIssue } from '../../utils/github';

import './index.scss';

Expand All @@ -17,6 +18,14 @@ export default function ButtonDropdown({ data, label, searchParams }) {
toastType: 'success',
});
};
const toastOpenAlex = () => {
toast({
description: `${data.length} corrections to OpenAlex have been saved - see https://github.com/dataesr/openalex-affiliations/issues`,
id: 'saveOpenAlex',
title: `${label} saved`,
toastType: 'success',
});
};
return (
<div className={`dropdown ${data.length > 0 ? 'enabled' : 'disabled'}`}>
<Button
Expand Down Expand Up @@ -52,9 +61,8 @@ export default function ButtonDropdown({ data, label, searchParams }) {
)}
{label === 'OpenAlex errors' && (
<Button
onClick={() => { export2FosmCsv({ data, label, searchParams }); toastExport(); }}
onClick={() => { sendGitHubIssue({ data }); toastOpenAlex(); }}
size="sm"
disabled
>
Send feedback to OpenAlex
</Button>
Expand Down
22 changes: 22 additions & 0 deletions client/src/utils/github.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const {
VITE_API,
} = import.meta.env;

const sendGitHubIssue = async (data) => {
const params = JSON.stringify(data);
console.log('ttt1', params);
return fetch(`${VITE_API}/github-issue`, {
method: 'POST',
body: params,
params,
headers: { 'Content-Type': 'application/json' },
})
.then((response) => {
if (response.ok) return response.json();
return 'Oops... GitHub request error';
});
};

export {
sendGitHubIssue,
};
Loading

0 comments on commit 33d5d01

Please sign in to comment.