diff --git a/app/components/CapitalProjectsAccordionPanel.tsx b/app/components/CapitalProjectsAccordionPanel.tsx index 2071783..c59f92c 100644 --- a/app/components/CapitalProjectsAccordionPanel.tsx +++ b/app/components/CapitalProjectsAccordionPanel.tsx @@ -1,7 +1,8 @@ import { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, Box, Flex, HStack, Heading, IconButton } from "@nycplanning/streetscape" -import { CapitalProject } from "~/gen"; +import { Agency, CapitalProject } from "~/gen"; import { CapitalProjectsList } from "./CapitalProjectsList"; import { ChevronLeftIcon } from "@chakra-ui/icons"; +import { Divider } from "@chakra-ui/react"; export interface CapitalProjectsAccordionPanelProps { capitalProjects: Array; @@ -10,10 +11,11 @@ export interface CapitalProjectsAccordionPanelProps { path: string; offset: number; total: number; + agencies: Agency[]; } export const CapitalProjectsAccordionPanel = ({ - capitalProjects, district, limit, offset, total, path + capitalProjects, district, limit, offset, total, path, agencies, }: CapitalProjectsAccordionPanelProps) => { return ( - +

- + - + + {/*

sdlkfja;sdlkjf;sa

*/} {district} - -
+ + +

- + +

sadlkfja;dsk

+ + + +
diff --git a/app/components/CapitalProjectsList.tsx b/app/components/CapitalProjectsList.tsx index 7be0976..7cdcc7d 100644 --- a/app/components/CapitalProjectsList.tsx +++ b/app/components/CapitalProjectsList.tsx @@ -1,6 +1,6 @@ import { Box, Flex, Hide, FlexProps, VStack, HStack, IconButton, Link} from "@nycplanning/streetscape"; import { useState } from "react"; -import { CapitalProject } from "~/gen"; +import { Agency, CapitalProject } from "~/gen"; import { getYear, getMonth, compareAsc } from "date-fns"; import { CapitalProjectsListItem } from "./CapitalProjectsListItem"; import { Button } from "@chakra-ui/react"; @@ -15,11 +15,12 @@ export interface CapitalProjectsListProps { limit: number; offset: number; total: number; + agencies: Agency[]; path: string; } export const CapitalProjectsList = ({ - capitalProjects, limit, offset, total, path + capitalProjects, limit, offset, total, path, agencies, }: CapitalProjectsListProps) => { const [searchParams] = useSearchParams(); @@ -66,27 +67,17 @@ export const CapitalProjectsList = ({ // const Pagination = () => return ( - - // - // { - // setIsExpanded(!isExpanded); - // }} - // /> - // <> - + + + + {/* this should be a generic panel for project detail and list */} {/* we need a separate component for project list item */} @@ -100,7 +91,9 @@ export const CapitalProjectsList = ({ description={capitalProject.description} minDate={capitalProject.minDate} maxDate={capitalProject.maxDate} - agency= {capitalProject.managingAgency} + agency= { agencies.find( + (agency) => agency.initials === capitalProject.managingAgency, + )?.name } yearRange={formatFiscalYearRange( new Date(capitalProject.minDate), new Date(capitalProject.maxDate), @@ -110,34 +103,10 @@ export const CapitalProjectsList = ({ })} + - - - - {/* We cannot know the size of the capital projects so we need to test out the 'next' offset to determine whether or not we should disable */} - {/* - } /> - - } /> - */} - + + diff --git a/app/components/CapitalProjectsListItem.tsx b/app/components/CapitalProjectsListItem.tsx index c4ea471..703387c 100644 --- a/app/components/CapitalProjectsListItem.tsx +++ b/app/components/CapitalProjectsListItem.tsx @@ -6,7 +6,7 @@ export interface CapitalProjectsListItemProps { description: string; minDate: string; maxDate: string; - agency: string; + agency: string | undefined; yearRange: string; } diff --git a/app/components/Pagination.tsx b/app/components/Pagination.tsx index 20b6a75..c3cd4ce 100644 --- a/app/components/Pagination.tsx +++ b/app/components/Pagination.tsx @@ -1,5 +1,5 @@ import { ChevronLeftIcon, ChevronRightIcon } from "@chakra-ui/icons"; -import { HStack, IconButton } from "@nycplanning/streetscape"; +import { Flex, HStack, IconButton } from "@nycplanning/streetscape"; import { useSearchParams } from "@remix-run/react"; import { Button } from "@chakra-ui/button"; import { Link } from "@remix-run/react"; @@ -16,23 +16,29 @@ export const Pagination = ({total, path}: PaginationProps) => { const limit = Number(searchParams.get("limit")); const offset = Number(searchParams.get("offset")); - const currentPage = Math.floor(offset / limit) + 1; + const currentPage = offset === 0 ? 1 : offset / limit + 1; + console.log(currentPage); const canSkipBackward = offset > 0; const canSkipForward = total === limit; - // const skip + const search = `?limit=7&offset=`; return ( - - - - }/> - - - } /> - + + + + }/> + + + + } /> + + + ); } \ No newline at end of file diff --git a/app/routes/city-council-districts.$cityCouncilDistrictId.capital-projects.tsx b/app/routes/city-council-districts.$cityCouncilDistrictId.capital-projects.tsx index b72111e..aeae4f8 100644 --- a/app/routes/city-council-districts.$cityCouncilDistrictId.capital-projects.tsx +++ b/app/routes/city-council-districts.$cityCouncilDistrictId.capital-projects.tsx @@ -1,5 +1,5 @@ import { LoaderFunctionArgs, json } from "@remix-run/node"; -import { findCapitalProjectsByCityCouncilId } from "../gen"; +import { findCapitalProjectsByCityCouncilId, findAgencies } from "../gen"; import { useLoaderData, useNavigate } from "@remix-run/react"; import { CapitalProjectsList } from "~/components/CapitalProjectsList"; import { CapitalProjectsAccordionPanel } from "~/components/CapitalProjectsAccordionPanel"; @@ -9,6 +9,9 @@ export async function loader({ request, params }: LoaderFunctionArgs) { const url = new URL(request.url); const path = url.pathname; console.log("url", url); + const agenciesResponse = await findAgencies({ + baseURL: `${import.meta.env.VITE_ZONING_API_URL}/api`, + }); const limitParam = url.searchParams.get("limit"); const offsetParam = url.searchParams.get("offset"); let limit; @@ -33,7 +36,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) { await findCapitalProjectsByCityCouncilId( cityCouncilDistrictId, { - limit, + limit: 7, offset, }, { @@ -41,17 +44,18 @@ export async function loader({ request, params }: LoaderFunctionArgs) { }, ); - return {projectsByCityCouncilDistrictResponse, limit, offset, cityCouncilDistrictId}; + return {projectsByCityCouncilDistrictResponse, agencies: agenciesResponse.agencies, limit, offset, path, cityCouncilDistrictId}; } export default function CapitalProjectsByCityCouncilDistrict() { - const {projectsByCityCouncilDistrictResponse, cityCouncilDistrictId, limit, offset} = useLoaderData(); + const {projectsByCityCouncilDistrictResponse, agencies, cityCouncilDistrictId, limit, path, offset} = useLoaderData(); console.log("in return fuction", projectsByCityCouncilDistrictResponse.capitalProjects); return (