@@ -9,14 +9,11 @@ import { MouseEventHandler, ReactElement, useEffect } from 'react';
9
9
import { SimpleLinkDropdown } from '@/components/Dropdown' ;
10
10
import { isBrowser } from '@/utils/common/guards' ;
11
11
import { IDocsEntity } from '@/api/search/types' ;
12
- import { useGetExportCitation } from '@/api/export/export' ;
13
- import { useSettings } from '@/lib/useSettings' ;
14
- import { exportFormats } from '@/components/CitationExporter/models' ;
15
- import { ExportApiFormatKey } from '@/api/export/types' ;
16
12
import CopyToClipboard from 'react-copy-html-to-clipboard' ;
17
13
18
14
export interface IItemResourceDropdownsProps {
19
15
doc : IDocsEntity ;
16
+ defaultCitation : string ;
20
17
}
21
18
22
19
export interface IItem {
@@ -25,22 +22,10 @@ export interface IItem {
25
22
path ?: string ;
26
23
}
27
24
28
- export const ItemResourceDropdowns = ( { doc } : IItemResourceDropdownsProps ) : ReactElement => {
25
+ export const ItemResourceDropdowns = ( { doc, defaultCitation } : IItemResourceDropdownsProps ) : ReactElement => {
29
26
const router = useRouter ( ) ;
30
27
const isClient = useIsClient ( ) ;
31
28
const toast = useToast ( { duration : 2000 } ) ;
32
- const { settings } = useSettings ( ) ;
33
- const { defaultExportFormat, customFormats } = settings ;
34
-
35
- const { data : citationData } = useGetExportCitation (
36
- {
37
- // format: values(exportFormats).find((f) => f.label === defaultExportFormat).id,
38
- format : ExportApiFormatKey . agu ,
39
- customFormat : defaultExportFormat === exportFormats . custom . label ? customFormats [ 0 ] . code : undefined ,
40
- bibcode : [ doc . bibcode ] ,
41
- } ,
42
- { enabled : ! ! settings ?. defaultExportFormat } ,
43
- ) ;
44
29
45
30
const { hasCopied, onCopy, setValue, value } = useClipboard ( '' ) ;
46
31
@@ -172,10 +157,10 @@ export const ItemResourceDropdowns = ({ doc }: IItemResourceDropdownsProps): Rea
172
157
} ;
173
158
174
159
const handleCitationCopied = ( ) => {
175
- if ( citationData ?. export ) {
160
+ if ( defaultCitation !== '' ) {
176
161
toast ( { status : 'info' , title : 'Copied to Clipboard' } ) ;
177
162
} else {
178
- toast ( { status : 'error' , title : 'There was a problem fetching citation' } ) ;
163
+ toast ( { status : 'error' , title : 'There was a problem fetching citation. Try reloading the page. ' } ) ;
179
164
}
180
165
} ;
181
166
@@ -300,7 +285,7 @@ export const ItemResourceDropdowns = ({ doc }: IItemResourceDropdownsProps): Rea
300
285
< MenuList >
301
286
< MenuItem onClick = { handleCopyAbstractUrl } > Copy URL</ MenuItem >
302
287
303
- < CopyToClipboard text = { citationData ?. export } onCopy = { handleCitationCopied } options = { { asHtml : true } } >
288
+ < CopyToClipboard text = { defaultCitation } onCopy = { handleCitationCopied } options = { { asHtml : true } } >
304
289
< MenuItem > Copy Citation</ MenuItem >
305
290
</ CopyToClipboard >
306
291
</ MenuList >
0 commit comments