Skip to content

Commit

Permalink
fix: incorrect usage of current async function
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Dec 1, 2020
1 parent 3f7bec2 commit 4739d74
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 42 deletions.
4 changes: 2 additions & 2 deletions domains/Auth/PinCode/GetPinCode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Text, Button } from 'react-native-paper';
import { Formik } from 'formik';
import FormInput from '../../../../components/FormikFields/FormInput';
import { storeData, getData, deleteData } from '../../../../modules/async-storage';
import { retrieveSignInFunction, retrieveCurrentUserFunction } from '../../../../services/parse/auth';
import { retrieveSignInFunction, retrieveCurrentUserAsyncFunction } from '../../../../services/parse/auth';
import I18n from '../../../../modules/i18n';

const GetPinCode = ({ navigation }) => {
Expand All @@ -21,7 +21,7 @@ const GetPinCode = ({ navigation }) => {
.then((userCreds) => {
retrieveSignInFunction(userCreds.username, userCreds.password)
.then(() => {
const currentUser = retrieveCurrentUserFunction();
const currentUser = retrieveCurrentUserAsyncFunction();
getData('currentUser').then((user) => {
if (user !== currentUser) {
storeData(currentUser, 'currentUser');
Expand Down
4 changes: 2 additions & 2 deletions domains/Auth/SignIn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ const SignIn = ({ navigation }) => {
const storeUserInformation = async () => {
const currentUser = await retrieveCurrentUserAsyncFunction();
getData('organization').then((asyncOrg) => {
if (asyncOrg !== currentUser.get('organization')) {
storeData(currentUser.get('organization'), 'organization');
if (asyncOrg !== currentUser.organization) {
storeData(currentUser.organization, 'organization');
storeData(currentUser, 'currentUser');
}
});
Expand Down
18 changes: 0 additions & 18 deletions domains/Auth/StoreOrganization/index.js

This file was deleted.

24 changes: 5 additions & 19 deletions domains/DataCollection/Forms/IdentificationForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,21 @@ import {
View, TouchableWithoutFeedback, Keyboard
} from 'react-native';
import { Formik } from 'formik';
// import * as yup from 'yup';

import { postObjectsToClass } from '../../../../services/parse/crud';

import {
storeData
} from '../../../../modules/async-storage';
import { storeData } from '../../../../modules/async-storage';
import checkOnlineStatus from '../../../../modules/offline';
import generateRandomID from '../../../../modules/utils';
import { layout } from '../../../../modules/theme';
import PaperButton from '../../../../components/Button';

import backgroundPostPatient from './utils';
import configArray from './config/config';

import I18n from '../../../../modules/i18n';

import PaperButton from '../../../../components/Button';
import PaperInputPicker from '../../../../components/FormikFields/PaperInputPicker';
import yupValidationPicker from '../../../../components/FormikFields/YupValidation';

// const validationSchema = yup.object().shape({
// fname: yup
// .string()
// .label('First Name')
// .required(),
// lname: yup
// .string()
// .label('Last Name')
// .required()
// });
import backgroundPostPatient from './utils';
import configArray from './config/config';

const IdentificationForm = ({
scrollViewScroll, setScrollViewScroll,
Expand Down
12 changes: 11 additions & 1 deletion services/parse/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ function retrieveCurrentUserFunction() {
}

function retrieveCurrentUserAsyncFunction() {
return Parse.User.currentAsync().then((user) => user);
return Parse.User.currentAsync().then((u) => {
const user = {};
user.id = u.id;
user.username = u.get('username');
user.firstname = u.get('firstname');
user.lastname = u.get('lastname');
user.email = u.get('email');
user.organization = u.get('organization');
user.role = u.get('role');
return user;
});
}

function retrieveDeleteUserFunction(params) {
Expand Down

0 comments on commit 4739d74

Please sign in to comment.