- Eula Progress

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-01-19 20:55:15 -05:00
parent 06a8d4257a
commit 6937f33134
21 changed files with 235 additions and 83 deletions

16
client/eulaize.js Normal file
View File

@@ -0,0 +1,16 @@
const fs = require('fs');
const filename = process.argv[2];
fs.readFile(filename, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading file ${filename}:`, err);
return;
}
const filteredData = JSON.stringify(data);
console.log('Select the content between the quotes below and paste it into the EULA Content field in the EULA Content table in the database.')
console.log('--------------------------------------------------')
console.log(filteredData);
console.log('--------------------------------------------------')
});

View File

@@ -19449,6 +19449,14 @@
"react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/react-smooth/node_modules/dom-helpers": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz",
"integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==",
"dependencies": {
"@babel/runtime": "^7.1.2"
}
},
"node_modules/react-smooth/node_modules/fast-equals": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.0.1.tgz",
@@ -19457,6 +19465,21 @@
"node": ">=6.0.0"
}
},
"node_modules/react-smooth/node_modules/react-transition-group": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.9.0.tgz",
"integrity": "sha512-+HzNTCHpeQyl4MJ/bdE0u6XRMe9+XG/+aL4mCxVN4DnPBQ0/5bfHWPDuOZUzYdMj94daZaZdCCc1Dzt9R/xSSg==",
"dependencies": {
"dom-helpers": "^3.4.0",
"loose-envify": "^1.4.0",
"prop-types": "^15.6.2",
"react-lifecycles-compat": "^3.0.4"
},
"peerDependencies": {
"react": ">=15.0.0",
"react-dom": ">=15.0.0"
}
},
"node_modules/react-sticky": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/react-sticky/-/react-sticky-6.0.3.tgz",
@@ -19497,29 +19520,6 @@
"resolved": "https://registry.npmjs.org/style-utils/-/style-utils-0.1.24.tgz",
"integrity": "sha512-MVZSKubpU/vIfpmOsi8/0ckWxb0WmGBmyNoEDGWZM9cM8n8sCL6DJftl3lEf8Uy5zKQ9+O1XdJxscWTDosCQpQ=="
},
"node_modules/react-transition-group": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.9.0.tgz",
"integrity": "sha512-+HzNTCHpeQyl4MJ/bdE0u6XRMe9+XG/+aL4mCxVN4DnPBQ0/5bfHWPDuOZUzYdMj94daZaZdCCc1Dzt9R/xSSg==",
"dependencies": {
"dom-helpers": "^3.4.0",
"loose-envify": "^1.4.0",
"prop-types": "^15.6.2",
"react-lifecycles-compat": "^3.0.4"
},
"peerDependencies": {
"react": ">=15.0.0",
"react-dom": ">=15.0.0"
}
},
"node_modules/react-transition-group/node_modules/dom-helpers": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz",
"integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==",
"dependencies": {
"@babel/runtime": "^7.1.2"
}
},
"node_modules/react-virtualized": {
"version": "9.22.5",
"resolved": "https://registry.npmjs.org/react-virtualized/-/react-virtualized-9.22.5.tgz",

View File

@@ -93,6 +93,7 @@
"buildcra": "REACT_APP_GIT_SHA=`git rev-parse --short HEAD` craco build",
"test": "cypress open",
"eject": "react-scripts eject",
"eulaize": "node eulaize.js",
"madge": "madge --image ./madge-graph.svg --extensions js,jsx,ts,tsx --circular ."
},
"eslintConfig": {

View File

@@ -122,7 +122,7 @@ export function App({bodyshop, checkUserSession, currentUser, online, setOnline}
/>
);
if (!currentUser.isEulaAccepted) {
if (!currentUser.eulaIsAccepted) {
return <Eula/>
}

View File

@@ -1,37 +1,89 @@
import React, {useState} from "react";
import React, {useCallback, useEffect, useRef, useState} from "react";
import {Button, Card, Checkbox, Col, Form, Input, Modal, 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";
const EULA = require('./testData.json').eula;
/**
* Returns the EULA component.
* @returns {Element}
* @constructor
*/
const mapStateToProps = createStructuredSelector({
currentEula: selectCurrentEula,
currentUser: selectCurrentUser,
});
//REDUXY THIS
export default function Eula({eulaContentToShow}) {
const [isModalOpen, setIsModalOpen] = useState(true);
const mapDispatchToProps = (dispatch) => ({
acceptEula: () => dispatch(acceptEula()),
});
const handleAccept = (values) => {
localStorage.setItem('termsAccepted', 'true');
setIsModalOpen(false);
export function Eula({currentEula, currentUser, acceptEula}) {
const [formReady, setFormReady] = useState(false); // [formReady, setFormReady
const [hasEverScrolledToBottom, setHasEverScrolledToBottom] = useState(false);
const [insertEulaAcceptance] = useMutation(INSERT_EULA_ACCEPTANCE);
const [form] = Form.useForm();
const markdownDivRef = useRef(null);
//Insert and Dispatch the action to rechecuk force acceptance.
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) {
setHasEverScrolledToBottom(true);
}
};
const handleChange = useCallback(() => {
form.validateFields({
validateOnly: true,
}).then(() => {
setFormReady(hasEverScrolledToBottom);
}).catch(() => {
setFormReady(false);
});
}, [form, hasEverScrolledToBottom]);
useEffect(() => {
handleChange();
}, [handleChange, hasEverScrolledToBottom, form]);
return <Modal
title="Terms and Conditions"
width={'90vh'}
open={isModalOpen}
style={{top: 20}}
width={'100vh'}
open={currentEula}
footer={() => (
<>
<Button form='tosForm' type="primary" htmlType="submit">
Accept
</Button>
</>
<Button style={{width: '100%'}} form='tosForm' type="primary" size='large' htmlType="submit"
disabled={!formReady}>Accept</Button>
)}
closable={false}
>
@@ -40,17 +92,20 @@ export default function Eula({eulaContentToShow}) {
maxHeight: '50vh',
overflowY: 'auto',
backgroundColor: 'lightgray',
padding: '0 25px 0 25px'
}}>
<Markdown children={EULA}/>
}} onScroll={handleScroll} ref={markdownDivRef}>
<div id='markdowndiv' style={{
padding: '0 10px 0 10px'
}}>
<Markdown children={currentEula?.content?.replace(/\\n/g, '\n')}/>
</div>
</Card>
<Card type='inner' title='Acknowledgement'>
<Form id='tosForm' onFinish={handleAccept}>
<Form id='tosForm' onChange={handleChange} onFinish={handleAccept} form={form}>
<Row gutter={24}>
<Col span={12}>
<Form.Item
label="First Name"
name="firstName"
name="first_name"
rules={[{required: true, message: 'Please input your first name!'}]}
>
<Input placeholder="First Name" aria-label="First Name"/>
@@ -59,7 +114,7 @@ export default function Eula({eulaContentToShow}) {
<Col span={12}>
<Form.Item
label="Last Name"
name="lastName"
name="last_name"
rules={[{required: true, message: 'Please input your last name!'}]}
>
<Input placeholder="Last Name" aria-label="Last Name"/>
@@ -70,7 +125,7 @@ export default function Eula({eulaContentToShow}) {
<Col span={12}>
<Form.Item
label="Legal Business Name"
name="businessName"
name="business_name"
rules={[{required: true, message: 'Please input your legal business name!'}]}
>
<Input placeholder="Legal Business Name" aria-label="Legal Business Name"/>
@@ -79,7 +134,13 @@ export default function Eula({eulaContentToShow}) {
<Col span={12}>
<Form.Item
label="Phone"
name="phone"
name="phone_number"
rules={[
{
pattern: /^(\+\d{1,2}\s?)?1?-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/,
message: 'Please enter a valid phone number!'
}
]}
>
<Input placeholder="Phone" aria-label="Phone"/>
</Form.Item>
@@ -97,28 +158,38 @@ export default function Eula({eulaContentToShow}) {
<Col span={12}>
<Form.Item
label="Date"
name="date"
rules={[{required: true, message: 'Please input the date!'}]}
name="date_accepted"
rules={[{required: true},]}
>
<Input type="date" aria-label="Date"/>
<FormDatePicker onChange={handleChange} onlyFuture/>
</Form.Item>
</Col>
</Row>
<Row gutter={24}>
<Col span={24}>
<Form.Item
name="acceptTerms"
valuePropName="checked"
rules={[
{
validator: (_, value) =>
value ? Promise.resolve() : Promise.reject(new Error('You must accept the terms and conditions')),
},
]}
>
<Checkbox aria-label="Accept Terms">I accept the terms and conditions</Checkbox>
</Form.Item>
</Col>
</Row>
<Form.Item
name="acceptTerms"
valuePropName="checked"
rules={[
{
validator: (_, value) =>
value ? Promise.resolve() : Promise.reject(new Error('You must accept the terms and conditions')),
},
]}
>
<Checkbox aria-label="Accept Terms">I accept the terms and conditions</Checkbox>
</Form.Item>
</Form>
</Card>
{!hasEverScrolledToBottom && (
<Card style={{textAlign: 'center'}} type='inner'>
<h3>You must scroll to the bottom of the Terms and Conditions before accepting.</h3>
</Card>
)}
</Space>
</Modal>
}
export default connect(mapStateToProps, mapDispatchToProps)(Eula);

View File

@@ -1,3 +0,0 @@
{
"eula": "# End User License Agreement (EULA)\n## 1. Introduction\n\nThis End User License Agreement (\"EULA\") governs your use of our website and any related services. By using our website, you agree to be bound by the terms of this EULA.\n\n## 2. License Grant\n\nWe grant you a non-exclusive, non-transferable, revocable license to use our website for your personal, non-commercial use.\n\n## 3. Restrictions\n\nYou agree not to:\n\n- Use our website for any illegal or unauthorized purpose\n- Attempt to reverse engineer or otherwise derive the source code of our website\n\n## 4. Termination\n\nWe reserve the right to terminate your license to use our website at any time and for any reason.\n\n## 5. Disclaimer of Warranties\n\nOur website is provided \"as is\" and without any warranty of any kind.\n\n## 6. Limitation of Liability\n\nWe will not be liable for any damages or losses arising from your use of our website.\n\n## 7. Governing Law\n\nThis EULA is governed by the laws of [Your Jurisdiction].\n\n## 8. Changes to this EULA\n\nWe reserve the right to modify this EULA at any time. Your continued use of our website after any such changes constitutes your acceptance of the new EULA.\n\n## 9. Contact Us\n\nIf you have any questions about this EULA, please contact us at [Your Contact Information].\n## 1. Introduction\n\nThis End User License Agreement (\"EULA\") governs your use of our website and any related services. By using our website, you agree to be bound by the terms of this EULA.\n\n## 2. License Grant\n\nWe grant you a non-exclusive, non-transferable, revocable license to use our website for your personal, non-commercial use.\n\n## 3. Restrictions\n\nYou agree not to:\n\n- Use our website for any illegal or unauthorized purpose\n- Attempt to reverse engineer or otherwise derive the source code of our website\n\n## 4. Termination\n\nWe reserve the right to terminate your license to use our website at any time and for any reason.\n\n## 5. Disclaimer of Warranties\n\nOur website is provided \"as is\" and without any warranty of any kind.\n\n## 6. Limitation of Liability\n\nWe will not be liable for any damages or losses arising from your use of our website.\n\n## 7. Governing Law\n\nThis EULA is governed by the laws of [Your Jurisdiction].\n\n## 8. Changes to this EULA\n\nWe reserve the right to modify this EULA at any time. Your continued use of our website after any such changes constitutes your acceptance of the new EULA.\n\n## 9. Contact Us\n\nIf you have any questions about this EULA, please contact us at [Your Contact Information].\n## 1. Introduction\n\nThis End User License Agreement (\"EULA\") governs your use of our website and any related services. By using our website, you agree to be bound by the terms of this EULA.\n\n## 2. License Grant\n\nWe grant you a non-exclusive, non-transferable, revocable license to use our website for your personal, non-commercial use.\n\n## 3. Restrictions\n\nYou agree not to:\n\n- Use our website for any illegal or unauthorized purpose\n- Attempt to reverse engineer or otherwise derive the source code of our website\n\n## 4. Termination\n\nWe reserve the right to terminate your license to use our website at any time and for any reason.\n\n## 5. Disclaimer of Warranties\n\nOur website is provided \"as is\" and without any warranty of any kind.\n\n## 6. Limitation of Liability\n\nWe will not be liable for any damages or losses arising from your use of our website.\n\n## 7. Governing Law\n\nThis EULA is governed by the laws of [Your Jurisdiction].\n\n## 8. Changes to this EULA\n\nWe reserve the right to modify this EULA at any time. Your continued use of our website after any such changes constitutes your acceptance of the new EULA.\n\n## 9. Contact Us\n\nIf you have any questions about this EULA, please contact us at [Your Contact Information]."
}

View File

@@ -31,6 +31,14 @@ export const UPDATE_ASSOCIATION = gql`
}
`;
export const INSERT_EULA_ACCEPTANCE = gql`
mutation INSERT_EULA_ACCEPTANCE($eulaAcceptance:eula_acceptances_insert_input!) {
insert_eula_acceptances_one(object: $eulaAcceptance){
id
}
}
`;
export const UPSERT_USER = gql`
mutation UPSERT_USER($authEmail: String!, $authToken: String!) {
insert_users(

View File

@@ -110,8 +110,12 @@ export const setAuthlevel = (authlevel) => ({
payload: authlevel,
});
export const setEulaContentToShow = (eulaContent) => ({
type: UserActionTypes.SET_EULA_CONTENT,
payload: eulaContent,
export const setCurrentEula = (eula) => ({
type: UserActionTypes.SET_CURRENT_EULA,
payload: eula,
});
export const acceptEula = () => ({
type: UserActionTypes.EULA_ACCEPTED,
});

View File

@@ -18,7 +18,7 @@ const INITIAL_STATE = {
loading: false,
},
authLevel: 0,
eulaContentToShow:null
currentEula: null,
};
const userReducer = (state = INITIAL_STATE, action) => {
@@ -65,11 +65,19 @@ const userReducer = (state = INITIAL_STATE, action) => {
loading: false,
},
};
case UserActionTypes.EULA_ACCEPTED:
return {
...state,
currentUser:{...state.currentUser, eulaIsAccepted: true},
currentEula: null,
};
case UserActionTypes.SIGN_IN_SUCCESS:
const{ currentEula,...currentUser} = action.payload
return {
...state,
loginLoading: false,
currentUser: action.payload,
currentUser: currentUser,
currentEula,
error: null,
};
case UserActionTypes.SIGN_OUT_SUCCESS:

View File

@@ -97,7 +97,7 @@ export function* isUserAuthenticated() {
},
});
const isEulaAccepted = eulaQuery.data.eulas.length > 0 && eulaQuery.data.eulas[0].eula_acceptances.length > 0;
const eulaIsAccepted = eulaQuery.data.eulas.length > 0 && eulaQuery.data.eulas[0].eula_acceptances.length > 0;
yield put(
signInSuccess({
@@ -106,7 +106,8 @@ export function* isUserAuthenticated() {
displayName: user.displayName,
photoURL: user.photoURL,
authorized: true,
isEulaAccepted,
eulaIsAccepted,
currentEula: eulaIsAccepted ? null : eulaQuery.data.eulas[0],
})
);
} catch (error) {

View File

@@ -37,7 +37,7 @@ export const selectLoginLoading = createSelector(
(user) => user.loginLoading
);
export const selectEulaContentToShow = createSelector(
export const selectCurrentEula = createSelector(
[selectUser],
(user) => user.eulaContentToShow
(user) => user.currentEula
);

View File

@@ -32,6 +32,7 @@ const UserActionTypes = {
CHECK_ACTION_CODE_START: "CHECK_ACTION_CODE_START",
CHECK_ACTION_CODE_SUCCESS: "CHECK_ACTION_CODE_SUCCESS",
CHECK_ACTION_CODE_FAILURE: "CHECK_ACTION_CODE_FAILURE",
SET_EULA_CONTENT: "SET_EULA_CONTENT"
SET_CURRENT_EULA: "SET_CURRENT_EULA",
EULA_ACCEPTED : "EULA_ACCEPTED",
};
export default UserActionTypes;

31
client/test.md Normal file
View File

@@ -0,0 +1,31 @@
# End User License Agreement (EULA)
## 1. Introduction
This End User License Agreement ("EULA") is a legal agreement between you and [Your Company Name] ("Company"). This EULA governs your acquisition and use of our [Software Name] ("Software") directly from [Your Company Name] or indirectly through a [Your Company Name] authorized reseller or distributor.
By installing and/or using the [Software Name], you are confirming your acceptance of the Software and agreeing to become bound by the terms of this EULA agreement.
## 2. License
[Your Company Name] hereby grants you a personal, non-transferable, non-exclusive licence to use the [Software Name] on your devices in accordance with the terms of this EULA agreement.
## 3. Restrictions
You are not permitted to:
- Edit, alter, modify, adapt, translate or otherwise change the whole or any part of the Software nor permit the whole or any part of the Software to be combined with or become incorporated in any other software, nor decompile, disassemble or reverse engineer the Software or attempt to do any such things.
- Reproduce, copy, distribute, resell or otherwise use the Software for any commercial purpose.
- Allow any third party to use the Software on behalf of or for the benefit of any third party.
- Use the Software in any way which breaches any applicable local, national or international law.
## 4. Termination
This EULA agreement is effective from the date you first use the Software and shall continue until terminated. You may terminate it at any time upon written notice to [Your Company Name].
## 5. Governing Law
This EULA agreement, and any dispute arising out of or in connection with this EULA agreement, shall be governed by and construed in accordance with the laws of [Your Country].

View File

@@ -1,3 +1,6 @@
- function:
name: jobs_ar_summary
schema: public
- function:
name: search_bills
schema: public

View File

@@ -2442,7 +2442,7 @@
_eq: X-Hasura-User-Id
columns:
- address
- buisness_name
- business_name
- date_accepted
- eulaid
- first_name
@@ -2454,7 +2454,7 @@
permission:
columns:
- address
- buisness_name
- business_name
- first_name
- last_name
- phone_number
@@ -2673,6 +2673,9 @@
- table:
name: ioevents
schema: public
- table:
name: job_ar_schema
schema: public
- table:
name: job_conversations
schema: public
@@ -3812,6 +3815,7 @@
- referral_source
- referral_source_extra
- regie_number
- remove_from_ar
- ro_number
- scheduled_completion
- scheduled_delivery
@@ -4093,6 +4097,7 @@
- referral_source
- referral_source_extra
- regie_number
- remove_from_ar
- ro_number
- scheduled_completion
- scheduled_delivery

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" rename column "business_name" to "buisness_name";

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" rename column "buisness_name" to "business_name";

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" alter column "phone_number" set not null;

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" alter column "phone_number" drop not null;

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" alter column "address" set not null;

View File

@@ -0,0 +1 @@
alter table "public"."eula_acceptances" alter column "address" drop not null;