import { useCallback, useState } from 'react';
export function useFullScreenDrawer({
  isShow = false,
  onDismissCallback = () => {},
  shouldShowCloseWarning
} = {
  isShow: false,
  onDismissCallback: () => {},
  shouldShowCloseWarning: false
}) {
  const [show, setShow] = useState(isShow);
  const [showCloseWarning, setShowCloseWarning] = useState(false);
  const onDismiss = useCallback(() => {
    // if consumer's requirements to show warning is true and warning is not shown yet - then show warning instead of closing
    // if warning was already shown - then proceed closing
    if (shouldShowCloseWarning && !showCloseWarning) {
      setShowCloseWarning(true);
    } else {
      onDismissCallback();
      setShowCloseWarning(false);
      setShow(false);
    }
  }, [onDismissCallback, shouldShowCloseWarning, showCloseWarning]);
  return {
    show,
    setShow,
    onDismiss,
    showCloseWarning,
    setShowCloseWarning
  };
}