{"version":3,"file":"index-D_Uk7z7Q.js","sources":["../../src/scripts/modules/react-modules/LatestNewsGraphQL/LatestNews.tsx","../../src/scripts/modules/react-modules/LatestNewsGraphQL/index.tsx"],"sourcesContent":["import React from 'react';\r\nimport { GraphQLClient } from 'graphql-request';\r\nimport { useQuery } from '@tanstack/react-query';\r\nimport {\r\n GetLatestNewsByTagDocument,\r\n GetLatestNewsByTagQuery\r\n} from '../../../../codegenGenerated/optigraphql/generated';\r\nimport Loader from '../Loader';\r\nimport { getEnvGQLUrl } from '../../../helpers';\r\n\r\nconst useGetLatestNews = (endpoint: string, tag: string) => {\r\n const graphQLClient = new GraphQLClient(endpoint);\r\n\r\n const { isError, error, isFetching, data } = useQuery({\r\n queryKey: ['GetLatestNewsByTag', { tag: tag }],\r\n queryFn: async () =>\r\n graphQLClient.request(GetLatestNewsByTagDocument, {\r\n tag: tag\r\n }) as GetLatestNewsByTagQuery,\r\n refetchOnWindowFocus: false\r\n });\r\n\r\n return {\r\n status: isError ? 'error' : isFetching ? 'loading' : 'success',\r\n error: error as Error,\r\n results: data && data.ArticleDetailPage?.items ? data.ArticleDetailPage.items : []\r\n };\r\n};\r\n\r\nexport type LatestNewsProps = {\r\n title: string;\r\n tag: string;\r\n imgFallback?: string;\r\n};\r\n\r\nexport const LatestNews = ({ title, tag, imgFallback }: LatestNewsProps) => {\r\n const { status, results } = useGetLatestNews(getEnvGQLUrl(), tag);\r\n\r\n if (status === 'loading') {\r\n return
{result?.FeaturedDescription}
\r\n