Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(platform): updated the empty state of dashboard #522

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/platform/public/svg/dashboard/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion apps/platform/public/svg/dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import EnvironmentSVG from './environment.svg'
import ConfigSVG from './config.svg'
import SecretSVG from './secret.svg'
import FolderSVG from './folder.svg'

export { EnvironmentSVG, ConfigSVG, SecretSVG }
export { EnvironmentSVG, ConfigSVG, SecretSVG, FolderSVG }
33 changes: 23 additions & 10 deletions apps/platform/src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'
import { toast } from 'sonner'
import { useRouter } from 'next/navigation'
import { AddSVG } from '@public/svg/shared'
import { FolderSVG } from '@public/svg/dashboard'
import ProjectCard from '@/components/dashboard/projectCard'
import {
Sheet,
Expand Down Expand Up @@ -30,6 +31,7 @@ import { Projects } from '@/lib/api-functions/projects'

export default function Index(): JSX.Element {
const [isSheetOpen, setIsSheetOpen] = useState<boolean>(false)
const [isProjectEmpty, setIsProjectEmpty] = useState(true)
rajdip-b marked this conversation as resolved.
Show resolved Hide resolved
const [projects, setProjects] = useState<ProjectWithoutKeys[] | []>([])
const [newProjectData, setNewProjectData] = useState<NewProject>({
name: '',
Expand Down Expand Up @@ -68,6 +70,7 @@ export default function Index(): JSX.Element {
.then((data: ProjectWithoutKeys[] | [] | undefined) => {
if (data) {
setProjects(data)
setIsProjectEmpty(data.length === 0)
}
})
.catch((error) => {
Expand All @@ -79,15 +82,20 @@ export default function Index(): JSX.Element {
return (
<div className="flex flex-col gap-4">
<div className="flex items-center justify-between">
<h1 className="text-[1.75rem] font-semibold ">My Projects</h1>
{!isProjectEmpty && (
<h1 className="text-[1.75rem] font-semibold ">My Projects</h1>
)}

<Dialog>
<DialogTrigger>
<Button>
{' '}
<AddSVG /> Create a new Project
</Button>
</DialogTrigger>
{!isProjectEmpty && (
<DialogTrigger>
<Button>
{' '}
<AddSVG /> Create a new Project
</Button>
</DialogTrigger>
)}

<DialogContent>
<DialogHeader>Create a new project</DialogHeader>
<DialogDescription>
Expand Down Expand Up @@ -155,7 +163,7 @@ export default function Index(): JSX.Element {
</Dialog>
</div>

{projects.length !== 0 ? (
{!isProjectEmpty ? (
<div className="grid h-[70vh] gap-6 overflow-y-auto scroll-smooth p-2 md:grid-cols-2 2xl:grid-cols-3">
{projects.map((project: ProjectWithoutKeys) => {
return (
Expand All @@ -173,8 +181,13 @@ export default function Index(): JSX.Element {
})}
</div>
) : (
<div className="mt-[10vh] flex justify-center">
<div>No projects yet? Get started by creating a new project.</div>
<div className="mt-[10vh] flex h-[40vh] flex-col items-center justify-center gap-y-4">
<FolderSVG width="150" />
<div className="text-4xl">Start your First Project</div>
<div>
Create a file and start setting up your environment and secret keys
</div>
<Button variant="secondary">Create project</Button>
</div>
)}

Expand Down