Skip to content

Commit

Permalink
Dashboard: show FallbackMap in case operator has no subsections
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannaPeanut committed Dec 8, 2023
1 parent ed067c7 commit b694b78
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/core/components/Map/BaseMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export type BaseMapProps = Required<Pick<MapProps, "id" | "initialViewState">> &
Point,
{ subsectionSlug: string; subsubsectionSlug?: string; color: string; opacity?: number }
>
dots: [number, number][]
dots?: [number, number][]
classHeight?: string
children: React.ReactNode
children?: React.ReactNode
}

export const BaseMap: React.FC<BaseMapProps> = ({
Expand Down
22 changes: 22 additions & 0 deletions src/core/components/Map/ProjectMapFallback.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { SubsectionWithPosition } from "src/subsections/queries/getSubsection"
import { BaseMap } from "./BaseMap"
import { subsectionsBbox } from "./utils"

type Props = { subsections: SubsectionWithPosition[] }

export const ProjectMapFallback: React.FC<Props> = ({ subsections }) => {
return (
<section className="mt-3 relative">
<BaseMap
id="mainMap"
initialViewState={{
bounds: subsectionsBbox(subsections),
fitBoundsOptions: { padding: 60 },
}}
/>
<div className="inset-x-0 mx-4 bg-white/80 p-4 px-8 text-center absolute bottom-12 font-sans">
Noch keine Planungsabschnitte angelegt
</div>
</section>
)
}
7 changes: 6 additions & 1 deletion src/pages/[projectSlug]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CalenderDashboard } from "src/calendar-entries/components"
import { SuperAdminLogData } from "src/core/components/AdminBox/SuperAdminLogData"
import { Breadcrumb } from "src/core/components/Breadcrumb/Breadcrumb"
import { ProjectMap } from "src/core/components/Map/ProjectMap"
import { ProjectMapFallback } from "src/core/components/Map/ProjectMapFallback"
import { Markdown } from "src/core/components/Markdown/Markdown"
import { Spinner } from "src/core/components/Spinner"
import { Link } from "src/core/components/links"
Expand Down Expand Up @@ -81,7 +82,11 @@ export const ProjectDashboardWithQuery = () => {

<OperatorFilterDropdown />
<MapProvider>
<ProjectMap subsections={filteredSubsections} />
{Boolean(filteredSubsections.length) ? (
<ProjectMap subsections={filteredSubsections} />
) : (
<ProjectMapFallback subsections={subsections} />
)}
</MapProvider>

<SubsectionTable subsections={filteredSubsections} />
Expand Down

0 comments on commit b694b78

Please sign in to comment.