Skip to content

Commit 95218d0

Browse files
VirginiaWu11hanapotski
authored andcommitted
2577 convert ResultsList to Typescript
1 parent eb09a01 commit 95218d0

2 files changed

Lines changed: 32 additions & 22 deletions

File tree

client/src/components/FoodSeeker/SearchResults/ResultsList/ResultsList.jsx renamed to client/src/components/FoodSeeker/SearchResults/ResultsList/ResultsList.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
import { useState } from "react";
2-
import {
3-
Button,
4-
CircularProgress,
5-
Stack,
6-
Typography,
7-
Divider,
8-
} from "@mui/material";
9-
import PropTypes from "prop-types";
10-
import { useEffect } from "react";
1+
import { FC, useEffect, useState } from "react";
2+
import { CircularProgress, Stack, Typography, Divider } from "@mui/material";
113
import { Virtuoso } from "react-virtuoso";
124
import * as analytics from "services/analytics";
135
import {
@@ -19,20 +11,38 @@ import StakeholderDetails from "../StakeholderDetails/StakeholderDetails";
1911
import StakeholderPreview from "../StakeholderPreview/StakeholderPreview";
2012
import useBreakpoints from "hooks/useBreakpoints";
2113
import { useMapbox } from "hooks/useMapbox";
14+
import type { Theme } from "@mui/material/styles";
15+
16+
interface Stakeholder {
17+
id: number;
18+
latitude: number;
19+
longitude: number;
20+
[key: string]: unknown;
21+
}
22+
23+
interface ResultsListProps {
24+
stakeholders: Stakeholder[];
25+
loading: boolean;
26+
handleReset?: () => void;
27+
}
2228

23-
const ResultsList = ({ stakeholders, loading, handleReset }) => {
29+
const ResultsList: FC<ResultsListProps> = ({
30+
stakeholders,
31+
loading,
32+
handleReset,
33+
}) => {
2434
const selectedOrganization = useSelectedOrganization();
2535
const [topMostIndex, setTopMostIndex] = useState(0);
2636
const { isDesktop } = useBreakpoints();
27-
const dispatch = useAppDispatch();
37+
const dispatch = useAppDispatch() as (action: any) => void;
2838
const { flyTo } = useMapbox();
2939
const open = useFilterPanel();
3040

3141
useEffect(() => {
3242
analytics.postEvent("showList");
3343
}, []);
3444

35-
const handleHover = (stakeholder) => {
45+
const handleHover = (stakeholder: Stakeholder) => {
3646
dispatch({
3747
type: "HOVERED_ORGANIZATION_UPDATED",
3848
organization: stakeholder,
@@ -65,7 +75,7 @@ const ResultsList = ({ stakeholders, loading, handleReset }) => {
6575
<Stack pt={2} spacing={2}>
6676
<Stack px={2} direction="row" justifyContent="space-between">
6777
<Typography
68-
sx={(theme) => ({
78+
sx={(theme: Theme) => ({
6979
fontWeight: "bold",
7080
fontSize: { xs: "18px" },
7181
color: theme.palette.common.gray,
@@ -94,7 +104,7 @@ const ResultsList = ({ stakeholders, loading, handleReset }) => {
94104
</Stack>
95105
)}
96106
{stakeholders.length ? (
97-
<Virtuoso
107+
<Virtuoso<Stakeholder>
98108
initialTopMostItemIndex={topMostIndex}
99109
data={stakeholders}
100110
style={{
@@ -143,11 +153,4 @@ const ResultsList = ({ stakeholders, loading, handleReset }) => {
143153
);
144154
};
145155

146-
ResultsList.propTypes = {
147-
stakeholders: PropTypes.arrayOf(PropTypes.object),
148-
status: PropTypes.string,
149-
handleReset: PropTypes.func,
150-
handleFlyTo: PropTypes.func,
151-
};
152-
153156
export default ResultsList;

client/src/theme/palette.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ declare module "@mui/material/styles" {
4343
hoverSelectedColor: string;
4444
};
4545
}
46+
47+
// Extend common colors (palette.common) with app-specific keys
48+
interface CommonColors {
49+
gray: string;
50+
disabled: string;
51+
darkGray: string;
52+
}
4653
}
4754

4855
export const white = "#FFFFFF";

0 commit comments

Comments
 (0)