From 2b7c336239414f206d8e38f287a8f00ffbe92645 Mon Sep 17 00:00:00 2001 From: Sergey Bolshakov Date: Mon, 27 Oct 2025 22:47:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D0=BE=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5?= =?UTF-8?q?,=20=D0=B8=D1=82=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D1=8F=2012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/FeaturedYacht.tsx | 18 +- src/components/form/guest-date-picker.tsx | 310 ++++++++++++++++++++++ src/components/ui/counter.tsx | 2 +- src/types/icon.ts | 1 - 4 files changed, 317 insertions(+), 14 deletions(-) create mode 100644 src/components/form/guest-date-picker.tsx delete mode 100644 src/types/icon.ts diff --git a/src/app/components/FeaturedYacht.tsx b/src/app/components/FeaturedYacht.tsx index d0530b0..20b0b25 100644 --- a/src/app/components/FeaturedYacht.tsx +++ b/src/app/components/FeaturedYacht.tsx @@ -2,7 +2,6 @@ import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; -import { DatePicker } from "@/components/ui/date-picker"; import { Carousel, CarouselContent, @@ -13,7 +12,7 @@ import { import Image from "next/image"; import Icon from "@/components/ui/icon"; import { useState } from "react"; -import { GuestPicker } from "@/components/form/guest-picker"; +import { GuestDatePicker } from "@/components/form/guest-date-picker"; const yacht = { name: "Яхта", @@ -140,7 +139,7 @@ export default function FeaturedYacht() { {/* Promoted badge */} {yacht.isPromoted && (
- + Это объявление продвигается.{" "} @@ -152,7 +151,7 @@ export default function FeaturedYacht() {
{/* Right side - Booking form */} -
+
{/* Promoted banner - Desktop only */}
{/* Booking form */} -
+
- -
-
- -
-
- +
+
{/* Book button */} diff --git a/src/components/form/guest-date-picker.tsx b/src/components/form/guest-date-picker.tsx new file mode 100644 index 0000000..5e4fe96 --- /dev/null +++ b/src/components/form/guest-date-picker.tsx @@ -0,0 +1,310 @@ +"use client"; + +import React, { useState } from "react"; +import { format } from "date-fns"; +import { ru } from "date-fns/locale"; +import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"; + +import { Button } from "@/components/ui/button"; +import { Calendar } from "@/components/ui/calendar"; +import { Counter } from "@/components/ui/counter"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; + +interface GuestDatePickerProps { + onApply?: (data: { + date: Date | undefined; + departureTime: string; + arrivalTime: string; + adults: number; + children: number; + }) => void; + className?: string; +} + +interface CommonPopoverContentProps { + date: Date | undefined; + setDate: (date: Date | undefined) => void; + departureTime: string; + setDepartureTime: (time: string) => void; + arrivalTime: string; + setArrivalTime: (time: string) => void; + adults: number; + setAdults: (count: number) => void; + childrenCount: number; + setChildrenCount: (count: number) => void; + handleApply: () => void; +} + +const CommonPopoverContent: React.FC = ({ + date, + setDate, + departureTime, + setDepartureTime, + arrivalTime, + setArrivalTime, + adults, + setAdults, + childrenCount, + setChildrenCount, + handleApply, +}) => { + return ( + + {/* Календарь */} +
+ + date < new Date(new Date().setHours(0, 0, 0, 0)) + } + classNames={{ + root: "w-full", + month: "flex w-full flex-col gap-4", + button_previous: + "h-8 w-8 flex items-center justify-center hover:bg-gray-100 rounded-md", + button_next: + "h-8 w-8 flex items-center justify-center hover:bg-gray-100 rounded-md", + month_caption: + "flex h-8 w-full items-center justify-center px-8 text-gray-700 font-semibold", + table: "w-full border-collapse", + weekdays: "flex", + weekday: + "flex-1 text-gray-500 text-xs font-normal p-2 text-center", + day_button: "font-bold ring-0 focus:ring-0", + week: "mt-2 flex w-full", + today: "bg-gray-100 text-gray-900 rounded-full", + outside: "text-gray-300", + disabled: "text-gray-400 cursor-not-allowed", + selected: + "rounded-full border-none outline-none !bg-brand text-white", + }} + /> +
+ + {/* Счетчики гостей */} +
+ + +
+ + {/* Поля времени */} +
+
+ +
+ + setDepartureTime(e.target.value)} + className="w-full focus:outline-none focus:border-transparent" + /> +
+
+ +
+ +
+ + setArrivalTime(e.target.value)} + className="w-full focus:outline-none focus:border-transparent" + /> +
+
+
+ + {/* Кнопка Применить */} + +
+ ); +}; + +export const GuestDatePicker: React.FC = ({ + onApply, + className, +}) => { + const [date, setDate] = useState(); + const [departureTime, setDepartureTime] = useState("12:00"); + const [arrivalTime, setArrivalTime] = useState("13:00"); + const [adults, setAdults] = useState(1); + const [children, setChildren] = useState(0); + const [isDepartureOpen, setIsDepartureOpen] = useState(false); + const [isArrivalOpen, setIsArrivalOpen] = useState(false); + const [isGuestOpen, setIsGuestOpen] = useState(false); + + const handleApply = () => { + onApply?.({ + date, + departureTime, + arrivalTime, + adults, + children, + }); + setIsDepartureOpen(false); + setIsArrivalOpen(false); + setIsGuestOpen(false); + }; + + const getDepartureDisplayText = () => { + if (!date || !departureTime) return "Выход"; + + return ( + <> + {format(date, "d MMMM", { + locale: ru, + })} + , {departureTime} + + ); + }; + + const getArrivalDisplayText = () => { + if (!date || !arrivalTime) return "Заход"; + + return ( + <> + {format(date, "d MMMM", { + locale: ru, + })} + , {arrivalTime} + + ); + }; + + const getGuestDisplayText = () => { + if (adults === 1 && children === 0) return "1 гость"; + return ( + + Взрослых: {adults}, Детей: {children} + + ); + }; + + return ( +
+
+ {/* Кнопка Выход */} + + + + + + + + {/* Кнопка Заход */} + + + + + + + + {/* Кнопка Гости */} + + + + + + +
+
+ ); +}; diff --git a/src/components/ui/counter.tsx b/src/components/ui/counter.tsx index 6ad7089..a8c05f4 100644 --- a/src/components/ui/counter.tsx +++ b/src/components/ui/counter.tsx @@ -31,7 +31,7 @@ export const Counter: React.FC = ({ }; return ( -
+
diff --git a/src/types/icon.ts b/src/types/icon.ts deleted file mode 100644 index 8b13789..0000000 --- a/src/types/icon.ts +++ /dev/null @@ -1 +0,0 @@ -