import { Form, Formik } from 'formik';
import React from 'react';
import { Card, CardContent, Divider } from '@mui/material';
import { axiosInstance } from '../../../axiosApi';
import { useNavigate } from 'react-router-dom';
import MDTypography from '../../ui-kit/components/MDTypography';
import PageWrapperLayout from '../../components/PageWrapperLayout/PageWrapperLayout';
import MDBox from '../../ui-kit/components/MDBox';
import MDButton from '../../ui-kit/components/MDButton';

const TermsOfService = (): JSX.Element => {
    const navigate = useNavigate();    
    
    const handleAcknowledge = async (): Promise<void> => {
        
        try{
            await axiosInstance.post('/user/acknowledge_tos/')
            navigate('/')            

        }catch(error){ 
            console.log(error)
        }
    }

    


  return (
    <PageWrapperLayout>
        <MDBox sx={{ margin: '0 auto', width: '80%', height: '80%', minHeight: '80%', maxHeight: '80%', align:'center'}}>
        <Card>
            <CardContent>
                <MDTypography variant="h3">
                    Terms of service
                </MDTypography>
            </CardContent>
            <Divider />
            <MDTypography>
            Welcome to Hesychia (hesychia.ai)! We're excited to have you on board. Before you start using our large language model, supplied by AI ML Operations, LLC, we need you to agree to our Terms of Service.
            </MDTypography>
            <MDTypography variant="h4">
                1. Acceptance of Terms
            </MDTypography>
            <MDTypography>By logging in, you acknowledge that you have read, understood, and agree to be bound by these Terms of Service. If you don't agree, please don't use our services.</MDTypography>
            <MDTypography variant="h4">2. Data Confidentiality</MDTypography>
            <MDTypography>We respect your data. All information entered by you will be contained within your organization and will not be sold, shared, or disclosed to any third parties without your explicit consent.</MDTypography>
            <MDTypography variant="h4">3. Use of Services</MDTypography>
            <MDTypography>You agree to use our large language model for legitimate purposes only. You're responsible for ensuring that your use of our services complies with all applicable laws and regulations.</MDTypography>
            <MDTypography variant="h4">4. Intellectual Property</MDTypography>
            <MDTypography>All intellectual property rights in our services, including the large language model, remain the property of AI ML Operations, LLC. Any information generated by our service is for your use and AI ML Operations, LLC makes no claim to it.</MDTypography>
            <MDTypography variant="h4">5. Limitation of Liability</MDTypography>
            <MDTypography>In no event will we be liable for any damages, including consequential, incidental, or punitive damages, arising from your use of our services.</MDTypography>
            <MDTypography variant="h4">6. Changes to Terms</MDTypography>
            <MDTypography>We may update these Terms of Service from time to time. We'll notify you of significant changes, and your continued use of our services will constitute acceptance of the updated terms.</MDTypography>
            <MDTypography variant="h4">7. Governing Law</MDTypography>
            <MDTypography>These Terms of Service will be governed by and construed in accordance with the laws of the United States and the state of Illinois.</MDTypography>
            <MDTypography>By logging in, you acknowledge that you have read and agree to these Terms of Service. If you have any questions, please don't hesitate to contact us.</MDTypography>
            Happy using our services!
            <Divider />
            <Formik
                initialValues={{
                    email: '',
                    password: '',
                }}
                onSubmit={handleAcknowledge}
                >
                    {(formik) => (
                        <Form>
                             <MDButton
                            type={'submit'}
                            disabled={ formik.isSubmitting}
                            
                            loading={formik.isSubmitting}
                            //   disabled={
                            //     !formik.isValid || !formik.dirty || formik.isSubmitting
                            // }
                            >
                            Acknowledge
                            </MDButton>

                        </Form>
                    )}

            </Formik>

        </Card>
        </MDBox>
    </PageWrapperLayout>
  );
};

export default TermsOfService;
