You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.7 KiB

  1. "use client";
  2. import React, { FC, Fragment, useState } from "react";
  3. import { Dialog, Transition } from "@headlessui/react";
  4. import { XMarkIcon } from "@heroicons/react/24/solid";
  5. import ButtonPrimary from "@/shared/ButtonPrimary";
  6. import GuestsInput from "@/app/(client-components)/(HeroSearchForm2Mobile)/GuestsInput";
  7. interface ModalSelectGuestsProps {
  8. renderChildren?: (p: { openModal: () => void }) => React.ReactNode;
  9. }
  10. const ModalSelectGuests: FC<ModalSelectGuestsProps> = ({ renderChildren }) => {
  11. const [showModal, setShowModal] = useState(false);
  12. // FOR RESET ALL DATA WHEN CLICK CLEAR BUTTON
  13. //
  14. function closeModal() {
  15. setShowModal(false);
  16. }
  17. function openModal() {
  18. setShowModal(true);
  19. }
  20. const renderButtonOpenModal = () => {
  21. return renderChildren ? (
  22. renderChildren({ openModal })
  23. ) : (
  24. <button onClick={openModal}>Select Date</button>
  25. );
  26. };
  27. return (
  28. <>
  29. {renderButtonOpenModal()}
  30. <Transition appear show={showModal} as={Fragment}>
  31. <Dialog
  32. as="div"
  33. className="HeroSearchFormMobile__Dialog relative z-50"
  34. onClose={closeModal}
  35. >
  36. <div className="fixed inset-0 bg-neutral-100 dark:bg-neutral-900">
  37. <div className="flex h-full">
  38. <Transition.Child
  39. as={Fragment}
  40. enter="ease-out transition-transform"
  41. enterFrom="opacity-0 translate-y-52"
  42. enterTo="opacity-100 translate-y-0"
  43. leave="ease-in transition-transform"
  44. leaveFrom="opacity-100 translate-y-0"
  45. leaveTo="opacity-0 translate-y-52"
  46. >
  47. <Dialog.Panel className="relative h-full overflow-hidden flex-1 flex flex-col justify-between ">
  48. <>
  49. <div className="absolute left-4 top-4">
  50. <button
  51. className="focus:outline-none focus:ring-0"
  52. onClick={closeModal}
  53. >
  54. <XMarkIcon className="w-5 h-5 text-black dark:text-white" />
  55. </button>
  56. </div>
  57. <div className="flex-1 pt-12 p-1 flex flex-col overflow-hidden">
  58. <div className="flex-1 flex flex-col overflow-hidden bg-white dark:bg-neutral-800">
  59. <div className="flex-1 flex flex-col transition-opacity animate-[myblur_0.4s_ease-in-out] overflow-auto">
  60. <div
  61. className={`flex-1 relative flex z-10 overflow-hidden`}
  62. >
  63. <GuestsInput />
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. <div className="px-4 py-3 bg-white dark:bg-neutral-900 border-t border-neutral-200 dark:border-neutral-700 flex justify-between">
  69. <button
  70. type="button"
  71. className="underline font-semibold flex-shrink-0"
  72. onClick={() => {}}
  73. >
  74. Clear data
  75. </button>
  76. <ButtonPrimary
  77. sizeClass="px-6 py-3 !rounded-xl"
  78. onClick={() => {
  79. closeModal();
  80. }}
  81. >
  82. Save
  83. </ButtonPrimary>
  84. </div>
  85. </>
  86. </Dialog.Panel>
  87. </Transition.Child>
  88. </div>
  89. </div>
  90. </Dialog>
  91. </Transition>
  92. </>
  93. );
  94. };
  95. export default ModalSelectGuests;