Skip to content

Commit

Permalink
added default date on calendar in pricing toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
teetangh committed Dec 12, 2024
1 parent 0df98a5 commit a652985
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function PricingToggle({
subscriptionOptions = defaultSubscriptionOptions,
handleBooking,
selectedDate,
setSelectedDate,
currentDate,
setCurrentDate,
renderCalendar,
Expand Down Expand Up @@ -96,6 +97,12 @@ export default function PricingToggle({
return breakDownSlotsByDuration(daySlots, selectedDuration);
}, [slotTimings, selectedDate, selectedDuration]);

const handleBookNowClick = () => {
const today = new Date();
setSelectedDate(today);
setCurrentDate(new Date(today.getFullYear(), today.getMonth(), 1));
};

if (consultationOptions.length === 0 && subscriptionOptions.length === 0) {
return (
<div className="w-full max-w-4xl mx-auto py-8 px-4 sm:px-6 lg:px-8 bg-gradient-to-br from-gray-900 to-black rounded-3xl shadow-2xl">
Expand Down Expand Up @@ -221,6 +228,7 @@ export default function PricingToggle({
<Button
variant="outline"
className="w-full bg-white text-black hover:bg-gray-100 transition-colors duration-300"
onClick={handleBookNowClick}
>
Book Now
</Button>
Expand Down
4 changes: 4 additions & 0 deletions app/explore/experts/[consultantId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default function ExpertProfile(
}, [params.consultantId, toast]);

useEffect(() => {
// Only process slots if timezone is available and not loading
if (selectedDate && consultantDetails && timezone && !isTimezoneLoading) {
console.log("Using timezone:", timezone);
console.log("Selected date:", selectedDate.toISOString());
Expand Down Expand Up @@ -186,6 +187,9 @@ export default function ExpertProfile(

setSlotTimings(sortedSlots);
}
} else {
// Clear slots if timezone is not available
setSlotTimings([]);
}
}, [selectedDate, consultantDetails, timezone, isTimezoneLoading]);

Expand Down

0 comments on commit a652985

Please sign in to comment.