damus.io

damus.io website
git clone git://jb55.com/damus.io
Log | Files | Refs | README | LICENSE

purple-checkout.tsx (1248B)


      1 import Head from "next/head";
      2 import { useIntl } from 'react-intl'
      3 import { Footer } from '@/components/sections/Footer';
      4 import { PurpleCheckout as CheckoutSection } from '@/components/sections/PurpleCheckout';
      5 import { useEffect, useState } from "react";
      6 import { PurpleCheckoutMaintenance } from "../sections/PurpleCheckoutMaintenance";
      7 
      8 
      9 export function PurpleCheckout() {
     10   const intl = useIntl()
     11   const [underMaintenance, setUnderMaintenance] = useState(false);
     12   
     13   // Declare the function to check maintenance status
     14   const checkIfUnderMaintenance = async () => {
     15     const response = await fetch('/purple-checkout-maintenance');
     16     // If response is 200 OK, return true, if 404 Not Found, return false
     17     return response.status === 200;
     18   }
     19   
     20   useEffect(() => {
     21     checkIfUnderMaintenance().then((isUnderMaintenance: boolean) => {
     22       setUnderMaintenance(isUnderMaintenance);
     23     }).catch(error => {
     24       console.error('Failed to check maintenance status:', error);
     25     });
     26   }, []);
     27 
     28   return (<>
     29     <Head>
     30       <title>Damus Purple checkout</title>
     31     </Head>
     32     <main style={{ scrollBehavior: "smooth" }}>
     33       {underMaintenance ? <PurpleCheckoutMaintenance /> : <CheckoutSection />}
     34       <Footer />
     35     </main>
     36   </>)
     37 }