index.tsx60 lines · main
1import { useIsMFAEnabled } from 'common'
2import Link from 'next/link'
3import { Button } from 'ui'
4import { Admonition } from 'ui-patterns'
5
6import { ProjectList } from '@/components/interfaces/Home/ProjectList/ProjectList'
7import { HomePageActions } from '@/components/interfaces/HomePageActions'
8import DefaultLayout from '@/components/layouts/DefaultLayout'
9import OrganizationLayout from '@/components/layouts/OrganizationLayout'
10import { PageLayout } from '@/components/layouts/PageLayout/PageLayout'
11import { ScaffoldContainer, ScaffoldSection } from '@/components/layouts/Scaffold'
12import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
13import type { NextPageWithLayout } from '@/types'
14
15const ProjectsPage: NextPageWithLayout = () => {
16 const isUserMFAEnabled = useIsMFAEnabled()
17 const { data: org } = useSelectedOrganizationQuery()
18
19 const disableAccessMfa = org?.organization_requires_mfa && !isUserMFAEnabled
20
21 return (
22 <ScaffoldContainer className="grow flex">
23 <ScaffoldSection isFullWidth className="pb-0">
24 {disableAccessMfa ? (
25 <Admonition
26 type="note"
27 layout="horizontal"
28 title={`${org?.name} requires MFA`}
29 description={
30 <>
31 Set up multi-factor authentication (MFA) on your account to access this
32 organization’s projects.
33 </>
34 }
35 actions={
36 <Button asChild type="default">
37 <Link href="/account/security">Set up MFA</Link>
38 </Button>
39 }
40 />
41 ) : (
42 <div className="flex flex-col gap-y-4">
43 <HomePageActions />
44 <ProjectList />
45 </div>
46 )}
47 </ScaffoldSection>
48 </ScaffoldContainer>
49 )
50}
51
52ProjectsPage.getLayout = (page) => (
53 <DefaultLayout>
54 <OrganizationLayout title="Projects">
55 <PageLayout title="Projects">{page}</PageLayout>
56 </OrganizationLayout>
57 </DefaultLayout>
58)
59
60export default ProjectsPage