Skip to content

Commit

Permalink
feat: HUGE REFACTOR of imports to consolidate for design system
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Feb 13, 2023
1 parent 07ddcb2 commit c8d9777
Show file tree
Hide file tree
Showing 103 changed files with 4,564 additions and 2,613 deletions.
14 changes: 9 additions & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
],
"parser": "babel-eslint",
"plugins": [
"simple-import-sort"
"simple-import-sort",
"module-resolver"
],
"rules": {
"no-use-before-define": "off",
Expand All @@ -15,10 +16,13 @@
"react/no-access-state-in-setstate": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.js", "**/*.spec.js", "**/__test__/*.js" ]}]



"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.js", "**/*.spec.js", "**/__test__/*.js" ]}],
"module-resolver/use-alias": 2
},
"settings": {
"import/resolver": {
"babel-module": {}
}
},
"env": {
"jest": true,
Expand Down
10 changes: 5 additions & 5 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable-file */
import 'react-native-gesture-handler';

import { UserContextProvider } from '@context/auth.context';
import { OfflineContextProvider } from '@context/offline.context';
import MainNavigation from '@impacto-design-system/MainNavigation';
import useCachedResources from '@modules/cached-resources/useCachedResources';
import { theme } from '@modules/theme';
import { NavigationContainer } from '@react-navigation/native';
import React from 'react';
import { Provider as PaperProvider } from 'react-native-paper';

import MainNavigation from './impacto-design-system/MainNavigation';
import { UserContextProvider } from './context/auth.context';
import { OfflineContextProvider } from './context/offline.context';
import useCachedResources from './modules/cached-resources/useCachedResources';
import { theme } from './modules/theme';
import { initialize } from './services/parse/auth';

initialize();
Expand Down
17 changes: 16 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@ module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
plugins: [
'react-native-reanimated/plugin',
[
'module-resolver',
{
root: ['./'],
alias: {
'@impacto-design-system': './impacto-design-system',
'@modules': './modules',
'@assets': './assets',
'@context': './context',
"@app": "."
},
},
],
],
env: {
production: {
plugins: ['react-native-paper/babel'],
Expand Down
9 changes: 4 additions & 5 deletions context/auth.context.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { createContext, useEffect, useState } from 'react';

import { getData, storeData } from '../modules/async-storage';
import checkOnlineStatus from '../modules/offline';
import {
retrieveCurrentUserAsyncFunction,
retrieveSignInFunction,
retrieveSignOutFunction,
retrieveSignUpFunction
} from '../services/parse/auth/index';
} from '@app/services/parse/auth/index';
import { getData, storeData } from '@modules/async-storage';
import checkOnlineStatus from '@modules/offline';
import React, { createContext, useEffect, useState } from 'react';

export const UserContext = createContext();

Expand Down
4 changes: 2 additions & 2 deletions context/offline.context.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getData, storeData } from '@modules/async-storage';
import { populateCache, residentQuery } from '@modules/cached-resources';
import React, {
createContext, useContext, useState
} from 'react';

import { getData, storeData } from '../modules/async-storage';
import { populateCache, residentQuery } from '../modules/cached-resources';
import { UserContext } from './auth.context';

export const OfflineContext = createContext();
Expand Down
13 changes: 6 additions & 7 deletions domains/Auth/PinCode/GetPinCode/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { retrieveSignInFunction } from '@app/services/parse/auth';
import FormInput from '@impacto-design-system/Extensions/FormikFields/FormInput';
import { deleteData, getData } from '@modules/async-storage';
import { populateCache } from '@modules/cached-resources';
import I18n from '@modules/i18n';
import checkOnlineStatus from '@modules/offline';
import { Formik } from 'formik';
import React, { useState } from 'react';
import { ActivityIndicator } from 'react-native';
import { Button, Text } from 'react-native-paper';

import FormInput from '../../../../impacto-design-system/FormikFields/FormInput';
import { deleteData, getData } from '../../../../modules/async-storage';
import { populateCache } from '../../../../modules/cached-resources';
import I18n from '../../../../modules/i18n';
import checkOnlineStatus from '../../../../modules/offline';
import { retrieveSignInFunction } from '../../../../services/parse/auth';

const GetPinCode = ({ navigation }) => {
const [failedAttempts, setFailedAttempts] = useState(1);

Expand Down
7 changes: 3 additions & 4 deletions domains/Auth/PinCode/StorePinCode/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import FormInput from '@impacto-design-system/Extensions/FormikFields/FormInput';
import { storeData } from '@modules/async-storage';
import I18n from '@modules/i18n';
import { Formik } from 'formik';
import React from 'react';
import { ActivityIndicator } from 'react-native';
import { Button, Text } from 'react-native-paper';

import FormInput from '../../../../impacto-design-system/FormikFields/FormInput';
import { storeData } from '../../../../modules/async-storage';
import I18n from '../../../../modules/i18n';

const StorePinCode = ({ navigation }) => (
<Formik
initialValues={{ pincode: '' }}
Expand Down
9 changes: 4 additions & 5 deletions domains/Auth/SignIn/ForgotPassword/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { retrieveForgotPasswordFunction } from '@app/services/parse/auth';
import FormInput from '@impacto-design-system/Extensions/FormikFields/FormInput';
import I18n from '@modules/i18n';
import { theme } from '@modules/theme';
import { Formik } from 'formik';
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
Expand All @@ -6,11 +10,6 @@ import {
Text
} from 'react-native-paper';

import FormInput from '../../../../impacto-design-system/FormikFields/FormInput';
import I18n from '../../../../modules/i18n';
import { theme } from '../../../../modules/theme';
import { retrieveForgotPasswordFunction } from '../../../../services/parse/auth';

export default function ForgotPassword({ navigation, setForgotPassword }) {
const handleSignUp = () => {
navigation.navigate('Sign Up');
Expand Down
16 changes: 8 additions & 8 deletions domains/Auth/SignIn/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/* eslint no-param-reassign: ["error",
{ "props": true, "ignorePropertyModificationsFor": ["formikProps"] }] */
import BlackLogo from '@app/assets/graphics/static/Logo-Black.svg';
import FormInput from '@impacto-design-system/Extensions/FormikFields/FormInput';
import LanguagePicker from '@impacto-design-system/Extensions/LanguagePicker';
import TermsModal from '@impacto-design-system/Extensions/TermsModal';
import { deleteData, getData } from '@modules/async-storage';
import I18n from '@modules/i18n';
import checkOnlineStatus from '@modules/offline';
import { theme } from '@modules/theme';
import { Formik } from 'formik';
import React, {
useContext,
Expand All @@ -22,15 +30,7 @@ import {
} from 'react-native-paper';
import * as yup from 'yup';

import BlackLogo from '../../../assets/graphics/static/Logo-Black.svg';
import FormInput from '../../../impacto-design-system/FormikFields/FormInput';
import LanguagePicker from '../../../impacto-design-system/LanguagePicker';
import TermsModal from '../../../impacto-design-system/TermsModal';
import { UserContext } from '../../../context/auth.context';
import { deleteData, getData } from '../../../modules/async-storage';
import I18n from '../../../modules/i18n';
import checkOnlineStatus from '../../../modules/offline';
import { theme } from '../../../modules/theme';
import ForgotPassword from './ForgotPassword';

const validationSchema = yup.object().shape({
Expand Down
12 changes: 6 additions & 6 deletions domains/Auth/SignUp/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { Button } from '@impacto-design-system/Base';
import FormInput from '@impacto-design-system/Extensions/FormikFields/FormInput';
import Autofill from '@impacto-design-system/Extensions/FormikFields/PaperInputPicker/AutoFill';
import TermsModal from '@impacto-design-system/Extensions/TermsModal';
import I18n from '@modules/i18n';
import { theme } from '@modules/theme';
import { Formik } from 'formik';
import React, { useContext, useState } from 'react';
import {
Expand All @@ -14,13 +20,7 @@ import {
} from 'react-native-paper';
import * as yup from 'yup';

import Button from '../../../impacto-design-system/Button';
import FormInput from '../../../impacto-design-system/FormikFields/FormInput';
import Autofill from '../../../impacto-design-system/FormikFields/PaperInputPicker/AutoFill';
import TermsModal from '../../../impacto-design-system/TermsModal';
import { UserContext } from '../../../context/auth.context';
import I18n from '../../../modules/i18n';
import { theme } from '../../../modules/theme';

const validationSchema = yup.object().shape({
firstname: yup
Expand Down
5 changes: 2 additions & 3 deletions domains/DataAnalysis/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Header from '@impacto-design-system/Extensions/Header';
import { layout } from '@modules/theme';
import * as React from 'react';
import {
Text, View
} from 'react-native';

import Header from '../../impacto-design-system/Header';
import { layout } from '../../modules/theme';

export default function DataAnalysis() {
return (
<View style={layout.screenContainer}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { Button as PaperButton } from '@impacto-design-system/Base';
import I18n from '@modules/i18n';
import { theme } from '@modules/theme';
import React from 'react';
import {
KeyboardAvoidingView,
Expand All @@ -8,10 +11,6 @@ import {
TextInput
} from 'react-native-paper';

import PaperButton from '../../../../../../impacto-design-system/Button';
import I18n from '../../../../../../modules/i18n';
import { theme } from '../../../../../../modules/theme';

const PeopleModal = ({
people,
handleInputChange, handleAddClick, handleRemoveClick,
Expand Down
18 changes: 8 additions & 10 deletions domains/DataCollection/Assets/NewAssets/AssetCore/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import { cleanLoopSubmissions } from '@app/domains/DataCollection/Forms/SupplementaryForm/utils';
import surveyingUserFailsafe from '@app/domains/DataCollection/Forms/utils';
import { Button as PaperButton, PopupError } from '@impacto-design-system/Base';
import { ErrorPicker, PaperInputPicker } from '@impacto-design-system/Extensions';
import { getData } from '@modules/async-storage';
import { postAssetForm } from '@modules/cached-resources';
import I18n from '@modules/i18n';
import { isEmpty } from '@modules/utils';
import { Formik } from 'formik';
import _ from 'lodash';
import React, { useEffect, useState } from 'react';
Expand All @@ -10,16 +18,6 @@ import {
Provider
} from 'react-native-paper';

import PaperButton from '../../../../../impacto-design-system/Button';
import ErrorPicker from '../../../../../impacto-design-system/FormikFields/ErrorPicker';
import PaperInputPicker from '../../../../../impacto-design-system/FormikFields/PaperInputPicker';
import PopupError from '../../../../../impacto-design-system/PopupError';
import { getData } from '../../../../../modules/async-storage';
import { postAssetForm } from '../../../../../modules/cached-resources';
import I18n from '../../../../../modules/i18n';
import { isEmpty } from '../../../../../modules/utils';
import { cleanLoopSubmissions } from '../../../Forms/SupplementaryForm/utils';
import surveyingUserFailsafe from '../../../Forms/utils';
import configArray from './config/config';
import styles from './index.styles';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { assetFormsQuery } from '@modules/cached-resources';
import I18n from '@modules/i18n';
import { layout, theme } from '@modules/theme';
import React, { useEffect, useState } from 'react';
import { ActivityIndicator, ScrollView, View } from 'react-native';
import { Card, IconButton, Text } from 'react-native-paper';

import { assetFormsQuery } from '../../../../../../modules/cached-resources';
import I18n from '../../../../../../modules/i18n';
import { layout, theme } from '../../../../../../modules/theme';
import styles from './index.style';

const AssetFormSelect = ({ setSelectedForm, surveyingOrganization }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { theme } from '@modules/theme';
import { StyleSheet } from 'react-native';

import { theme } from '../../../../../../modules/theme';

const styles = StyleSheet.create({
cardContainer: {
alignItems: 'center',
Expand Down
24 changes: 11 additions & 13 deletions domains/DataCollection/Assets/NewAssets/AssetSupplementary/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import SelectedAsset from '@app/domains/DataCollection/Assets/ViewAssets/SelectedAsset';
import { addSelectTextInputs, cleanLoopSubmissions } from '@app/domains/DataCollection/Forms/SupplementaryForm/utils';
import surveyingUserFailsafe from '@app/domains/DataCollection/Forms/utils';
import { Button as PaperButton, PopupError } from '@impacto-design-system/Base';
import { AssetSearchbar, PaperInputPicker } from '@impacto-design-system/Extensions';
import { getData } from '@modules/async-storage';
import { postSupplementaryAssetForm } from '@modules/cached-resources';
import { storeAppVersion } from '@modules/cached-resources/populate-cache';
import I18n from '@modules/i18n';
import { theme } from '@modules/theme';
import { isEmpty } from '@modules/utils';
import { Formik } from 'formik';
import React, { useState } from 'react';
import {
ActivityIndicator, Platform, TouchableWithoutFeedback, View
} from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';

import AssetSearchbar from '../../../../../impacto-design-system/AssetSearchBar/index';
import PaperButton from '../../../../../impacto-design-system/Button';
import PaperInputPicker from '../../../../../impacto-design-system/FormikFields/PaperInputPicker';
import PopupError from '../../../../../impacto-design-system/PopupError';
import { getData } from '../../../../../modules/async-storage';
import { postSupplementaryAssetForm } from '../../../../../modules/cached-resources';
import { storeAppVersion } from '../../../../../modules/cached-resources/populate-cache';
import I18n from '../../../../../modules/i18n';
import { theme } from '../../../../../modules/theme';
import { isEmpty } from '../../../../../modules/utils';
import { addSelectTextInputs, cleanLoopSubmissions } from '../../../Forms/SupplementaryForm/utils';
import surveyingUserFailsafe from '../../../Forms/utils';
import SelectedAsset from '../../ViewAssets/SelectedAsset';
import AssetFormSelect from './AssetFormSelect';
import styles from './index.styles';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import I18n from '@modules/i18n';
import { layout } from '@modules/theme';
import React from 'react';
import {
View
Expand All @@ -7,9 +9,6 @@ import {
Text, Title
} from 'react-native-paper';

import I18n from '../../../../../modules/i18n';
import { layout } from '../../../../../modules/theme';

const SelectedAsset = ({ selectedMarker, switchAssetPage }) => (
<TouchableWithoutFeedback
onPress={switchAssetPage ? () => switchAssetPage('assetSupplementary', selectedMarker) : (e) => e}
Expand Down
8 changes: 4 additions & 4 deletions domains/DataCollection/Assets/ViewAssets/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { getData, storeData } from '@modules/async-storage';
import { assetDataQuery } from '@modules/cached-resources/read';
import getLocation from '@modules/geolocation';
import { theme } from '@modules/theme';
import { Spinner } from 'native-base';
import React, { createRef, useEffect, useState } from 'react';
import {
Expand All @@ -6,10 +10,6 @@ import {
import MapView, { Marker } from 'react-native-maps';
import { IconButton } from 'react-native-paper';

import { getData, storeData } from '../../../../modules/async-storage';
import { assetDataQuery } from '../../../../modules/cached-resources/read';
import getLocation from '../../../../modules/geolocation';
import { theme } from '../../../../modules/theme';
import SelectedAsset from './SelectedAsset';

const ViewAssets = ({ organization, switchAssetPage }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import I18n from '@modules/i18n';
import { layout } from '@modules/theme';
import React from 'react';
import {
ScrollView,
Expand All @@ -8,8 +10,6 @@ import {
} from 'react-native-paper';
import uuid from 'react-native-uuid';

import I18n from '../../../../modules/i18n';
import { layout } from '../../../../modules/theme';
import styles from '../index.styles';

const FormsHorizontalView = ({
Expand Down
Loading

0 comments on commit c8d9777

Please sign in to comment.