-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create initial dashboard page (#308)
### TL;DR This PR adds a new `/dashboard` page to go to a specific site ### What changed? 1. **Site Listing**: - Introduced a new `SiteList` component that lists all sites a user has access to. - Added new database query in `site.router.ts` to fetch site list. 2. **Report Issue Button**: - Added a button in the AppNavbar to allow users to report issues via the Isomer issue tracker. 3. **Component Updates**: - Updated `AppNavbar` to include new functionality and style tweaks. - Changed the logo source in `AppNavbar.tsx`. - Updated `dashboard.tsx` with new site listing component. - Refactored various storybook files to include new handlers and remove unnecessary layouts. ### How to test? New stories ---
- Loading branch information
Showing
12 changed files
with
158 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import NextLink from "next/link" | ||
import { Card, CardHeader, SimpleGrid, Skeleton } from "@chakra-ui/react" | ||
import { Link } from "@opengovsg/design-system-react" | ||
|
||
import { withSuspense } from "~/hocs/withSuspense" | ||
import { trpc } from "~/utils/trpc" | ||
|
||
const SuspendableSiteList = (): JSX.Element => { | ||
// TODO: Only return sites that the user has access to | ||
const [sites] = trpc.site.list.useSuspenseQuery() | ||
return ( | ||
<SimpleGrid columns={3} gap="2.5rem" width="100%"> | ||
{sites.map((site) => ( | ||
<Card key={site.id} width="100%"> | ||
<CardHeader> | ||
<Link href={`/sites/${site.id}`} as={NextLink}> | ||
{site.name} | ||
</Link> | ||
</CardHeader> | ||
</Card> | ||
))} | ||
</SimpleGrid> | ||
) | ||
} | ||
|
||
const SiteListSkeleton = (): JSX.Element => { | ||
return ( | ||
<SimpleGrid columns={3} gap="2.5rem"> | ||
{[1, 2, 3].map((index) => ( | ||
<Card key={index} width="100%"> | ||
<Skeleton> | ||
<CardHeader>Loading...</CardHeader> | ||
</Skeleton> | ||
</Card> | ||
))} | ||
</SimpleGrid> | ||
) | ||
} | ||
|
||
export const SiteList = withSuspense(SuspendableSiteList, <SiteListSkeleton />) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
import { Box, Flex } from "@chakra-ui/react" | ||
import { Flex, Text } from "@chakra-ui/react" | ||
import { Link } from "@opengovsg/design-system-react" | ||
|
||
import Suspense from "~/components/Suspense" | ||
import { | ||
ADMIN_NAVBAR_HEIGHT, | ||
APP_GRID_COLUMN, | ||
APP_GRID_TEMPLATE_COLUMN, | ||
} from "~/constants/layouts" | ||
import { SiteList } from "~/features/dashboard/SiteList" | ||
import { type NextPageWithLayout } from "~/lib/types" | ||
import { AppGrid } from "~/templates/AppGrid" | ||
import { AdminLayout } from "~/templates/layouts/AdminLayout" | ||
|
||
const Home: NextPageWithLayout = () => { | ||
const DashboardPage: NextPageWithLayout = () => { | ||
return ( | ||
<Flex | ||
w="100%" | ||
flexDir="column" | ||
position={{ base: "absolute", sm: "inherit" }} | ||
left={{ base: 0, sm: undefined }} | ||
minH={`calc(100% - ${ADMIN_NAVBAR_HEIGHT})`} | ||
> | ||
Hello | ||
<Flex flexDir="column" py="2rem" maxW="57rem" mx="auto" width="100%"> | ||
<Flex gap="0.75rem" flexDirection="column"> | ||
<Text as="h3" size="lg" textStyle="h3"> | ||
My sites | ||
</Text> | ||
<Text textStyle="body-2"> | ||
Don't see a site here?{" "} | ||
<Link variant="inline" href="mailto:[email protected]"> | ||
Let us know | ||
</Link> | ||
. | ||
</Text> | ||
<SiteList /> | ||
</Flex> | ||
</Flex> | ||
) | ||
} | ||
|
||
Home.getLayout = AdminLayout | ||
DashboardPage.getLayout = AdminLayout | ||
|
||
export default Home | ||
export default DashboardPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { DelayMode } from "msw" | ||
import { delay } from "msw" | ||
|
||
import { trpcMsw } from "../mockTrpc" | ||
|
||
const siteListQuery = (wait?: DelayMode | number) => { | ||
return trpcMsw.site.list.query(async () => { | ||
if (wait !== undefined) { | ||
await delay(wait) | ||
} | ||
return [ | ||
{ | ||
id: 1, | ||
name: "Ministry of Trade and Industry", | ||
}, | ||
] | ||
}) | ||
} | ||
|
||
export const sitesHandlers = { | ||
list: { | ||
default: siteListQuery, | ||
loading: () => siteListQuery("infinite"), | ||
}, | ||
} |