Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
majkshkurti committed Oct 18, 2024
1 parent 102ec9e commit 6b16fa1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
15 changes: 13 additions & 2 deletions apps/web/app/[lng]/(dashboard)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useProjects } from "@/lib/api/projects";
import type { PaginatedQueryParams } from "@/lib/validations/common";
import type { Layer } from "@/lib/validations/layer";

import { useAuthZ } from "@/hooks/auth/AuthZ";
import { useJobStatus } from "@/hooks/jobs/JobStatus";

import BlogSection from "@/components/dashboard/home/BlogSection";
Expand Down Expand Up @@ -44,6 +45,8 @@ const Home = () => {

useJobStatus(mutate);

const { isOrgEditor } = useAuthZ();

return (
<Container sx={{ py: 10, px: 10 }} maxWidth="xl">
<Stack direction="column" spacing={24}>
Expand All @@ -67,9 +70,17 @@ const Home = () => {
</Button>
</Box>
<Divider sx={{ mb: 4 }} />
<ProjectSection projects={projects?.items ?? []} isLoading={isProjectLoading} />
<ProjectSection
projects={projects?.items ?? []}
isLoading={isProjectLoading}
hideCreate={!isOrgEditor}
/>
</Stack>
<DataSection layers={(layers?.items as Layer[]) ?? []} isLoading={isLayerLoading} />
<DataSection
layers={(layers?.items as Layer[]) ?? []}
isLoading={isLayerLoading}
hideCreate={!isOrgEditor}
/>
<BlogSection />
</Stack>
</Container>
Expand Down
15 changes: 9 additions & 6 deletions apps/web/components/dashboard/home/DataSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import DatasetUploadModal from "@/components/modals/DatasetUpload";
interface DataSectionProps {
layers: Layer[];
isLoading: boolean;
hideCreate?: boolean;
}

const DataSection = (props: DataSectionProps) => {
Expand Down Expand Up @@ -65,7 +66,7 @@ const DataSection = (props: DataSectionProps) => {
</Box>
<Divider sx={{ mb: 4 }} />
<Grid container spacing={5}>
{(isLoading ? Array.from(new Array(4)) : layers ?? []).map((item: Layer, index: number) => (
{(isLoading ? Array.from(new Array(4)) : (layers ?? [])).map((item: Layer, index: number) => (
<Grid
item
key={item?.id ?? index}
Expand Down Expand Up @@ -99,11 +100,13 @@ const DataSection = (props: DataSectionProps) => {
{isLoading ? (
<Skeleton variant="rectangular" height={200} />
) : (
<EmptyCard
onClick={() => setOpenDatasetUploadModal(true)}
tooltip={t("create_new_dataset")}
backgroundImage="https://assets.plan4better.de/img/grid_thumbnail.png"
/>
!props.hideCreate && (
<EmptyCard
onClick={() => setOpenDatasetUploadModal(true)}
tooltip={t("create_new_dataset")}
backgroundImage="https://assets.plan4better.de/img/grid_thumbnail.png"
/>
)
)}
</Grid>
</Grid>
Expand Down
19 changes: 11 additions & 8 deletions apps/web/components/dashboard/home/ProjectSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ProjectModal from "@/components/modals/Project";
interface ProjectSectionProps {
projects: Project[];
isLoading: boolean;
hideCreate?: boolean;
}

const ProjectSection = (props: ProjectSectionProps) => {
Expand All @@ -43,7 +44,7 @@ const ProjectSection = (props: ProjectSectionProps) => {
</>
)}
<Grid container spacing={5}>
{(isLoading ? Array.from(new Array(3)) : projects ?? []).map((item: Project, index: number) => (
{(isLoading ? Array.from(new Array(3)) : (projects ?? [])).map((item: Project, index: number) => (
<Grid
item
key={item?.id ?? index}
Expand Down Expand Up @@ -77,13 +78,15 @@ const ProjectSection = (props: ProjectSectionProps) => {
{isLoading ? (
<Skeleton variant="rectangular" height={200} />
) : (
<EmptyCard
onClick={() => {
setOpenProjectModal(true);
}}
tooltip={t("create_new_project")}
backgroundImage="https://assets.plan4better.de/img/goat_new_project_artwork.png"
/>
!props.hideCreate && (
<EmptyCard
onClick={() => {
setOpenProjectModal(true);
}}
tooltip={t("create_new_project")}
backgroundImage="https://assets.plan4better.de/img/goat_new_project_artwork.png"
/>
)
)}
</Grid>
</Grid>
Expand Down

0 comments on commit 6b16fa1

Please sign in to comment.