Skip to content
42 changes: 35 additions & 7 deletions src/components/landlord/AddViewingWindowForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const DAYS = [
'SUNDAY',
] as const;

const DAY_OPTIONS = [
...DAYS,
'EVERYDAY',
'WEEKDAYS',
] as const;

export const AddViewingWindowForm: React.FC<AddViewingWindowFormProps> = ({
propertyId,
onSuccess,
Expand All @@ -43,16 +49,34 @@ export const AddViewingWindowForm: React.FC<AddViewingWindowFormProps> = ({
return;
}

// Wrap in array as server expects a list of windows for the property
const payload = {
propertyId,
viewingWindows: [
// Expand shortcut options into individual days for the backend
const getSelectedWindows = () => {
if (dayOfWeek === 'EVERYDAY') {
return DAYS.map((day) => ({
dayOfWeek: day,
startTime,
endTime,
}));
}
if (dayOfWeek === 'WEEKDAYS') {
return ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY'].map((day) => ({
dayOfWeek: day,
startTime,
endTime,
}));
}
return [
{
dayOfWeek,
startTime,
endTime,
},
],
];
};

const payload = {
propertyId,
viewingWindows: getSelectedWindows(),
};

updateWindows(payload, {
Expand All @@ -76,9 +100,13 @@ export const AddViewingWindowForm: React.FC<AddViewingWindowFormProps> = ({
<SelectValue placeholder="Select day" />
</SelectTrigger>
<SelectContent>
{DAYS.map((day) => (
{DAY_OPTIONS.map((day) => (
<SelectItem key={day} value={day}>
{day.charAt(0) + day.slice(1).toLowerCase()}
{day === 'EVERYDAY'
? 'Everyday'
: day === 'WEEKDAYS'
? 'Weekdays'
: day.charAt(0) + day.slice(1).toLowerCase()}
</SelectItem>
))}
</SelectContent>
Expand Down
29 changes: 24 additions & 5 deletions src/components/landlord/create-property/ViewingWindowsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ export const ViewingWindowsForm: React.FC<ViewingWindowsFormProps> = ({ disabled

const [editingWindowIndex, setEditingWindowIndex] = useState<number | null>(null);
const [isAddingWindow, setIsAddingWindow] = useState(false);
const [tempWindow, setTempWindow] = useState<{ dayOfWeek: 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY'; startTime: string; endTime: string }>({
const [tempWindow, setTempWindow] = useState<{ dayOfWeek: string; startTime: string; endTime: string }>({
dayOfWeek: 'MONDAY',
startTime: '09:00',
endTime: '12:00',
});

const DAYS = ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'];
const DAY_OPTIONS = [...DAYS, 'EVERYDAY', 'WEEKDAYS'];

const handleStartAddWindow = () => {
if (disabled) return;
setTempWindow({ dayOfWeek: 'MONDAY', startTime: '09:00', endTime: '12:00' });
Expand Down Expand Up @@ -62,14 +65,26 @@ export const ViewingWindowsForm: React.FC<ViewingWindowsFormProps> = ({ disabled
};

const handleSaveWindow = () => {
const expandWindows = (base: { dayOfWeek: string; startTime: string; endTime: string }) => {
if (base.dayOfWeek === 'EVERYDAY') {
return DAYS.map(day => ({ ...base, dayOfWeek: day }));
}
if (base.dayOfWeek === 'WEEKDAYS') {
return ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY'].map(day => ({ ...base, dayOfWeek: day }));
}
return [base];
};

const newWindows = expandWindows(tempWindow) as any[];

if (editingWindowIndex !== null) {
const next = [...viewingWindows];
next[editingWindowIndex] = { ...tempWindow };
next.splice(editingWindowIndex, 1, ...newWindows);
setValue('viewingWindows', next);
} else {
setValue('viewingWindows', [
...viewingWindows,
{ ...tempWindow },
...newWindows,
]);
}
setEditingWindowIndex(null);
Expand Down Expand Up @@ -133,9 +148,13 @@ export const ViewingWindowsForm: React.FC<ViewingWindowsFormProps> = ({ disabled
<SelectValue placeholder="Select day" />
</SelectTrigger>
<SelectContent>
{['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'].map((day) => (
{DAY_OPTIONS.map((day) => (
<SelectItem key={day} value={day}>
{day.charAt(0) + day.slice(1).toLowerCase()}
{day === 'EVERYDAY'
? 'Everyday'
: day === 'WEEKDAYS'
? 'Weekdays'
: day.charAt(0) + day.slice(1).toLowerCase()}
</SelectItem>
))}
</SelectContent>
Expand Down
2 changes: 1 addition & 1 deletion src/components/public/footer/FooterCompany.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NavLink } from 'react-router-dom';
import { navLinks } from '../nav/Navbar';
import { navLinks } from '../nav/nav-links';

export const FooterFeatures = () => {
return (
Expand Down
15 changes: 12 additions & 3 deletions src/components/public/hero/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Navbar } from '../nav/Navbar';
import { Logo } from '@/components/shared/Logo';
// NOTE: useNavigate commented out - not needed while original CTA buttons are replaced
// with "Join the Waitlist" for early stage rollout. Uncomment when restoring.
// import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { HeroCarousel } from './HeroCarousel';
import { HeroConfig } from './types';
import { highlightHeroHeadline } from '@/utils/highlightHeroHeadline';
Expand All @@ -16,7 +16,7 @@ interface HeroProps {
export const Hero = ({ config }: HeroProps) => {
// NOTE: navigate and ctas commented out - not needed while CTA buttons are replaced
// with "Join the Waitlist" button for early stage rollout. Uncomment when restoring original CTAs.
// const navigate = useNavigate();
const navigate = useNavigate();
const { size, media, content } = config;
// const { size, media, content, ctas } = config;

Expand All @@ -33,7 +33,16 @@ export const Hero = ({ config }: HeroProps) => {
<div className="flex items-center justify-between p-5 lg:w-[95%] lg:mx-auto">
<Logo className="text-2xl font-bold text-primary-foreground" />
<Navbar />
<LandingCTA className="hidden lg:inline-flex px-6 rounded-full bg-accent text-accent-foreground hover:bg-accent/90" />
<div className="hidden lg:flex items-center gap-4">
<Button
variant="ghost"
onClick={() => navigate('/auth/login')}
className="text-primary-foreground hover:bg-white/20 px-4 rounded-full"
>
Sign In
</Button>
<LandingCTA className="px-6 rounded-full bg-accent text-accent-foreground hover:bg-accent/90" />
</div>
</div>
</div>

Expand Down
29 changes: 1 addition & 28 deletions src/components/public/nav/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,7 @@ import { LandingCTA } from '../hero/LandingCTA';
import { useMediaQuery } from '@/hooks/useMediaQuery';
import { Button } from '../../ui/button';

type NavLinksType = {
id: string;
label: string;
slug: string;
};
export const navLinks: NavLinksType[] = [
{
id: '1',
label: 'Home',
slug: '/',
},
{
id: '2',
label: `Listings`,
slug: '/listings',
},
{
id: '3',
label: 'About Us',
slug: '/about',
},

{
id: '4',
label: 'Contact Us',
slug: '/contact',
},
];
import { navLinks } from './nav-links';

export const Navbar = () => {
const [isNavOpen, setIsNavOpen] = useState(false);
Expand Down
28 changes: 28 additions & 0 deletions src/components/public/nav/nav-links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export type NavLinksType = {
id: string;
label: string;
slug: string;
};

export const navLinks: NavLinksType[] = [
{
id: '1',
label: 'Home',
slug: '/',
},
{
id: '2',
label: `Listings`,
slug: '/listings',
},
{
id: '3',
label: 'About Us',
slug: '/about',
},
{
id: '4',
label: 'Contact Us',
slug: '/contact',
},
];
2 changes: 1 addition & 1 deletion src/components/ui/alert-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react"
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"

import { cn } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
import { buttonVariants } from "@/components/ui/button-variants"

const AlertDialog = AlertDialogPrimitive.Root

Expand Down
33 changes: 33 additions & 0 deletions src/components/ui/button-variants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { cva, type VariantProps } from "class-variance-authority"

export const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-xl text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground",
destructive:
"bg-destructive text-destructive-foreground",
outline:
"border border-primary text-primary bg-background hover:!bg-[#00E4B2] hover:!text-white hover:!border-[#00E4B2]",
secondary:
"bg-secondary text-secondary-foreground",
ghost: "text-primary-foreground bg-white/20",
link: "text-primary underline-offset-4",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)

export type ButtonVariantProps = VariantProps<typeof buttonVariants>
35 changes: 3 additions & 32 deletions src/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,9 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"

const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-xl text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground",
destructive:
"bg-destructive text-destructive-foreground",
outline:
"border border-primary text-primary bg-background hover:!bg-[#00E4B2] hover:!text-white hover:!border-[#00E4B2]",
secondary:
"bg-secondary text-secondary-foreground",
ghost: "",
link: "text-primary underline-offset-4",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
import { buttonVariants } from "./button-variants"

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
Expand All @@ -54,4 +25,4 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
)
Button.displayName = "Button"

export { Button, buttonVariants }
export { Button }
3 changes: 2 additions & 1 deletion src/components/ui/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker"

import { cn } from "@/lib/utils"
import { Button, buttonVariants } from "@/components/ui/button"
import { Button } from "@/components/ui/button"
import { buttonVariants } from "@/components/ui/button-variants"

function Calendar({
className,
Expand Down
3 changes: 2 additions & 1 deletion src/components/ui/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from "react"
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react"

import { cn } from "@/lib/utils"
import { ButtonProps, buttonVariants } from "@/components/ui/button"
import { ButtonProps } from "@/components/ui/button"
import { buttonVariants } from "@/components/ui/button-variants"

const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
<nav
Expand Down