Skip to content

Commit 1476a4d

Browse files
authored
Merge pull request #34 from h-sehee/refactor/code-cleanup
Format code for consistency
2 parents b8c94ad + de22811 commit 1476a4d

File tree

14 files changed

+159
-147
lines changed

14 files changed

+159
-147
lines changed

src/api/dog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const searchDogs = async (
3434
sort: string,
3535
ageMin?: number,
3636
ageMax?: number,
37-
zipCodes: string[] = [],
37+
zipCodes: string[] = []
3838
): Promise<SearchResponse> => {
3939
const params = new URLSearchParams();
4040
if (breeds.length > 0) {

src/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from "./auth";
22
export * from "./dog";
3-
export * from "./location";
3+
export * from "./location";

src/api/location.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,19 @@ export interface LocationSearchResponse {
3838
total: number;
3939
}
4040

41-
export const searchLocations = async (
42-
params: {
43-
city?: string;
44-
states?: string[];
45-
geoBoundingBox?: GeoBoundingBox;
46-
size?: number;
47-
from?: number;
48-
}
49-
): Promise<LocationSearchResponse> => {
50-
const res = await fetch(
51-
`${API_BASE_URL}/locations/search`,
52-
{
53-
method: "POST",
54-
credentials: "include",
55-
headers: { "Content-Type": "application/json" },
56-
body: JSON.stringify(params),
57-
}
58-
);
41+
export const searchLocations = async (params: {
42+
city?: string;
43+
states?: string[];
44+
geoBoundingBox?: GeoBoundingBox;
45+
size?: number;
46+
from?: number;
47+
}): Promise<LocationSearchResponse> => {
48+
const res = await fetch(`${API_BASE_URL}/locations/search`, {
49+
method: "POST",
50+
credentials: "include",
51+
headers: { "Content-Type": "application/json" },
52+
body: JSON.stringify(params),
53+
});
5954
if (!res.ok) {
6055
throw new Error("Failed to search locations");
6156
}

src/components/ActiveFilters.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
HStack,
3-
Tag,
4-
TagLabel,
5-
TagCloseButton,
6-
Box,
7-
} from "@chakra-ui/react";
1+
import { HStack, Tag, TagLabel, TagCloseButton, Box } from "@chakra-ui/react";
82
import { US_STATES } from "./FilterPopover";
93

104
interface ActiveFiltersProps {

src/components/FavoritesDrawer.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ const FavoritesDrawer: React.FC = () => {
3232
const zips = Array.from(
3333
new Set(favoriteDogsDetails.map((d) => d.zip_code))
3434
).filter(Boolean);
35-
const { locationsMap: dogLocations, loading } =
36-
useDogLocations(zips);
35+
const { locationsMap: dogLocations, loading } = useDogLocations(zips);
3736

3837
return (
3938
<Drawer

src/components/FilterPopover.tsx

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -354,56 +354,56 @@ const FilterPopover: React.FC<FilterPopoverProps> = ({
354354
};
355355

356356
export const US_STATES = [
357-
{ code: "AL", name: "Alabama" },
358-
{ code: "AK", name: "Alaska" },
359-
{ code: "AZ", name: "Arizona" },
360-
{ code: "AR", name: "Arkansas" },
361-
{ code: "CA", name: "California" },
362-
{ code: "CO", name: "Colorado" },
363-
{ code: "CT", name: "Connecticut" },
364-
{ code: "DE", name: "Delaware" },
365-
{ code: "FL", name: "Florida" },
366-
{ code: "GA", name: "Georgia" },
367-
{ code: "HI", name: "Hawaii" },
368-
{ code: "ID", name: "Idaho" },
369-
{ code: "IL", name: "Illinois" },
370-
{ code: "IN", name: "Indiana" },
371-
{ code: "IA", name: "Iowa" },
372-
{ code: "KS", name: "Kansas" },
373-
{ code: "KY", name: "Kentucky" },
374-
{ code: "LA", name: "Louisiana" },
375-
{ code: "ME", name: "Maine" },
376-
{ code: "MD", name: "Maryland" },
377-
{ code: "MA", name: "Massachusetts" },
378-
{ code: "MI", name: "Michigan" },
379-
{ code: "MN", name: "Minnesota" },
380-
{ code: "MS", name: "Mississippi" },
381-
{ code: "MO", name: "Missouri" },
382-
{ code: "MT", name: "Montana" },
383-
{ code: "NE", name: "Nebraska" },
384-
{ code: "NV", name: "Nevada" },
385-
{ code: "NH", name: "New Hampshire" },
386-
{ code: "NJ", name: "New Jersey" },
387-
{ code: "NM", name: "New Mexico" },
388-
{ code: "NY", name: "New York" },
389-
{ code: "NC", name: "North Carolina" },
390-
{ code: "ND", name: "North Dakota" },
391-
{ code: "OH", name: "Ohio" },
392-
{ code: "OK", name: "Oklahoma" },
393-
{ code: "OR", name: "Oregon" },
394-
{ code: "PA", name: "Pennsylvania" },
395-
{ code: "RI", name: "Rhode Island" },
396-
{ code: "SC", name: "South Carolina" },
397-
{ code: "SD", name: "South Dakota" },
398-
{ code: "TN", name: "Tennessee" },
399-
{ code: "TX", name: "Texas" },
400-
{ code: "UT", name: "Utah" },
401-
{ code: "VT", name: "Vermont" },
402-
{ code: "VA", name: "Virginia" },
403-
{ code: "WA", name: "Washington" },
404-
{ code: "WV", name: "West Virginia" },
405-
{ code: "WI", name: "Wisconsin" },
406-
{ code: "WY", name: "Wyoming" },
407-
];
357+
{ code: "AL", name: "Alabama" },
358+
{ code: "AK", name: "Alaska" },
359+
{ code: "AZ", name: "Arizona" },
360+
{ code: "AR", name: "Arkansas" },
361+
{ code: "CA", name: "California" },
362+
{ code: "CO", name: "Colorado" },
363+
{ code: "CT", name: "Connecticut" },
364+
{ code: "DE", name: "Delaware" },
365+
{ code: "FL", name: "Florida" },
366+
{ code: "GA", name: "Georgia" },
367+
{ code: "HI", name: "Hawaii" },
368+
{ code: "ID", name: "Idaho" },
369+
{ code: "IL", name: "Illinois" },
370+
{ code: "IN", name: "Indiana" },
371+
{ code: "IA", name: "Iowa" },
372+
{ code: "KS", name: "Kansas" },
373+
{ code: "KY", name: "Kentucky" },
374+
{ code: "LA", name: "Louisiana" },
375+
{ code: "ME", name: "Maine" },
376+
{ code: "MD", name: "Maryland" },
377+
{ code: "MA", name: "Massachusetts" },
378+
{ code: "MI", name: "Michigan" },
379+
{ code: "MN", name: "Minnesota" },
380+
{ code: "MS", name: "Mississippi" },
381+
{ code: "MO", name: "Missouri" },
382+
{ code: "MT", name: "Montana" },
383+
{ code: "NE", name: "Nebraska" },
384+
{ code: "NV", name: "Nevada" },
385+
{ code: "NH", name: "New Hampshire" },
386+
{ code: "NJ", name: "New Jersey" },
387+
{ code: "NM", name: "New Mexico" },
388+
{ code: "NY", name: "New York" },
389+
{ code: "NC", name: "North Carolina" },
390+
{ code: "ND", name: "North Dakota" },
391+
{ code: "OH", name: "Ohio" },
392+
{ code: "OK", name: "Oklahoma" },
393+
{ code: "OR", name: "Oregon" },
394+
{ code: "PA", name: "Pennsylvania" },
395+
{ code: "RI", name: "Rhode Island" },
396+
{ code: "SC", name: "South Carolina" },
397+
{ code: "SD", name: "South Dakota" },
398+
{ code: "TN", name: "Tennessee" },
399+
{ code: "TX", name: "Texas" },
400+
{ code: "UT", name: "Utah" },
401+
{ code: "VT", name: "Vermont" },
402+
{ code: "VA", name: "Virginia" },
403+
{ code: "WA", name: "Washington" },
404+
{ code: "WV", name: "West Virginia" },
405+
{ code: "WI", name: "Wisconsin" },
406+
{ code: "WY", name: "Wyoming" },
407+
];
408408

409409
export default FilterPopover;

src/components/Footer.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import { Box, Text } from "@chakra-ui/react";
44
const Footer: React.FC = () => {
55
return (
66
<Box
7-
as="footer"
8-
mt="auto"
9-
py="4"
10-
px="8"
11-
borderTop="1px solid"
12-
borderColor="gray.200"
13-
bg="#300d3811"
14-
textAlign="center"
15-
>
16-
<Text fontSize="sm" color="darkBrand.500">
17-
© 2025 PawFetch. All rights reserved.
18-
</Text>
19-
</Box>
7+
as="footer"
8+
mt="auto"
9+
py="4"
10+
px="8"
11+
borderTop="1px solid"
12+
borderColor="gray.200"
13+
bg="#300d3811"
14+
textAlign="center"
15+
>
16+
<Text fontSize="sm" color="darkBrand.500">
17+
© 2025 PawFetch. All rights reserved.
18+
</Text>
19+
</Box>
2020
);
2121
};
2222

23-
export default Footer;
23+
export default Footer;

src/components/Layout.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ const Layout = ({ children }: LayoutProps) => {
1313
style={{
1414
display: "flex",
1515
flexDirection: "column",
16-
minHeight: "100vh"
17-
}}
16+
minHeight: "100vh",
17+
}}
1818
>
1919
<NavBar />
2020

21-
<main style={{ flex: 1, padding: "1rem 2rem" }}>
22-
{children}
23-
</main>
21+
<main style={{ flex: 1, padding: "1rem 2rem" }}>{children}</main>
2422

2523
<Footer />
2624
</div>

src/components/MatchResultModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ const MatchResultModal: React.FC<MatchResultModalProps> = ({
3232
const modalSize = useBreakpointValue({ base: "sm", md: "2xl", xl: "6xl" });
3333

3434
const zip = matchDog?.zip_code ? matchDog.zip_code : "";
35-
const { location: dogLocation, loading } =
36-
useDogLocation(zip);
35+
const { location: dogLocation, loading } = useDogLocation(zip);
3736

3837
if (!matchDog) {
3938
return null;

src/hooks/useDogLocation.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import { useEffect, useState, useMemo } from "react";
22
import { fetchLocationsByZip, Location } from "../api";
33

44
export function useDogLocations(zipCodes: string[]) {
5-
const [locationsMap, setLocationsMap] = useState<Record<string, Location>>({});
5+
const [locationsMap, setLocationsMap] = useState<Record<string, Location>>(
6+
{}
7+
);
68
const [loading, setLoading] = useState(false);
79

8-
const zipKey = useMemo(
9-
() => zipCodes.filter(Boolean).join(","),
10-
[zipCodes]
11-
);
10+
const zipKey = useMemo(() => zipCodes.filter(Boolean).join(","), [zipCodes]);
1211

1312
useEffect(() => {
1413
const codes = zipKey ? zipKey.split(",") : [];
@@ -60,4 +59,4 @@ export function useDogLocation(zipCode?: string) {
6059
location: zipCode ? locationsMap[zipCode] : undefined,
6160
loading,
6261
};
63-
}
62+
}

0 commit comments

Comments
 (0)