Skip to content

Commit f8a6772

Browse files
author
Hina Shah
committed
ENH: adding gpt context
1 parent 2ab7917 commit f8a6772

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

src/pages/answer/resultsTable/AttributesTable.jsx

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import {
44
Table, TableBody, TableCell, TableHead, TableRow, withStyles,
55
} from '@material-ui/core';
66
import React, {
7-
useState, useRef,
7+
useState, useContext,
88
} from 'react';
99
import Button from '@material-ui/core/Button';
1010
import { blue } from '@material-ui/core/colors';
1111
import resultsUtils from '~/utils/results';
1212
import Popover from '~/components/Popover';
13+
import GPTContext from '~/context/gpt';
1314

1415
const headerStyles = { fontWeight: 'bold', backgroundColor: '#eee' };
1516

@@ -40,6 +41,7 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
4041
return `https://pubmed.ncbi.nlm.nih.gov/${pmid[1]}/`;
4142
};
4243

44+
const { enabled } = useContext(GPTContext);
4345
const [aiSummaryData, setAISummaryData] = useState('');
4446
const [popoverOpen, setPopoverOpen] = useState(false);
4547
const [popoverPosition, setPopoverPosition] = useState({ x: 0, y: 0 });
@@ -156,30 +158,19 @@ const PublicationLinkCell = ({ value, aiJSON }) => {
156158
</li>
157159
)}
158160
</ul>
159-
<GPTSummaryButton
160-
onClick={(event) => {
161-
event.persist();
162-
onGPTSummary(event, aiJSON);
163-
}}
164-
variant="outlined"
165-
// aria-describedby={id}
166-
>
167-
Get AI Summary
168-
</GPTSummaryButton>
169-
{/* <Popover
170-
id={id}
171-
open={popoverOpen === 'aiSummary'}
172-
onClose={handlePopoverClose}
173-
anchorEl={anchorEl}
174-
anchorOrigin={{
175-
vertical: 'bottom',
176-
horizontal: 'left',
177-
}}
178-
transformOrigin={{
179-
vertical: 'top',
180-
horizontal: 'left',
181-
}}
182-
> */}
161+
{enabled &&
162+
(
163+
<GPTSummaryButton
164+
onClick={(event) => {
165+
event.persist();
166+
onGPTSummary(event, aiJSON);
167+
}}
168+
variant="outlined"
169+
// aria-describedby={id}
170+
>
171+
Get AI Summary
172+
</GPTSummaryButton>
173+
)}
183174
<Popover
184175
open={popoverOpen === 'aiSummary'}
185176
onClose={() => setPopoverOpen(null)}

0 commit comments

Comments
 (0)