import { LoadingButton } from "@/components/frontend"; import { GlobalContext } from "@/globalContext"; import { callCustomAPI } from "@/utils/callCustomAPI"; import { Dialog, Transition } from "@headlessui/react"; import { useEffect } from "react"; import { useContext } from "react"; import { useState } from "react"; import { Fragment } from "react"; export default function TermsAndConditionsModal({ isOpen, closeModal, setIsAgreed, }) { const [termsAndConditions, setTermsAndCondition] = useState(""); const [agreed, setAgreed] = useState(false); const { dispatch: globalDispatch } = useContext(GlobalContext); async function fetchTermsAndConditions() { try { const result = await callCustomAPI( "cms", "post", { where: [`content_key = 'terms_and_conditions'`], limit: 1, page: 1 }, "PAGINATE" ); if (Array.isArray(result.list) && result.list.length > 0) { setTermsAndCondition(result.list[0].content_value); } } catch (err) { globalDispatch({ type: "SHOW_ERROR", payload: { heading: "Cannot get Terms and Conditions", message: err.message, }, }); } } useEffect(() => { fetchTermsAndConditions(); }, []); return ( <>