From a3755d4ee77cedbeda40046aaa207d5371bf4a33 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Sat, 23 Jun 2018 13:30:04 -0600 Subject: [PATCH] Create separate preferences localStorage item; remove username --- src/Constants.js | 3 + src/components/MainDisplay.jsx | 6 +- .../management/AccountManager/LoginForm.jsx | 84 ++++++++++--------- .../management/AccountManager/MyAccount.jsx | 78 +++++++++++++++-- .../management/AccountManager/index.jsx | 3 +- src/components/management/IPAField.jsx | 19 +++-- src/index.jsx | 6 +- 7 files changed, 137 insertions(+), 62 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index 7b04f40..00331d9 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -5,6 +5,9 @@ export const DEFAULT_USER_DATA = { username: '', publicName: '', allowEmails: true, +}; + +export const DEFAULT_PREFERENCES = { useIPAPronunciation: true, itemsPerPage: 30, }; diff --git a/src/components/MainDisplay.jsx b/src/components/MainDisplay.jsx index 3c61c9f..5cf4ea2 100644 --- a/src/components/MainDisplay.jsx +++ b/src/components/MainDisplay.jsx @@ -10,7 +10,7 @@ import { Pagination } from './structure/Pagination'; import { WordForm } from './management/WordForm'; import { DictionaryDetails } from './display/DictionaryDetails'; import { WordsList } from './display/WordsList'; -import { DEFAULT_USER_DATA } from '../Constants'; +import { DEFAULT_PREFERENCES } from '../Constants'; export class MainDisplay extends Component { constructor (props) { @@ -56,8 +56,8 @@ export class MainDisplay extends Component { } render () { - const userData = store.get('LexicongaUserData'); - const itemsPerPage = userData && userData.hasOwnProperty('itemsPerPage') ? userData.itemsPerPage : DEFAULT_USER_DATA.itemsPerPage; + const preferences = store.get('LexicongaPreferences'); + const itemsPerPage = preferences && preferences.hasOwnProperty('itemsPerPage') ? preferences.itemsPerPage : DEFAULT_PREFERENCES.itemsPerPage; const { dictionaryInfo, isLoadingWords, diff --git a/src/components/management/AccountManager/LoginForm.jsx b/src/components/management/AccountManager/LoginForm.jsx index 64b4afb..0263a32 100644 --- a/src/components/management/AccountManager/LoginForm.jsx +++ b/src/components/management/AccountManager/LoginForm.jsx @@ -26,19 +26,19 @@ export class LoginForm extends Component { loginPasswordError: '', loginFormIsValid: true, signupEmail: '', - signupUsername: '', + // signupUsername: '', signupPublicName: '', signupPassword: '', signupConfirm: '', signupAllowEmail: true, signupEmailError: '', - signupUsernameError: '', + // signupUsernameError: '', signupPasswordError: '', signupConfirmError: '', signupEmailChecking: false, - signupUsernameChecking: false, + // signupUsernameChecking: false, signupEmailIsUnique: true, - signupUsernameIsUnique: true, + // signupUsernameIsUnique: true, signupFormIsValid: true, }; } @@ -56,15 +56,15 @@ export class LoginForm extends Component { signupEmailError, signupEmailChecking, signupEmailIsUnique, - signupUsernameError, - signupUsernameChecking, - signupUsernameIsUnique, + // signupUsernameError, + // signupUsernameChecking, + // signupUsernameIsUnique, signupPasswordError, signupConfirmError, } = this.state; return !signupEmailChecking && !signupUsernameChecking - && signupEmailIsUnique && signupUsernameIsUnique - && signupEmailError === '' && signupUsernameError === '' + && signupEmailIsUnique && signupEmailError === '' + // && signupUsernameIsUnique && signupUsernameError === '' && signupPasswordError === '' && signupConfirmError === ''; } @@ -101,12 +101,12 @@ export class LoginForm extends Component { } } - if (field === 'signupUsername') { - if (value !== '' && /[^a-zA-Z0-9]+/g.test(value)) { - isValid = false; - fieldErrors[errorFieldName] = 'Please use only letters and numbers'; - } - } + // if (field === 'signupUsername') { + // if (value !== '' && /[^a-zA-Z0-9]+/g.test(value)) { + // isValid = false; + // fieldErrors[errorFieldName] = 'Please use only letters and numbers'; + // } + // } if (isValid) { fieldErrors[errorFieldName] = ''; @@ -118,17 +118,22 @@ export class LoginForm extends Component { const { signupEmailChecking, signupEmailIsUnique, - signupUsernameChecking, - signupUsernameIsUnique, + // signupUsernameChecking, + // signupUsernameIsUnique, } = this.state; - const fields = ['signupEmail', 'signupUsername', 'signupPassword', 'signupConfirm']; + const fields = [ + 'signupEmail', + // 'signupUsername', + 'signupPassword', + 'signupConfirm' + ]; let errors = {}; fields.forEach(field => { const fieldErrors = this.validateField(field, this.state[field]); errors = Object.assign(errors, fieldErrors); }); - errors.signupFormIsValid = !signupEmailChecking && !signupUsernameChecking - && signupEmailIsUnique && signupUsernameIsUnique + errors.signupFormIsValid = !signupEmailChecking && signupEmailIsUnique + // && !signupUsernameChecking && signupUsernameIsUnique && Object.keys(errors).every(field => errors[field] === ''); this.setState(errors, callback); } @@ -163,21 +168,22 @@ export class LoginForm extends Component { this.setState(fieldUpdate); }); }); - } else if (field === 'signupUsername') { - this.setState({ signupUsernameChecking: true }, () => { - request('check-username', { username: value }, (response) => { - const { data, error } = response; - fieldUpdate['signupUsernameChecking'] = false; - if (error) { - console.error(data); - } else { - fieldUpdate['signupUsernameIsUnique'] = !data; - } - }).then(() => { - this.setState(fieldUpdate); - }); - }); } + // else if (field === 'signupUsername') { + // this.setState({ signupUsernameChecking: true }, () => { + // request('check-username', { username: value }, (response) => { + // const { data, error } = response; + // fieldUpdate['signupUsernameChecking'] = false; + // if (error) { + // console.error(data); + // } else { + // fieldUpdate['signupUsernameIsUnique'] = !data; + // } + // }).then(() => { + // this.setState(fieldUpdate); + // }); + // }); + // } } logIn () { @@ -194,13 +200,13 @@ export class LoginForm extends Component { if (this.signupFormIsValid) { const { signupEmail, - signupUsername, + // signupUsername, signupPublicName, signupPassword, signupAllowEmail } = this.state; this.props.signUp(signupEmail, signupPassword, { - username: signupUsername, + // username: signupUsername, publicName: signupPublicName, allowEmail: signupAllowEmail, }); @@ -234,7 +240,7 @@ export class LoginForm extends Component {
-
+ {/*
@@ -342,7 +348,7 @@ export class LoginForm extends Component { ) : null }
-
+
*/}
+ +
+ +
+ Click the button below to reload the page and show the Reset Password form. Filling out this + form will instantly change your password, and you will need to log in using the new password + from that point forward. +
+
+ Reset Password +
+
+ +
+

Request Your Data

+

+ Per your GDPR rights in Articles 13–15 and 20, + we allow you to request any and all data we have stored about you. The only data we have about + you personally is your email address and your Public Name, if you decided to set one. All other + data (your Dictionary data) is visible and accessible via the Export button under your Dictionary's + Settings. Send an email to help@lexicon.ga to request your information. +

+
+ +
+

Delete Your Account

+

+ Per your GDPR rights in Article 17, if you wish + for your account to be deleted, please contact us at help@lexicon.ga, and we will delete your account + and all associated dictionaries and words as quickly as possible. Note that you can delete dictionaries + yourself via your Dictionary's Settings. +

+

+ Anything that is deleted from our system is permanently and irretrievably removed from our system and + cannot be restored, though search engines or internet archives may retain a cached version of your content + (there is nothing we can do about this, and you will need to seek out removal of that information by directly + contacting the services that are caching your data). +

+
diff --git a/src/components/management/AccountManager/index.jsx b/src/components/management/AccountManager/index.jsx index d9963aa..075efb7 100644 --- a/src/components/management/AccountManager/index.jsx +++ b/src/components/management/AccountManager/index.jsx @@ -28,7 +28,6 @@ export class AccountManager extends Component { username: userData && userData.hasOwnProperty('username') ? userData.username : DEFAULT_USER_DATA.username, publicName: userData && userData.hasOwnProperty('publicName') ? userData.publicName : DEFAULT_USER_DATA.publicName, allowEmails: userData && userData.hasOwnProperty('allowEmails') ? userData.allowEmails : DEFAULT_USER_DATA.allowEmails, - itemsPerPage: userData && userData.hasOwnProperty('itemsPerPage') ? userData.itemsPerPage : DEFAULT_USER_DATA.itemsPerPage, }, userDictionaries: [], }; @@ -119,7 +118,7 @@ export class AccountManager extends Component { { - store.set('LexicongaUserData', userData); + let preferences = store.get('LexicongaPreferences'); + if (!preferences) { + preferences = Object.assign({}, DEFAULT_PREFERENCES); + } + preferences.useIPAPronunciation = !this.useIPA; + this.setState({ useIPA: preferences.useIPAPronunciation }, () => { + store.set('LexicongaPreferences', preferences); }); } diff --git a/src/index.jsx b/src/index.jsx index 685277b..3a0b368 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -6,7 +6,7 @@ import { Component, render } from 'inferno'; import store from 'store'; import removeDiacritics from '../vendor/StackOverflow/removeDiacritics'; -import { DEFAULT_USER_DATA } from './Constants'; +import { DEFAULT_PREFERENCES } from './Constants'; import { addHelpfulPrototypes, getWordsStats } from './Helpers'; addHelpfulPrototypes(); @@ -95,8 +95,8 @@ class App extends Component { updateDisplayedWords (callback = () => {}) { dictionary.wordsPromise.then(words => { - const userData = store.get('LexicongaUserData'); - const itemsPerPage = userData && userData.hasOwnProperty('itemsPerPage') ? userData.itemsPerPage : DEFAULT_USER_DATA.itemsPerPage; + const preferences = store.get('LexicongaPreferences'); + const itemsPerPage = preferences && preferences.hasOwnProperty('itemsPerPage') ? preferences.itemsPerPage : DEFAULT_PREFERENCES.itemsPerPage; const { searchConfig, partsOfSpeech, currentPage } = this.state; const partsOfSpeechForFilter = [...partsOfSpeech, 'Uncategorized']; const pageStart = currentPage * itemsPerPage;