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iCAAkChB,EAAQe,GACzDd,EAAUc,IAoCRf,OAAQA,EACRiB,sBAAoB,S","sources":["webpack://_N_E/?b326","webpack://_N_E/./src/components/Auth/RedirectToLoginPage.tsx","webpack://_N_E/./src/components/Auth/withAuth.tsx","webpack://_N_E/./src/pages/collections/all/index.tsx"],"sourcesContent":["\n (window.__NEXT_P = window.__NEXT_P || []).push([\n \"/collections/all\",\n function () {\n return require(\"private-next-pages/collections/all/index.tsx\");\n }\n ]);\n if(module.hot) {\n module.hot.dispose(function () {\n window.__NEXT_P.push([\"/collections/all\"])\n });\n }\n ","import React, { useEffect } from 'react';\n\nimport { useRouter } from 'next/router';\n\nimport { getLoginNavigationUrl } from '@/utils/navigation';\n\nconst RedirectToLoginPage = () => {\n const router = useRouter();\n useEffect(() => {\n const { asPath } = router;\n router.replace(getLoginNavigationUrl(asPath));\n }, [router]);\n\n return <></>;\n};\n\nexport default RedirectToLoginPage;\n","import { JSX, useEffect, useState } from 'react';\n\nimport RedirectToLoginPage from './RedirectToLoginPage';\n\nimport { isLoggedIn } from '@/utils/auth/login';\n/**\n * withAuth is a Higher-Order Component (HOC) that wraps a component and checks if the user is authenticated.\n * If the user is authenticated, it renders the wrapped component.\n * If the user is not authenticated, it redirects the user to the login page.\n *\n * @param {React.ComponentType} WrappedComponent - The component to wrap and protect with authentication check.\n *\n * @returns {React.ComponentType} If the user is authenticated, returns the WrappedComponent.\n * If not, returns RedirectToLoginPage component.\n *\n * @example\n * const ProtectedComponent = withAuth(MyComponent);\n */\nconst withAuth = (WrappedComponent: React.ComponentType): React.ComponentType => {\n const WithAuth = (props: JSX.IntrinsicAttributes) => {\n const [isReady, setIsReady] = useState(false);\n\n /**\n * we need to wait for the initial render to check if the user is authenticated\n * because when it's server-side rendered, the user is not authenticated yet\n */\n useEffect(() => {\n setIsReady(true);\n }, []);\n\n if (!isReady) {\n return null; // or return a loading spinner\n }\n\n return isLoggedIn() ? <WrappedComponent {...props} /> : <RedirectToLoginPage />;\n };\n\n return WithAuth;\n};\n\nexport default withAuth;\n","import { useState } from 'react';\n\nimport { GetStaticProps } from 'next';\nimport useTranslation from 'next-translate/useTranslation';\n\nimport withAuth from '@/components/Auth/withAuth';\nimport CollectionDetailContainer from '@/components/Collection/CollectionDetailContainer/CollectionDetailContainer';\nimport { isLoggedIn } from '@/utils/auth/login';\nimport { logValueChange } from '@/utils/eventLogger';\nimport { makeAllCollectionsItemsUrl } from 'src/utils/auth/apiPaths';\nimport { getAllChaptersData } from 'src/utils/chapter';\nimport { CollectionDetailSortOption } from 'types/CollectionSortOptions';\n\nconst CollectionDetailPage = () => {\n const [sortBy, setSortBy] = useState(CollectionDetailSortOption.VerseKey);\n const { t } = useTranslation();\n\n const onSortByChange = (newSortByVal) => {\n logValueChange('collection_detail_page_sort_by', sortBy, newSortByVal);\n setSortBy(newSortByVal);\n };\n\n /**\n * Get the SWR key for cursor based pagination\n * - when the page index is still 0 (first fetch). get the bookmarkByCollection url without `cursor` param\n * - on the next fetch, add `cursor` to the parameters\n *\n * corner case\n * - when previous fetch contains empty data, stop fetching\n * - when the user is logged out, don't fetch the data\n *\n * Reference: https://swr.vercel.app/docs/pagination#useswrinfinite\n *\n * @returns {string} swr key\n */\n const getKey = (pageIndex, previousPageData) => {\n if (!isLoggedIn()) return null;\n if (previousPageData && !previousPageData.data) return null;\n if (pageIndex === 0) {\n return makeAllCollectionsItemsUrl({\n sortBy,\n });\n }\n const cursor = previousPageData.pagination?.endCursor;\n return makeAllCollectionsItemsUrl({\n sortBy,\n cursor,\n });\n };\n\n return (\n <CollectionDetailContainer\n title={t('collection:all-saved-verses')}\n getSWRKey={getKey}\n onSortByChange={onSortByChange}\n sortBy={sortBy}\n shouldDeleteBookmark\n />\n );\n};\n\nexport const getStaticProps: GetStaticProps = async ({ locale }) => {\n const allChaptersData = await getAllChaptersData(locale);\n\n return {\n props: {\n chaptersData: allChaptersData,\n },\n };\n};\n\nexport default withAuth(CollectionDetailPage);\n"],"names":["window","__NEXT_P","push","router","useRouter","useEffect","asPath","replace","getLoginNavigationUrl","WrappedComponent","props","useState","isReady","setIsReady","isLoggedIn","RedirectToLoginPage","withAuth","CollectionDetailSortOption","sortBy","setSortBy","useTranslation","t","CollectionDetailContainer","title","getSWRKey","pageIndex","previousPageData","data","makeAllCollectionsItemsUrl","cursor","pagination","endCursor","onSortByChange","newSortByVal","logValueChange","shouldDeleteBookmark"],"sourceRoot":""}