feat(home): move manual booking to responsive dialog

- Add Dice UI responsive-dialog component
- Move manual booking form to dialog (drawer on mobile)
- Filter past time slots when booking for today
- Rename button to 'Nueva Reserva'
This commit is contained in:
Jose Selesan
2026-04-10 16:33:45 -03:00
parent 839e316226
commit 8210a4bd9b
12 changed files with 671 additions and 156 deletions

View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import { useIsomorphicLayoutEffect } from '@/hooks/use-isomorphic-layout-effect';
function useAsRef<T>(props: T) {
const ref = React.useRef<T>(props);
useIsomorphicLayoutEffect(() => {
ref.current = props;
});
return ref;
}
export { useAsRef };

View File

@@ -0,0 +1,6 @@
import * as React from 'react';
const useIsomorphicLayoutEffect =
typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
export { useIsomorphicLayoutEffect };

View File

@@ -0,0 +1,13 @@
import * as React from 'react';
function useLazyRef<T>(fn: () => T) {
const ref = React.useRef<T | null>(null);
if (ref.current === null) {
ref.current = fn();
}
return ref as React.RefObject<T>;
}
export { useLazyRef };

View File

@@ -0,0 +1,17 @@
import * as React from 'react';
export function useIsMobile(mobileBreakpoint = 768) {
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${mobileBreakpoint - 1}px)`);
const onChange = () => {
setIsMobile(window.innerWidth < mobileBreakpoint);
};
mql.addEventListener('change', onChange);
setIsMobile(window.innerWidth < mobileBreakpoint);
return () => mql.removeEventListener('change', onChange);
}, [mobileBreakpoint]);
return !!isMobile;
}