diff --git a/client/src/pages/index.jsx b/client/src/pages/index.jsx index 67d2922..f0e0f7c 100644 --- a/client/src/pages/index.jsx +++ b/client/src/pages/index.jsx @@ -86,14 +86,13 @@ export default function Home({ isSticky, setIsSticky }) { setSelectedAffiliations([]); }; - const undo = (_affiliations, _affiliation) => { - const newAffiliations = _affiliations.map((affiliation) => { - if (affiliation.id === _affiliation.id) { - return { - ...affiliation, - hasCorrection: false, - rorsToCorrect: affiliation.rors.map((r) => r.rorId).join(';'), - }; + const undo = (id) => { + const newAffiliations = affiliations.map((affiliation) => { + if (affiliation.id === id) { + // eslint-disable-next-line no-param-reassign + affiliation.hasCorrection = false; + // eslint-disable-next-line no-param-reassign + affiliation.rorsToCorrect = affiliation.rors.map((r) => r.rorId).join(';'); } return affiliation; }); @@ -102,13 +101,7 @@ export default function Home({ isSticky, setIsSticky }) { }; useEffect(() => { - setAffiliations( - (data?.affiliations ?? []).map((affiliation) => { - // eslint-disable-next-line no-param-reassign - affiliation.undo = () => undo(data?.affiliations ?? [], affiliation); - return affiliation; - }), - ); + setAffiliations(data?.affiliations ?? []); // eslint-disable-next-line react-hooks/exhaustive-deps }, [data]); @@ -170,6 +163,7 @@ export default function Home({ isSticky, setIsSticky }) { allOpenalexCorrections={allOpenalexCorrections} options={options} setAllOpenalexCorrections={setAllOpenalexCorrections} + undo={undo} /> )} diff --git a/client/src/pages/mentions.jsx b/client/src/pages/mentions.jsx index 4892f82..a9f8330 100644 --- a/client/src/pages/mentions.jsx +++ b/client/src/pages/mentions.jsx @@ -1,6 +1,5 @@ /* eslint-disable no-param-reassign */ import { - Badge, Button, Col, Container, @@ -22,13 +21,13 @@ import { useEffect, useState } from 'react'; import { useSearchParams } from 'react-router-dom'; import useWebSocket from 'react-use-websocket'; -import { correction } from '../config'; import useToast from '../hooks/useToast'; import { getMentionsCorrections } from '../utils/curations'; import { affiliations2Template, authorsTemplate, doiTemplate, + hasCorrectionTemplate, } from '../utils/templates'; import { capitalize, getMentions } from '../utils/works'; @@ -238,22 +237,6 @@ export default function Mentions() { style={{ color: rowData.mention_context.used ? '#8dc572' : '#be6464' }} /> ); - const hasCorrectionTemplate = (rowData) => (rowData?.hasCorrection ? ( - <> - - {correction.corrected.label} - -