From ec22084ae75454cbfcbac04282a23c0a740bd31f Mon Sep 17 00:00:00 2001 From: Joseph McCombs Date: Wed, 3 Feb 2021 20:33:25 -0500 Subject: [PATCH] feat: autofill for sign up organization --- domains/Auth/SignUp/index.js | 25 ++++++++++++++++--------- modules/cached-resources/read.js | 25 +++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/domains/Auth/SignUp/index.js b/domains/Auth/SignUp/index.js index 1540f19a4..c28a93a88 100644 --- a/domains/Auth/SignUp/index.js +++ b/domains/Auth/SignUp/index.js @@ -21,6 +21,7 @@ import TermsModal from '../../../components/TermsModal'; import { theme } from '../../../modules/theme'; import { populateCache } from '../../../modules/cached-resources'; +import Autofill from '../../../components/FormikFields/PaperInputPicker/AutoFill'; import I18n from '../../../modules/i18n'; @@ -43,7 +44,7 @@ const validationSchema = yup.object().shape({ .min(10, 'Seems a bit short..'), organization: yup .string() - .label('Username') + .label('Organization') .required(), password: yup .string() @@ -61,7 +62,7 @@ const validationSchema = yup.object().shape({ export default function SignUp({ navigation }) { const [checked, setChecked] = React.useState(false); const [visible, setVisible] = React.useState(false); - + const [scrollViewScroll, setScrollViewScroll] = React.useState(); const handleLogIn = () => { navigation.navigate('Sign In'); }; @@ -75,7 +76,10 @@ export default function SignUp({ navigation }) { - + - @@ -170,8 +177,8 @@ export default function SignUp({ navigation }) { {formikProps.isSubmitting ? ( ) : ( - - )} + + )} diff --git a/modules/cached-resources/read.js b/modules/cached-resources/read.js index 734dc8c59..acb1d7cea 100644 --- a/modules/cached-resources/read.js +++ b/modules/cached-resources/read.js @@ -22,8 +22,29 @@ async function cacheAutofillData(parameter) { checkOnlineStatus().then((connected) => { if (connected) { retrievePuenteAutofillData('all').then((result) => { - storeData(result, 'autofill_information'); - resolve(result[parameter]); + // cache organizations tied to all users + customQueryService(0, 500, 'User', 'adminVerified', "true").then((users) => { + const orgsCapitalized = []; + const orgResults = []; + users.forEach((user) => { + console.log(user.get("organization")) + const org = user.get("organization") + if (org !== null && org !== undefined && org !== '') { + const orgCapitalized = org.toUpperCase().trim() || ''; + if (!orgsCapitalized.includes(orgCapitalized) && org !== '') { + orgsCapitalized.push(orgCapitalized); + orgResults.push(org); + } + } + }); + const autofillData = result; + autofillData["organization"] = orgResults; + storeData(autofillData, 'autofill_information') + resolve(autofillData[parameter]); + }, () => { + storeData(result, 'autofill_information'); + resolve(result[parameter]); + }) }, (error) => { reject(error); });