Skip to content

Commit 0b73e98

Browse files
committed
refactord NavbarActions
1 parent 0c0dde5 commit 0b73e98

5 files changed

Lines changed: 42 additions & 53 deletions

File tree

frontend/components/listings/detail/ListingDetail.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ export const ListingDetail = ({ listing, initialIsFavorited }: Props) => {
5656
toggleFavoriteMutation.mutate(!isFavorited);
5757
};
5858

59-
const subletCoords =
60-
listingType === "sublet" ? listing.additional_data : null;
61-
const hasLocation =
62-
subletCoords?.latitude != null && subletCoords?.longitude != null;
59+
const subletCoords = listingType === "sublet" ? listing.additional_data : null;
60+
const hasLocation = subletCoords?.latitude != null && subletCoords?.longitude != null;
6361

6462
return (
6563
<div className="mx-auto flex w-full max-w-[96rem] flex-col p-8 px-4 sm:px-12">
@@ -94,13 +92,11 @@ export const ListingDetail = ({ listing, initialIsFavorited }: Props) => {
9492
<div>
9593
<h2 className="text-lg font-semibold">{"Where you'll be living"}</h2>
9694
<p className="text-sm text-gray-500">
97-
Approximate location shown. The exact location will be shared once you connect with the owner.
95+
Approximate location shown. The exact location will be shared once you connect
96+
with the owner.
9897
</p>
99-
</div>
100-
<SubletMap
101-
latitude={subletCoords.latitude!}
102-
longitude={subletCoords.longitude!}
103-
/>
98+
</div>
99+
<SubletMap latitude={subletCoords.latitude!} longitude={subletCoords.longitude!} />
104100
</div>
105101
)}
106102
<ListingActions

frontend/components/listings/detail/SubletMap.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ interface Props {
88
}
99

1010
const LazyMap = dynamic(
11-
() =>
12-
import("@/components/listings/detail/SubletMapContent").then((m) => m.SubletMapContent),
13-
{ ssr: false },
11+
() => import("@/components/listings/detail/SubletMapContent").then((m) => m.SubletMapContent),
12+
{ ssr: false }
1413
);
1514

1615
export const SubletMap = ({ latitude, longitude }: Props) => {

frontend/components/navbar/Navbar.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@ export const Navbar = () => {
4646
</div>
4747
)}
4848

49-
{createNewConfig && (
50-
<NavbarActions
51-
createNewText={createNewConfig.text}
52-
createNewHref={createNewConfig.href}
53-
mobileShowHamburger={showListingsTabs}
54-
isMobileMenuOpen={isMobileMenuOpen}
55-
onToggleMobileMenu={toggleMobileMenu}
56-
/>
57-
)}
49+
<NavbarActions
50+
createNewConfig={createNewConfig}
51+
mobileShowHamburger={showListingsTabs}
52+
isMobileMenuOpen={isMobileMenuOpen}
53+
onToggleMobileMenu={toggleMobileMenu}
54+
/>
5855
</div>
5956
</div>
6057
</div>

frontend/components/navbar/NavbarActions.tsx

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ import { Button } from "@/components/ui/button";
66
import { UserProfileDropdown } from "./UserProfileDropdown";
77

88
interface Props {
9-
createNewText: string;
10-
createNewHref: string;
9+
createNewConfig: { text: string; href: string } | undefined;
1110
mobileShowHamburger: boolean;
1211
isMobileMenuOpen: boolean;
1312
onToggleMobileMenu: () => void;
1413
}
1514

1615
export const NavbarActions = ({
17-
createNewText,
18-
createNewHref,
16+
createNewConfig,
1917
mobileShowHamburger,
2018
isMobileMenuOpen,
2119
onToggleMobileMenu,
@@ -61,33 +59,33 @@ export const NavbarActions = ({
6159

6260
return (
6361
<div className="flex items-center gap-2 sm:gap-3">
64-
{/* desktop only new listing button */}
65-
{
66-
<Button
67-
variant="outline"
68-
className="border-primary text-primary hover:bg-primary hover:text-primary-foreground hidden gap-2 md:flex"
69-
asChild
70-
>
71-
<Link href={createNewHref} aria-label={createNewText}>
72-
<Plus className="h-4 w-4" />
73-
<span>{createNewText}</span>
74-
</Link>
75-
</Button>
76-
}
62+
{createNewConfig && (
63+
<>
64+
{/* desktop only new listing button */}
65+
<Button
66+
variant="outline"
67+
className="border-primary text-primary hover:bg-primary hover:text-primary-foreground hidden gap-2 md:flex"
68+
asChild
69+
>
70+
<Link href={createNewConfig.href} aria-label={createNewConfig.text}>
71+
<Plus className="h-4 w-4" />
72+
<span>{createNewConfig.text}</span>
73+
</Link>
74+
</Button>
7775

78-
{/* mobile only new listing button (icon only) */}
79-
{
80-
<Button
81-
variant="outline"
82-
size="icon"
83-
className="border-primary text-primary hover:bg-primary hover:text-primary-foreground md:hidden"
84-
asChild
85-
>
86-
<Link href={createNewHref} aria-label={createNewText}>
87-
<Plus className="h-4 w-4" />
88-
</Link>
89-
</Button>
90-
}
76+
{/* mobile only new listing button (icon only) */}
77+
<Button
78+
variant="outline"
79+
size="icon"
80+
className="border-primary text-primary hover:bg-primary hover:text-primary-foreground md:hidden"
81+
asChild
82+
>
83+
<Link href={createNewConfig.href} aria-label={createNewConfig.text}>
84+
<Plus className="h-4 w-4" />
85+
</Link>
86+
</Button>
87+
</>
88+
)}
9189

9290
{/* notification bell */}
9391
<Button

frontend/lib/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const BASE_URL =
1111

1212
export const API_BASE_URL =
1313
process.env.NODE_ENV === "production" ? "REPLACE WITH PROD API URL" : "http://backend:8000"; // can't be localhost because server fetch happens in container
14-
1514

1615
export const PLATFORM_URL = process.env.PLATFORM_URL;
1716
export const CLIENT_ID = process.env.CLIENT_ID;

0 commit comments

Comments
 (0)