From a126b41140e3bc4c438814d5bb9d6d883d97ed0d Mon Sep 17 00:00:00 2001 From: Arbyhisenaj <41119392+Arbyhisenaj@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:18:42 -0700 Subject: [PATCH 01/20] mild --- nextjs/src/app/reports/MapNavbar.tsx | 79 ++++ .../app/reports/[id]/ConstituenciesPanel.tsx | 20 +- nextjs/src/app/reports/[id]/context.tsx | 4 +- nextjs/src/app/reports/[id]/layout.tsx | 14 +- nextjs/src/app/reports/[id]/page.tsx | 149 +++---- nextjs/src/components/TopConstituencies.tsx | 77 +++- nextjs/src/components/dataConfig.tsx | 396 +++++++++--------- nextjs/src/components/navbar.tsx | 9 +- .../components/report/AddMapLayerButton.tsx | 2 +- nextjs/src/components/report/ReportMap.tsx | 4 +- .../components/reportsConstituencyItem.tsx | 3 +- .../components/ui/ConstituenciesDropdown.tsx | 100 +++++ nextjs/src/lib/map.tsx | 2 +- 13 files changed, 552 insertions(+), 307 deletions(-) create mode 100644 nextjs/src/app/reports/MapNavbar.tsx create mode 100644 nextjs/src/components/ui/ConstituenciesDropdown.tsx diff --git a/nextjs/src/app/reports/MapNavbar.tsx b/nextjs/src/app/reports/MapNavbar.tsx new file mode 100644 index 000000000..06f006c52 --- /dev/null +++ b/nextjs/src/app/reports/MapNavbar.tsx @@ -0,0 +1,79 @@ +'use client' + +import React from 'react' +import Link from 'next/link' +import { MappedIcon } from '@/components/navbar' +import { Provider as JotaiProvider, atom, useAtom, useAtomValue } from "jotai"; +import { MAP_REPORT_FRAGMENT, isConstituencyPanelOpenAtom, isDataConfigOpenAtom } from "@/lib/map"; +import { MAP_REPORT_LAYER_ANALYTICS, ReportMap, selectedConstituencyAtom } from "@/components/report/ReportMap"; + +import { BarChart3, Layers, MoreVertical, RefreshCcw, Trash } from "lucide-react" +import { twMerge } from "tailwind-merge"; + + + + + + + + +export default function MapNavbar() { + // const[isDataConfigOpen, setDataConfigOpen] = useAtom(isDataConfigOpenAtom); + // const toggleDataConfig = () => setDataConfigOpen(b => !b); + // const [isConstituencyPanelOpen, setConstituencyPanelOpen] = useAtom(isConstituencyPanelOpenAtom); + // const [selectedConstituency, setSelectedConstituency] = useAtom(selectedConstituencyAtom); + // const toggleConsData = () => { + // setConstituencyPanelOpen(b => { + // if (b) { + // setSelectedConstituency(null) + // } + // return !b + // }) + // } + + // const toggles = [ + // { + // icon: Layers, + // label: "Map layers", + // enabled: isDataConfigOpen, + // toggle: toggleDataConfig + // }, + // { + // icon: BarChart3, + // label: "Constituency data", + // enabled: isConstituencyPanelOpen, + // toggle: toggleConsData + // } + // ] + + return ( + + + + Report Name •124 Members + + + {/* {toggles.map(({ icon: Icon, label, enabled, toggle }) => ( + + + + {label} + + + ))} */} + + + Share + + + ) +} diff --git a/nextjs/src/app/reports/[id]/ConstituenciesPanel.tsx b/nextjs/src/app/reports/[id]/ConstituenciesPanel.tsx index cef941302..808308c4d 100644 --- a/nextjs/src/app/reports/[id]/ConstituenciesPanel.tsx +++ b/nextjs/src/app/reports/[id]/ConstituenciesPanel.tsx @@ -1,6 +1,7 @@ import { selectedConstituencyAtom } from "@/components/report/ReportMap" import { atom, useAtom } from "jotai" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" +import { X } from "lucide-react" import { Card, CardContent, @@ -15,7 +16,8 @@ import { useReportContext } from "./context"; export const constituencyPanelTabAtom = atom("list") -export function ConstituenciesPanel () { + +export function ConstituenciesPanel() { const [ selectedConstituencyId, setSelectedConstituency, @@ -33,12 +35,16 @@ export function ConstituenciesPanel () { }, [selectedConstituencyId, setTab]) return ( - - - - All Constituencies + + + Constituency Data + {/* { setOpen(false) }} /> */} + + + + All {!!selectedConstituencyId && ( - + Selected )} @@ -55,6 +61,6 @@ export function ConstituenciesPanel () { )} - + ) } \ No newline at end of file diff --git a/nextjs/src/app/reports/[id]/context.tsx b/nextjs/src/app/reports/[id]/context.tsx index d92761144..ac4396dde 100644 --- a/nextjs/src/app/reports/[id]/context.tsx +++ b/nextjs/src/app/reports/[id]/context.tsx @@ -5,8 +5,8 @@ import { QueryResult } from "@apollo/client"; import { createContext, useContext, useState } from "react"; export const defaultDisplayOptions = { - showLastElectionData: false, - showMPs: false, + showLastElectionData: true, + showMPs: true, showStreetDetails: false, analyticalAreaType: AnalyticalAreaType.ParliamentaryConstituency_2025 } diff --git a/nextjs/src/app/reports/[id]/layout.tsx b/nextjs/src/app/reports/[id]/layout.tsx index 10888c4b0..75ab4d99c 100644 --- a/nextjs/src/app/reports/[id]/layout.tsx +++ b/nextjs/src/app/reports/[id]/layout.tsx @@ -1,6 +1,8 @@ + import Navbar from "@/components/navbar"; import { useAuth } from "@/hooks/auth"; import { Toaster } from "sonner"; + import { GetMapReportNameQuery, GetMapReportNameQueryVariables } from "@/__generated__/graphql"; import { Metadata } from "next"; import { getClient } from "@/services/apollo-client"; @@ -18,10 +20,18 @@ export default async function Layout({ const user = await useAuth(); const isLoggedIn = Boolean(user); + + + + return (
•