11import { IDocsEntity } from '@/api/search/types' ;
22import { EXTERNAL_URLS } from '@/config' ;
33import { getReadablePublDate , pluralize } from '@/utils/common/formatters' ;
4- import { ExternalLinkIcon , QuestionIcon } from '@chakra-ui/icons' ;
4+ import { ChatIcon , ExternalLinkIcon , QuestionIcon } from '@chakra-ui/icons' ;
55import {
66 Badge ,
77 Box ,
@@ -10,6 +10,7 @@ import {
1010 Flex ,
1111 HStack ,
1212 Icon ,
13+ Spacer ,
1314 Stack ,
1415 Table ,
1516 Tag ,
@@ -33,6 +34,8 @@ import { SearchQueryLink } from '../SearchQueryLink';
3334import { SimpleLink } from '../SimpleLink' ;
3435import { AbstractCitationModal } from './AbstractCitationModal' ;
3536import { UATDropdown } from './UATDropdown' ;
37+ import { useRouter } from 'next/router' ;
38+ import { feedbackItems } from '../NavBar' ;
3639
3740interface IDetailsProps {
3841 doc : IDocsEntity ;
@@ -62,6 +65,15 @@ export const AbstractDetails = ({ doc }: IDetailsProps): ReactElement => {
6265
6366 const { isOpen : isCitationOpen , onOpen : onCitationOpen , onClose : onCitationClose } = useDisclosure ( ) ;
6467
68+ const router = useRouter ( ) ;
69+
70+ const handleUATFeedback = ( ) => {
71+ void router . push ( {
72+ pathname : feedbackItems . general . path ,
73+ query : { id : doc . bibcode ? doc . bibcode : doc . identifier ?. [ 0 ] , subject : 'UAT keywords feedback' } ,
74+ } ) ;
75+ } ;
76+
6577 return (
6678 < Box as = "section" border = "1px" borderColor = "gray.50" borderRadius = "md" shadow = "sm" aria-labelledby = "details" >
6779 < VisuallyHidden as = "h3" id = "details" >
@@ -103,7 +115,7 @@ export const AbstractDetails = ({ doc }: IDetailsProps): ReactElement => {
103115 < Detail label = "Bibcode" value = { doc . bibcode } copiable />
104116 < Collections collections = { doc . database ?? [ ] } />
105117 < Keywords keywords = { doc . keyword } />
106- < UATKeywords keywords = { doc . uat } ids = { doc . uat_id } />
118+ < UATKeywords keywords = { doc . uat } ids = { doc . uat_id } feedback = { handleUATFeedback } />
107119 < Bibgroups bibgroups = { doc . bibgroup ?? [ ] } />
108120 < PlanetaryFeatures features = { doc . planetary_feature } ids = { doc . planetary_feature_id } />
109121 < Detail label = "Comment(s)" value = { doc . comment } />
@@ -214,58 +226,69 @@ const Keywords = memo(({ keywords }: { keywords: Array<string> }) => {
214226} , equals ) ;
215227Keywords . displayName = 'Keywords' ;
216228
217- const UATKeywords = memo ( ( { keywords, ids } : { keywords : Array < string > ; ids : Array < number > } ) => {
218- const desc = `Search for papers that mention this keyword` ;
219- const label = (
220- < >
221- { `UAT ${ pluralize ( 'Keyword' , keywords ?. length ?? 0 ) } (generated)` }
222- < Badge colorScheme = "blue" mx = { 1 } >
223- BETA
224- </ Badge >
225- </ >
226- ) ;
227- return (
228- < Detail label = { label } value = { keywords } >
229- { ( keywords ) => (
230- < Flex flexWrap = { 'wrap' } >
231- { keywords . map ( ( keyword , index ) => (
232- < Tag size = "md" variant = "subtle" whiteSpace = "nowrap" m = "1" px = { 2 } py = { 1 } key = { keyword } >
233- < HStack spacing = "1" >
234- < Tooltip
235- label = {
236- < >
237- { keyword } < ExternalLinkIcon aria-label = "external link" />
238- </ >
239- }
240- >
241- < SimpleLink href = { `https://astrothesaurus.org/uat/${ encodeURIComponent ( ids [ index ] ) } ` } newTab >
242- { shortenKeyword ( keyword ) }
243- </ SimpleLink >
244- </ Tooltip >
245- < SearchQueryLink
246- params = { { q : `uat:"${ keyword . split ( '/' ) . pop ( ) } "` } }
247- textDecoration = "none"
248- _hover = { {
249- color : 'gray.900' ,
250- } }
251- aria-label = { desc }
252- fontSize = "md"
253- >
254- < Tooltip label = { desc } >
255- < Center >
256- < Icon as = { MagnifyingGlassIcon } transform = "rotate(90deg)" ml = { 2 } mr = { 1 } />
257- </ Center >
258- </ Tooltip >
259- </ SearchQueryLink >
260- < UATDropdown keyword = { keyword } />
261- </ HStack >
262- </ Tag >
263- ) ) }
264- </ Flex >
265- ) }
266- </ Detail >
267- ) ;
268- } , equals ) ;
229+ const UATKeywords = memo (
230+ ( { keywords, ids, feedback } : { keywords : Array < string > ; ids : Array < number > ; feedback : ( ) => void } ) => {
231+ const desc = `Search for papers that mention this keyword` ;
232+ const label = (
233+ < >
234+ { `UAT ${ pluralize ( 'Keyword' , keywords ?. length ?? 0 ) } (generated)` }
235+ < Badge colorScheme = "blue" mx = { 1 } >
236+ BETA
237+ </ Badge >
238+ </ >
239+ ) ;
240+ return (
241+ < Detail label = { label } value = { keywords } >
242+ { ( keywords ) => (
243+ < >
244+ < Flex flexWrap = { 'wrap' } >
245+ { keywords . map ( ( keyword , index ) => (
246+ < Tag size = "md" variant = "subtle" whiteSpace = "nowrap" m = "1" px = { 2 } py = { 1 } key = { keyword } >
247+ < HStack spacing = "1" >
248+ < Tooltip
249+ label = {
250+ < >
251+ { keyword } < ExternalLinkIcon aria-label = "external link" />
252+ </ >
253+ }
254+ >
255+ < SimpleLink href = { `https://astrothesaurus.org/uat/${ encodeURIComponent ( ids [ index ] ) } ` } newTab >
256+ { shortenKeyword ( keyword ) }
257+ </ SimpleLink >
258+ </ Tooltip >
259+ < SearchQueryLink
260+ params = { { q : `uat:"${ keyword . split ( '/' ) . pop ( ) } "` } }
261+ textDecoration = "none"
262+ _hover = { {
263+ color : 'gray.900' ,
264+ } }
265+ aria-label = { desc }
266+ fontSize = "md"
267+ >
268+ < Tooltip label = { desc } >
269+ < Center >
270+ < Icon as = { MagnifyingGlassIcon } transform = "rotate(90deg)" ml = { 2 } mr = { 1 } />
271+ </ Center >
272+ </ Tooltip >
273+ </ SearchQueryLink >
274+ < UATDropdown keyword = { keyword } />
275+ </ HStack >
276+ </ Tag >
277+ ) ) }
278+ < Spacer />
279+ < Flex justifyContent = "end" mt = { 2 } >
280+ < Button variant = "link" size = "sm" onClick = { feedback } >
281+ < ChatIcon mr = { 2 } /> Feedback
282+ </ Button >
283+ </ Flex >
284+ </ Flex >
285+ </ >
286+ ) }
287+ </ Detail >
288+ ) ;
289+ } ,
290+ equals ,
291+ ) ;
269292UATKeywords . displayName = 'UATKeywords' ;
270293
271294const Collections = memo ( ( { collections } : { collections : Array < string > } ) => {
0 commit comments