{"version":3,"file":"GetStarted-CtHmYEgE.js","sources":["../../src/components/Discover/DiscoverCarousel.tsx","../../src/components/GetStarted.tsx"],"sourcesContent":["import { Carousel } from '@mantine/carousel'\nimport { Box, Stack, Title, useMantineTheme } from '@mantine/core'\nimport { useMediaQuery } from '@mantine/hooks'\nimport { IconCaretLeftFilled, IconCaretRightFilled } from '@tabler/icons-react'\nimport React, { useEffect, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\n\nimport { useConstants, useErrorMessages } from '../../constants/content'\nimport useSessionStorage from '../../hooks/useSessionStorage'\nimport {\n DISCOVER_CAROUSEL_CONTENT_TYPE,\n Entry,\n getParagraph,\n RichText,\n} from '../../plugins/contentful/api'\nimport client from '../../plugins/contentful/client'\nimport ErrorMessage from '../ErrorMessage'\nimport Loading from '../Loading'\nimport GalleryCard, { GalleryElement } from './GalleryCard'\nimport SpacesCards from './SpacesCards'\n\n/* -------------------------------------------------------------------------- */\n/* Export Functions for Gallery Cards */\n/* -------------------------------------------------------------------------- */\nexport type GalleryElementsImagesByEntryId = {\n // undefined means that the image is not loaded yet\n // true means that the image is loading\n // false means that the failed to be loaded\n // string means that the image is loaded and this is its URL\n [entryId: string]: undefined | string | boolean\n}\n\nexport const wrapData = (\n elem: Entry,\n imagesByEntryId: GalleryElementsImagesByEntryId\n): GalleryElement => {\n const { title, buttonLink, signedOut, signedIn } = elem.fields\n const paragraph =\n elem.fields.description === undefined ? '' : getParagraph(elem.fields.description)\n const description =\n elem.fields.description === undefined ? '' : (elem.fields.description as RichText)\n\n const imageAsset = imagesByEntryId[elem.sys.id]\n\n return {\n id: elem.sys.id,\n title,\n paragraph,\n description,\n image: typeof imageAsset === 'string' ? imageAsset : undefined,\n buttonLink,\n buttonText: elem.fields.buttonText === undefined ? '' : elem.fields?.buttonText || undefined,\n signedOut: signedOut === undefined ? false : signedOut,\n signedIn: signedIn === undefined ? true : signedIn,\n }\n}\n\nexport const pullGalleryImage = (\n content: Entry[],\n oldEntry: GalleryElementsImagesByEntryId,\n setState: React.Dispatch>\n) => {\n async function getAssetsByIds(\n entryIdAssetIdPairs: [entryId: string, assetId: string][],\n saveAsset: (entryId: string, urlOrError: string | Error) => void\n ): Promise {\n for (let i = 0; i < entryIdAssetIdPairs.length; i++) {\n const [entryId, assetId] = entryIdAssetIdPairs[i]\n try {\n // eslint-disable-next-line no-await-in-loop\n const asset = await client.getAsset(assetId)\n const url = asset?.fields?.file?.url\n if (!url) {\n console.warn(`Asset ${assetId} has no url`)\n } else {\n saveAsset(entryId, url)\n }\n } catch (e) {\n console.error('ASSET error:', e)\n saveAsset(entryId, new Error(`${e}`))\n }\n }\n }\n\n const newGalleryImageByEntry: GalleryElementsImagesByEntryId = { ...oldEntry }\n\n content.forEach(elem => {\n const entryId = elem.sys.id\n newGalleryImageByEntry[entryId] =\n newGalleryImageByEntry[entryId] ?? elem.fields?.image?.fields?.file?.url\n })\n\n const entryIdsAssetIdsPairsToRequest = Object.keys(newGalleryImageByEntry)\n // filter only by undefined, which means the entry's image is still not loaded nor loading\n .filter(entryId => newGalleryImageByEntry[entryId] === undefined)\n .map(entryId => {\n const entry = content.find(elem => elem.sys.id === entryId)\n const assetId = entry?.fields?.image?.sys?.id\n return [entryId, assetId] as [string, string | undefined]\n })\n // filter out undefined, which means the entry has no image or the entry is not found\n .filter((tuple): tuple is [string, string] => !!tuple[0] && !!tuple[1])\n\n entryIdsAssetIdsPairsToRequest.forEach(([entryId]) => {\n newGalleryImageByEntry[entryId] = true\n })\n\n getAssetsByIds(entryIdsAssetIdsPairsToRequest, (entryId, url) => {\n setState(prevGalleryImageByEntry => ({\n ...prevGalleryImageByEntry,\n [entryId]: url instanceof Error ? false : url,\n }))\n }).catch(console.error)\n\n return newGalleryImageByEntry\n}\n\n/* -------------------------------------------------------------------------- */\n/* - */\n/* -------------------------------------------------------------------------- */\n\nconst DiscoverCarousel: React.FC = () => {\n const {\n t,\n i18n: { language },\n } = useTranslation()\n const constants = useConstants()\n const errorMessages = useErrorMessages()\n const [discoverContent, setDiscoverContent] = useSessionStorage(\n `discoverContent-${language}`,\n []\n )\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState('')\n const theme = useMantineTheme()\n const isMobile = useMediaQuery(`(max-width: ${theme.breakpoints.sm})`)\n\n useEffect(() => {\n if (!discoverContent.length) {\n setIsLoading(true)\n client\n .getEntries({ content_type: DISCOVER_CAROUSEL_CONTENT_TYPE, locale: language })\n .then((response: any) => {\n const sortedContent = response.items.sort(\n (a: Entry, b: Entry) => a.fields.order - b.fields.order\n )\n setDiscoverContent(sortedContent)\n })\n .catch((err: any) => {\n setError(err.message)\n setIsLoading(false)\n })\n .finally(() => {\n setIsLoading(false)\n })\n }\n }, [discoverContent, setDiscoverContent, t, language])\n\n const [galleryImageByEntry, setGalleryImageByEntry] = useState({})\n\n useEffect(() => {\n setGalleryImageByEntry(oldGalleryImageByEntry =>\n pullGalleryImage(discoverContent, oldGalleryImageByEntry, setGalleryImageByEntry)\n )\n }, [discoverContent])\n\n return (\n \n \n {constants.DISCOVER_HEADER}\n \n {isLoading && }\n {error && }\n {!isLoading && !error && (\n \n }\n nextControlIcon={}\n slidesToScroll=\"auto\"\n >\n \n {discoverContent.slice(0, -2).map((elem, index) => (\n \n \n \n \n \n ))}\n \n \n )}\n \n )\n}\n\nexport default DiscoverCarousel\n","import { Carousel } from '@mantine/carousel'\nimport { Stack, Text, Title, useMantineTheme } from '@mantine/core'\nimport { useMediaQuery } from '@mantine/hooks'\nimport { IconCaretLeftFilled, IconCaretRightFilled } from '@tabler/icons-react'\nimport React, { useEffect, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useNavigate } from 'react-router-dom'\n\nimport missingImage from '@/assets/webp_converted/imageOnload.webp'\nimport { useErrorMessages } from '@/constants/content'\nimport useSessionStorage from '@/hooks/useSessionStorage'\nimport { Entry, GET_STARTED_CONTENT_TYPE } from '@/plugins/contentful/api'\nimport client from '@/plugins/contentful/client'\n\nimport RootButton from './Buttons/RootButton'\nimport {\n GalleryElementsImagesByEntryId,\n pullGalleryImage,\n wrapData,\n} from './Discover/DiscoverCarousel'\nimport ErrorMessage from './ErrorMessage'\nimport Loading from './Loading'\n\ninterface CTACardProps {\n image: string | undefined\n title: string\n description?: string\n button: {\n text?: string\n link: string\n }\n}\n\nexport const CTACard: React.FC = ({ image, title, description = '', button }) => {\n const theme = useMantineTheme()\n const navigate = useNavigate()\n const isMobile = useMediaQuery(`(max-width: ${theme.breakpoints.sm})`)\n return (\n \n button.link.startsWith('/') ? navigate(button.link) : window.open(button.link, '_blank')\n }\n >\n \n {title}\n {description && {description}}\n {button.text && (\n \n button.link.startsWith('/') ? navigate(button.link) : window.open(button.link, '_blank')\n }\n >\n {button.text}\n \n )}\n \n )\n}\n\nconst GetStarted: React.FC = () => {\n const {\n t,\n i18n: { language },\n } = useTranslation()\n\n const errorMessages = useErrorMessages()\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState('')\n const [getStarted, setGetStarted] = useSessionStorage(`getStarted-${language}`, [])\n const [galleryImageByEntry, setGalleryImageByEntry] = useState({})\n\n useEffect(() => {\n if (!getStarted.length) {\n setIsLoading(true)\n client\n .getEntries({ content_type: GET_STARTED_CONTENT_TYPE, locale: language })\n .then((response: any) => {\n const sortedContent = response.items.sort(\n (a: Entry, b: Entry) => a.fields.order - b.fields.order\n )\n setGetStarted(sortedContent)\n })\n .catch((err: any) => {\n setError(err.message)\n setIsLoading(false)\n })\n .finally(() => {\n setIsLoading(false)\n })\n }\n }, [getStarted, setGetStarted, t, language])\n\n useEffect(() => {\n if (getStarted) {\n setGalleryImageByEntry(oldGalleryImageByEntry =>\n pullGalleryImage(getStarted, oldGalleryImageByEntry, setGalleryImageByEntry)\n )\n }\n }, [getStarted])\n\n return (\n \n {isLoading && }\n {error && }\n {!isLoading && !error && (\n \n {t(`components.getStarted.title`, 'Get Started on LAMINA1')}\n \n {t(\n 'components.getStarted.subtitle',\n 'Your items, content, and activity will show up here, on your Profile, as you start exploring the LAMINA1 Hub.'\n )}\n \n\n \n }\n nextControlIcon={}\n >\n {getStarted &&\n getStarted.map((elem, index) => {\n const card = wrapData(elem, galleryImageByEntry)\n return (\n \n \n \n )\n })}\n \n \n \n )}\n \n )\n}\n\nexport default GetStarted\n"],"names":["wrapData","elem","imagesByEntryId","title","buttonLink","signedOut","signedIn","paragraph","getParagraph","description","imageAsset","_a","pullGalleryImage","content","oldEntry","setState","getAssetsByIds","entryIdAssetIdPairs","saveAsset","i","entryId","assetId","asset","client","url","_b","e","newGalleryImageByEntry","_d","_c","entryIdsAssetIdsPairsToRequest","entry","tuple","prevGalleryImageByEntry","CTACard","image","button","theme","useMantineTheme","navigate","useNavigate","isMobile","useMediaQuery","jsxs","Stack","jsx","missingImage","Title","Text","RootButton","GetStarted","t","language","useTranslation","errorMessages","useErrorMessages","isLoading","setIsLoading","useState","error","setError","getStarted","setGetStarted","useSessionStorage","galleryImageByEntry","setGalleryImageByEntry","useEffect","GET_STARTED_CONTENT_TYPE","response","sortedContent","a","b","err","oldGalleryImageByEntry","Loading","ErrorMessage","Carousel","IconCaretLeftFilled","IconCaretRightFilled","index","card"],"mappings":"uoBAgCa,MAAAA,EAAW,CACtBC,EACAC,IACmB,OACnB,KAAM,CAAE,MAAAC,EAAO,WAAAC,EAAY,UAAAC,EAAW,SAAAC,GAAaL,EAAK,OAClDM,EACJN,EAAK,OAAO,cAAgB,OAAY,GAAKO,EAAaP,EAAK,OAAO,WAAW,EAC7EQ,EACJR,EAAK,OAAO,cAAgB,OAAY,GAAMA,EAAK,OAAO,YAEtDS,EAAaR,EAAgBD,EAAK,IAAI,EAAE,EAEvC,MAAA,CACL,GAAIA,EAAK,IAAI,GACb,MAAAE,EACA,UAAAI,EACA,YAAAE,EACA,MAAO,OAAOC,GAAe,SAAWA,EAAa,OACrD,WAAAN,EACA,WAAYH,EAAK,OAAO,aAAe,OAAY,KAAKU,EAAAV,EAAK,SAAL,YAAAU,EAAa,aAAc,OACnF,UAAWN,IAAc,OAAY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