index.tsx45 lines · main
| 1 | import { LOCAL_STORAGE_KEYS } from 'common' |
| 2 | import { useRouter } from 'next/router' |
| 3 | import { useEffect } from 'react' |
| 4 | |
| 5 | import { ShimmeringCard } from '@/components/interfaces/Home/ProjectList/ShimmeringCard' |
| 6 | import { DefaultLayout } from '@/components/layouts/DefaultLayout' |
| 7 | import OrganizationLayout from '@/components/layouts/OrganizationLayout' |
| 8 | import { ScaffoldContainerLegacy } from '@/components/layouts/Scaffold' |
| 9 | import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage' |
| 10 | import type { NextPageWithLayout } from '@/types' |
| 11 | |
| 12 | const OrgIndexPage: NextPageWithLayout = () => { |
| 13 | const router = useRouter() |
| 14 | const [lastVisitedOrganization, _, { isSuccess }] = useLocalStorageQuery( |
| 15 | LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION, |
| 16 | '' |
| 17 | ) |
| 18 | |
| 19 | useEffect(() => { |
| 20 | if (isSuccess) { |
| 21 | if (lastVisitedOrganization.length > 0) router.push(`/org/${lastVisitedOrganization}`) |
| 22 | else router.push('/organizations') |
| 23 | } |
| 24 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 25 | }, [isSuccess]) |
| 26 | |
| 27 | return ( |
| 28 | <ScaffoldContainerLegacy> |
| 29 | <div> |
| 30 | <ul className="my-6 mx-auto grid grid-cols-1 gap-4 sm:grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3"> |
| 31 | <ShimmeringCard /> |
| 32 | <ShimmeringCard /> |
| 33 | </ul> |
| 34 | </div> |
| 35 | </ScaffoldContainerLegacy> |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | OrgIndexPage.getLayout = (page) => ( |
| 40 | <DefaultLayout> |
| 41 | <OrganizationLayout title="Organizations">{page}</OrganizationLayout> |
| 42 | </DefaultLayout> |
| 43 | ) |
| 44 | |
| 45 | export default OrgIndexPage |