diff --git a/client/src/components/eula/eula.component.jsx b/client/src/components/eula/eula.component.jsx
index 63337d184..3dca72951 100644
--- a/client/src/components/eula/eula.component.jsx
+++ b/client/src/components/eula/eula.component.jsx
@@ -1,58 +1,27 @@
-import React, {useCallback, useEffect, useRef, useState} from "react";
-import {Button, Card, Checkbox, Col, Form, Input, Modal, Row, Space} from "antd";
+import React, { useCallback, useEffect, useRef, useState } from "react";
+import {Button, Card, Checkbox, Col, Form, Input, Modal, notification, Row, Space} from "antd";
import Markdown from "react-markdown";
-import {createStructuredSelector} from "reselect";
-import {selectCurrentEula, selectCurrentUser} from "../../redux/user/user.selectors";
-import {connect} from "react-redux";
-import {FormDatePicker} from "../form-date-picker/form-date-picker.component";
-import {INSERT_EULA_ACCEPTANCE} from "../../graphql/user.queries";
-import {useMutation} from "@apollo/client";
-import {acceptEula} from "../../redux/user/user.actions";
+import { createStructuredSelector } from "reselect";
+import { selectCurrentEula, selectCurrentUser } from "../../redux/user/user.selectors";
+import { connect } from "react-redux";
+import { FormDatePicker } from "../form-date-picker/form-date-picker.component";
+import { INSERT_EULA_ACCEPTANCE } from "../../graphql/user.queries";
+import { useMutation } from "@apollo/client";
+import { acceptEula } from "../../redux/user/user.actions";
+import { useTranslation } from "react-i18next";
+import day from '../../utils/day';
+import './eula.styles.scss';
-const mapStateToProps = createStructuredSelector({
- currentEula: selectCurrentEula,
- currentUser: selectCurrentUser,
-});
-
-
-const mapDispatchToProps = (dispatch) => ({
- acceptEula: () => dispatch(acceptEula()),
-});
-
-export function Eula({currentEula, currentUser, acceptEula}) {
- const [formReady, setFormReady] = useState(false); // [formReady, setFormReady
+const Eula = ({ currentEula, currentUser, acceptEula }) => {
+ const [formReady, setFormReady] = useState(false);
const [hasEverScrolledToBottom, setHasEverScrolledToBottom] = useState(false);
const [insertEulaAcceptance] = useMutation(INSERT_EULA_ACCEPTANCE);
const [form] = Form.useForm();
- const markdownDivRef = useRef(null);
+ const markdownCardRef = useRef(null);
+ const { t } = useTranslation();
+ const [api, contextHolder] = notification.useNotification();
- const handleAccept = async ({acceptTerms, ...formValues}) => {
-
- const eulaId = currentEula.id;
- const useremail = currentUser.email;
-
- try {
- await insertEulaAcceptance({
- variables: {
- eulaAcceptance: {
- eulaid: eulaId,
- useremail,
- ...formValues,
- date_accepted: new Date(),
- }
- }
- });
-
- acceptEula();
- } catch (err) {
- // Pop notification with error, pop console
- console.error(err);
- }
-//R
- // setIsModalOpen(false);
- //Insert and Dispatch the action to recheck force acceptance.
- };
const handleScroll = (e) => {
const bottom = e.target.scrollHeight - 100 <= e.target.scrollTop + e.target.clientHeight;
if (bottom && !hasEverScrolledToBottom) {
@@ -61,135 +30,197 @@ export function Eula({currentEula, currentUser, acceptEula}) {
};
const handleChange = useCallback(() => {
- form.validateFields({
- validateOnly: true,
- }).then(() => {
- setFormReady(hasEverScrolledToBottom);
- }).catch(() => {
- setFormReady(false);
- });
+ form.validateFields({ validateOnly: true })
+ .then(() => setFormReady(hasEverScrolledToBottom))
+ .catch(() => setFormReady(false));
}, [form, hasEverScrolledToBottom]);
-
useEffect(() => {
handleChange();
}, [handleChange, hasEverScrolledToBottom, form]);
+ const onFinish = async ({ acceptTerms, ...formValues }) => {
+ const eulaId = currentEula.id;
+ const useremail = currentUser.email;
- return (
-
- )}
- closable={false}
- >
-
-
-
-
-
-
-
-
-
- {!hasEverScrolledToBottom && (
-
- You must scroll to the bottom of the Terms and Conditions before accepting.
-
- )}
-
-
+ try {
+ const { accepted_terms, ...otherFormValues } = formValues;
+ await insertEulaAcceptance({
+ variables: {
+ eulaAcceptance: {
+ eulaid: eulaId,
+ useremail,
+ ...otherFormValues,
+ date_accepted: new Date(),
+ }
+ }
+ });
+ acceptEula();
+ } catch (err) {
+ api.error({
+ message: t('eula.errors.acceptance.message'),
+ description: t('eula.errors.acceptance.description'),
+ placement: 'bottomRight',
+ duration: 5000,
+
+ });
+ console.log(`${t('eula.errors.acceptance.message')}`);
+ console.dir({
+ message: err.message,
+ stack: err.stack,
+ });
+ }
+ };
+
+ return (
+ <>
+ {contextHolder}
+ (
+
+ )}
+ closable={false}
+ >
+
+
+
+
+
+
+
+ {!hasEverScrolledToBottom && (
+
+ {t('eula.content.never_scrolled')}
+
+ )}
+
+
+ >
+ )
}
+const EulaFormComponent = ({ form, handleChange, onFinish, t }) => (
+
+
+
+);
+
+const mapStateToProps = createStructuredSelector({
+ currentEula: selectCurrentEula,
+ currentUser: selectCurrentUser,
+});
+
+const mapDispatchToProps = (dispatch) => ({
+ acceptEula: () => dispatch(acceptEula()),
+});
+
export default connect(mapStateToProps, mapDispatchToProps)(Eula);
\ No newline at end of file
diff --git a/client/src/components/eula/eula.styles.scss b/client/src/components/eula/eula.styles.scss
new file mode 100644
index 000000000..6e12e7032
--- /dev/null
+++ b/client/src/components/eula/eula.styles.scss
@@ -0,0 +1,21 @@
+.eula-modal {
+ top: 20px;
+}
+
+.eula-markdown-card {
+ max-height: 50vh;
+ overflow-y: auto;
+ background-color: lightgray;
+}
+
+.eula-markdown-div {
+ padding: 0 10px 0 10px;
+}
+
+.eula-never-scrolled {
+ text-align: center;
+}
+
+.eula-accept-button {
+ width: 100%;
+}
\ No newline at end of file
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index 919f7e297..dcddeb7cd 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -933,6 +933,41 @@
"updated": "Document updated successfully. "
}
},
+ "eula": {
+ "titles": {
+ "modal": "Terms and Conditions",
+ "upper_card": "Acknowledgement"
+ },
+ "messages": {
+ "first_name": "Please enter your first name.",
+ "last_name": "Please enter your last name.",
+ "business_name": "Please enter your legal business name.",
+ "phone_number": "Please enter your phone number.",
+ "date_accepted": "Please enter Today's Date.",
+ "accepted_terms": "Please accept the terms and conditions of this agreement."
+ },
+ "buttons": {
+ "accept": "Accept EULA"
+ },
+ "labels": {
+ "first_name": "First Name",
+ "last_name": "Last Name",
+ "business_name": "Legal Business Name",
+ "phone_number": "Phone Number",
+ "address": "Address",
+ "date_accepted": "Date Accepted",
+ "accepted_terms": "I accept the terms and conditions of this agreement."
+ },
+ "content": {
+ "never_scrolled": "You must scroll to the bottom of the Terms and Conditions before accepting."
+ },
+ "errors": {
+ "acceptance": {
+ "message": "Eula Acceptance Error",
+ "description": "Something went wrong while accepting the EULA. Please try again."
+ }
+ }
+ },
"emails": {
"errors": {
"notsent": "Email not sent. Error encountered while sending {{message}}"
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index a798f790c..4fd6a54fa 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -933,6 +933,41 @@
"updated": ""
}
},
+ "eula": {
+ "titles": {
+ "modal": "Terms and Conditions",
+ "upper_card": "Acknowledgement"
+ },
+ "messages": {
+ "first_name": "Please enter your first name.",
+ "last_name": "Please enter your last name.",
+ "business_name": "Please enter your legal business name.",
+ "phone_number": "Please enter your phone number.",
+ "date_accepted": "Please enter Today's Date.",
+ "accepted_terms": "Please accept the terms and conditions of this agreement."
+ },
+ "buttons": {
+ "accept": "Accept EULA"
+ },
+ "labels": {
+ "first_name": "First Name",
+ "last_name": "Last Name",
+ "business_name": "Legal Business Name",
+ "phone_number": "Phone Number",
+ "address": "Address",
+ "date_accepted": "Date Accepted",
+ "accepted_terms": "I accept the terms and conditions of this agreement."
+ },
+ "content": {
+ "never_scrolled": "You must scroll to the bottom of the Terms and Conditions before accepting."
+ },
+ "errors": {
+ "acceptance": {
+ "message": "Eula Acceptance Error",
+ "description": "Something went wrong while accepting the EULA. Please try again."
+ }
+ }
+ },
"emails": {
"errors": {
"notsent": "Correo electrónico no enviado Se encontró un error al enviar {{message}}"
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index b65abaf04..70b09f588 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -933,6 +933,41 @@
"updated": ""
}
},
+ "eula": {
+ "titles": {
+ "modal": "Terms and Conditions",
+ "upper_card": "Acknowledgement"
+ },
+ "messages": {
+ "first_name": "Please enter your first name.",
+ "last_name": "Please enter your last name.",
+ "business_name": "Please enter your legal business name.",
+ "phone_number": "Please enter your phone number.",
+ "date_accepted": "Please enter Today's Date.",
+ "accepted_terms": "Please accept the terms and conditions of this agreement."
+ },
+ "buttons": {
+ "accept": "Accept EULA"
+ },
+ "labels": {
+ "first_name": "First Name",
+ "last_name": "Last Name",
+ "business_name": "Legal Business Name",
+ "phone_number": "Phone Number",
+ "address": "Address",
+ "date_accepted": "Date Accepted",
+ "accepted_terms": "I accept the terms and conditions of this agreement."
+ },
+ "content": {
+ "never_scrolled": "You must scroll to the bottom of the Terms and Conditions before accepting."
+ },
+ "errors": {
+ "acceptance": {
+ "message": "Eula Acceptance Error",
+ "description": "Something went wrong while accepting the EULA. Please try again."
+ }
+ }
+ },
"emails": {
"errors": {
"notsent": "Courriel non envoyé. Erreur rencontrée lors de l'envoi de {{message}}"