Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
aivanyk committed May 4, 2024
1 parent 503b305 commit 5c66db9
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 28 deletions.
9 changes: 2 additions & 7 deletions components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import React, { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
import { IAddress } from '@pages/api/property/search';
import { IProperties } from '@components/types';

// type IProperties = {
// SAM_ID: string;
// addressDetails: IAddress;
// }
import { IAddress, IProperties } from '@components/types';

// The card on map that shows the point information
const Card = ({ properties }: {properties: IProperties} ) => {
const router = useRouter();
const SAM_ID: string = properties.SAM_ID
Expand Down
2 changes: 2 additions & 0 deletions components/ColorLegend/ColorLegend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type ViolationProps = {
};
};

// This React functional component displays a color legend for violations, allowing users to visualize the severity
// of violations based on color. It provides an interactive color slider to explore different thresholds.
const ColorLegend: React.FC<ViolationProps> = ({ lowViolation, highViolation }) => {
const [color, setColor] = useState(lowViolation.color);
const [index, setIndex] = useState(lowViolation.count)
Expand Down
2 changes: 1 addition & 1 deletion components/MapSearchbar/MapSearchbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function debounce(func: (...args: any[]) => void, wait: number) {
};
}


// The search bar in the map, locating the address
const MapSearchbar = ({ viewport, setViewport } : {
viewport: IViewport,
setViewport: React.Dispatch<React.SetStateAction<IViewport>>
Expand Down
1 change: 1 addition & 0 deletions components/NeighborhoodSelection/NeighborhoodSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from 'react';
import { INeighborhoodButton, IViewport } from '@components/types';
import { MapRef } from 'react-map-gl';

// This component allows the user to select a neighborhood and adjust the viewport of the map accordingly.
function NeighborhoodSelector(
{ neighborhoodButtons, setViewport, mapRef, hoveredNeighborhoodFeatureId, setHoveredNeighborhoodFeatureId, setHoveredNeighborhoodFeatureName } :
{
Expand Down
2 changes: 1 addition & 1 deletion components/NewMap/NewMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import NeighborhoodSelector from '@components/NeighborhoodSelection/Neighborhood
import ColorLegend from "@components/ColorLegend/ColorLegend"
import { set } from 'cypress/types/lodash';


// The map on map page
const NewMap = (
) => {
const router = useRouter();
Expand Down
13 changes: 1 addition & 12 deletions pages/api/landlords/by-pid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Landlord = {
year: string;
}

// Fetch associated landlords with a parcel id
const ByPID = async (req: NextApiRequest, res: NextApiResponse) => {
try {
const pid = Array.isArray(req.query.pid) ? req.query.pid[0] : req.query.pid;
Expand All @@ -19,18 +20,6 @@ const ByPID = async (req: NextApiRequest, res: NextApiResponse) => {
return;
}

// console.log(pid);

// const landlords = await prisma.property.findMany({
// where: {
// PID: { equals: pid },
// },
// select: {
// OWNER: true,
// },
// distinct: ['OWNER'],
// });

const landlords: Landlord[] = await prisma.$queryRaw<Landlord[]>`
SELECT DISTINCT "OWNER", "UNIT_NUM", "year" FROM "property"
WHERE SUBSTRING("PID", 1, LENGTH("PID") - 3) = ${pid.slice(0, -3)}
Expand Down
1 change: 1 addition & 0 deletions pages/api/landlords/top-ten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import prisma from "../../../prisma/prismaClient"
import { ITopTen, IViolationView } from '@components/types';
import cache from './cache';

// Top10 properties by violation number
const TopTen = async (req: NextApiRequest, res: NextApiResponse) => {
const cacheKey = "top-ten"

Expand Down
1 change: 1 addition & 0 deletions pages/api/property/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
// const prisma = new PrismaClient();
import prisma from "../../../prisma/prismaClient"

// Find address in SAM table
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const searchAddress = req.query.search as string;
Expand Down
7 changes: 1 addition & 6 deletions pages/api/property/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import { NextApiRequest, NextApiResponse } from 'next';
// const prisma = new PrismaClient();
import prisma from "../../../prisma/prismaClient"

// Find 10 suggestions for the given string. Addresses starting with the given string come first.
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const searchAddress = req.query.search as string;
const maxRecords = 10;

// const addresses = await prisma.sam.findMany({
// where: {
// FULL_ADDRESS: { contains: searchAddress, mode: 'insensitive' }, // this allows slower case values
// },
// take: 10,
// });
const startingAddresses = await prisma.sam.findMany({
where: {
FULL_ADDRESS: {
Expand Down
1 change: 1 addition & 0 deletions pages/api/property/llViolations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
// const prisma = new PrismaClient();
import prisma from "../../../prisma/prismaClient"

// TODO: Get violations associated with a landlord
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const searchAddress = req.query.llName as string;
Expand Down
1 change: 1 addition & 0 deletions pages/api/property/relatedUnits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
// const prisma = new PrismaClient();
import prisma from "../../../prisma/prismaClient"

// Find all the addresses starting with certain string in SAM table
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const searchAddress = req.query.search as string;
Expand Down
1 change: 1 addition & 0 deletions pages/api/property/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function debounce<T extends (...args: any[]) => any>(func: T, wait: number): (..
};
}

// API for page search bar
export const useSearchAPI = () => {
const [searchAddress, setSearchAddress] = useState('');
const [addressSuggestions, setAddressSuggestions] = useState<IAddress[]>([]);
Expand Down
1 change: 1 addition & 0 deletions pages/api/property/violations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
// const prisma = new PrismaClient();
import prisma from "../../../prisma/prismaClient"

// Get violations of a sam id
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const sam_id = Array.isArray(req.query.sam_id) ? req.query.sam_id[0] : req.query.sam_id;
Expand Down
1 change: 1 addition & 0 deletions pages/map/detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useEffect, useState, useRef } from 'react';
import { useSearchAPI } from '../../api/property/search';
import { IAddress } from '@components/types';

// Street Address Page
interface IViolation {
code: string;
longitude: string;
Expand Down
2 changes: 1 addition & 1 deletion pages/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ITopTen } from '@components/types';
import { GetServerSideProps } from 'next';
import { IAddress } from '@components/types';


// Map page
interface IMapProps {
topTen: ITopTen[];
}
Expand Down

0 comments on commit 5c66db9

Please sign in to comment.