diff --git a/client/src/config.js b/client/src/config.js
new file mode 100644
index 00000000..34b11850
--- /dev/null
+++ b/client/src/config.js
@@ -0,0 +1,28 @@
+const status = {
+ validated: {
+ badgeType: 'success',
+ buttonClassName: 'btn-keep',
+ buttonIcon: 'ri-checkbox-circle-line',
+ buttonLabel: 'Validate',
+ id: 'validated',
+ label: 'Validated',
+ },
+ excluded: {
+ badgeType: 'error',
+ buttonClassName: 'btn-hide',
+ buttonIcon: 'ri-indeterminate-circle-line',
+ buttonLabel: 'Exclude',
+ id: 'excluded',
+ label: 'Excluded',
+ },
+ tobedecided: {
+ badgeType: 'info',
+ buttonClassName: 'btn-reset',
+ buttonIcon: 'ri-reply-fill',
+ buttonLabel: 'Reset status',
+ id: 'tobedecided',
+ label: 'To be decided',
+ },
+};
+
+export { status };
diff --git a/client/src/pages/home/actions.jsx b/client/src/pages/home/actions.jsx
index bfdce41d..62edfc78 100644
--- a/client/src/pages/home/actions.jsx
+++ b/client/src/pages/home/actions.jsx
@@ -6,6 +6,7 @@ import { Tooltip } from 'react-tooltip';
import Button from '../../components/button';
import { export2BsoCsv, export2json, importJson } from '../../utils/file';
+import { status } from '../../config';
export default function Actions({
allAffiliations,
@@ -18,7 +19,7 @@ export default function Actions({
const [, setSearchParams] = useSearchParams();
const [displayFileUpload, setDisplayFileUpload] = useState(false);
- const decidedAffiliations = allAffiliations.filter((affiliation) => ['excluded', 'validated'].includes(affiliation.status));
+ const decidedAffiliations = allAffiliations.filter((affiliation) => affiliation.status !== status.tobedecided.id);
return (
<>
diff --git a/client/src/pages/home/index.jsx b/client/src/pages/home/index.jsx
index 0670530c..bbddd3df 100644
--- a/client/src/pages/home/index.jsx
+++ b/client/src/pages/home/index.jsx
@@ -27,6 +27,7 @@ import {
getOpenAlexPublications,
mergePublications,
} from '../../utils/works';
+import { status } from '../../config';
import 'primereact/resources/primereact.min.css';
import 'primereact/resources/themes/lara-light-indigo/theme.css';
@@ -39,9 +40,6 @@ const {
const DATASOURCES = [{ key: 'bso', label: 'French OSM' }, { key: 'openalex', label: 'OpenAlex' }];
const FOSM_IDENTIFIERS = ['crossref', 'hal_id', 'datacite'];
-const STATUS_EXCLUDED = 'excluded';
-const STATUS_TO_BE_DECIDED = 'to be decided';
-const STATUS_VALIDATED = 'validated';
const getData = async (options) => {
const promises1 = [getBsoWorks({ options, index: VITE_BSO_PUBLICATIONS_INDEX }), getOpenAlexPublications(options)];
@@ -119,10 +117,10 @@ export default function Home() {
const groupByAffiliations = (publications) => {
setIsLoading(true);
// Save already decided affiliations
- const decidedAffiliations = Object.values(allAffiliations).filter((affiliation) => affiliation.status !== STATUS_TO_BE_DECIDED);
- // Compute distinct affiliations of the undecided publications
+ const decidedAffiliations = Object.values(allAffiliations).filter((affiliation) => affiliation.status !== status.tobedecided.id);
+ // Compute distinct affiliations of the undecided works
let allAffiliationsTmp = {};
- publications.filter((publication) => publication.status === STATUS_TO_BE_DECIDED).forEach((publication) => {
+ publications.filter((publication) => publication.status === status.tobedecided.id).forEach((publication) => {
(publication?.affiliations ?? [])
.filter((affiliation) => Object.keys(affiliation).length && affiliation?.name)
.forEach((affiliation) => {
@@ -141,7 +139,7 @@ export default function Home() {
nameHtml: affiliation.name.replace(regexp, '$&'),
ror,
rorHtml: ror?.replace(regexp, '$&'),
- status: STATUS_TO_BE_DECIDED,
+ status: status.tobedecided.id,
publications: [],
};
}
@@ -193,7 +191,7 @@ export default function Home() {
allIdsHtml: getAllIdsHtmlField(dataset),
authorsHtml: getAuthorsHtmlField(dataset),
authorsTooltip: getAuthorsTooltipField(dataset),
- status: STATUS_TO_BE_DECIDED,
+ status: status.tobedecided.id,
}));
allPublicationsTmp = data.publications
.map((publication) => ({
@@ -203,7 +201,7 @@ export default function Home() {
allIdsHtml: getAllIdsHtmlField(publication),
authorsHtml: getAuthorsHtmlField(publication),
authorsTooltip: getAuthorsTooltipField(publication),
- status: STATUS_TO_BE_DECIDED,
+ status: status.tobedecided.id,
}));
}
setAllDatasets(allDatasetsTmp);
@@ -227,7 +225,7 @@ export default function Home() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [allPublications, regexp]);
- const tagPublications = (publications, action) => {
+ const tagWorks = (publications, action) => {
const allPublicationsTmp = [...allPublications];
const publicationsIds = publications.map((publication) => publication.id);
allPublicationsTmp.filter((publication) => publicationsIds.includes(publication.id)).map((publication) => publication.status = action);
@@ -236,7 +234,7 @@ export default function Home() {
};
const tagAffiliations = (affiliations, action) => {
- if (action !== STATUS_EXCLUDED) {
+ if (action !== status.excluded.id) {
const allPublicationsTmp = [...allPublications];
const publicationsIds = affiliations.map((affiliation) => affiliation.publications).flat();
allPublicationsTmp.filter((publication) => publicationsIds.includes(publication.id)).map((publication) => publication.status = action);
@@ -249,73 +247,35 @@ export default function Home() {
setSelectedAffiliations([]);
};
- const renderAffiliationsButtons = () => (
+ const renderAffiliationsButtons = (selected) => (
<>
-
-
-
+ {Object.values(status).map((st) => (
+
+ ))}
>
);
const renderWorksButtons = (selected) => (
<>
-
-
-
+ {Object.values(status).map((st) => (
+
+ ))}
>
);
@@ -391,15 +351,16 @@ export default function Home() {
)}