Commit 148ea8e7 authored by Nikolai R Kristiansen's avatar Nikolai R Kristiansen

馃帹 Add prettier and eslint, then format

parent ab77f9de
{
"extends": [
"airbnb-base",
"plugin:prettier/recommended",
"plugin:react/recommended",
"plugin:import/errors",
"plugin:import/warnings",
],
"rules": {
"no-plusplus": 0,
"no-console": 0,
"no-underscore-dangle": 0,
"no-param-reassign": 0,
"react/prefer-stateless-function": 1,
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/sort-comp": 0,
"max-len": 0,
"no-use-before-define": ["error", { "functions": true, "classes": true, "variables": false }] // disable the rule for variables, but enable it for functions and classes
},
"plugins": [
"react",
"prettier"
],
"parser": "babel-eslint",
"settings": {
"react": {
"version": "16.8"
}
}
}
{
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 120,
"arrowParens": "always"
}
......@@ -119,10 +119,13 @@ android {
}
signingConfigs {
release {
storeFile file(DUSKEN_RELEASE_STORE_FILE)
storePassword DUSKEN_RELEASE_STORE_PASSWORD
keyAlias DUSKEN_RELEASE_KEY_ALIAS
keyPassword DUSKEN_RELEASE_KEY_PASSWORD
// These variables are in ~/.gradle/gradle.properties
if (project.hasProperty('DUSKEN_RELEASE_STORE_FILE')) {
storeFile file(DUSKEN_RELEASE_STORE_FILE)
storePassword DUSKEN_RELEASE_STORE_PASSWORD
keyAlias DUSKEN_RELEASE_KEY_ALIAS
keyPassword DUSKEN_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
......
......@@ -6,7 +6,9 @@
"android": "react-native run-android",
"build:android": "cd android && ./gradlew assembleRelease",
"emulator": "emulator -avd $(emulator -list-avds | head)&",
"format": "eslint --fix \"src/**/*.js\"",
"ios": "react-native run-ios",
"lint:format": "eslint --quiet \"src/**/*.js\"",
"release:android": "cd android && bundle exec fastlane beta",
"release:ios": "cd ios && bundle exec fastlane beta",
"start": "node node_modules/react-native/local-cli/cli.js start",
......@@ -44,10 +46,19 @@
"devDependencies": {
"@babel/core": "^7.4.4",
"@babel/runtime": "^7.4.4",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.7.1",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.12.4",
"jest": "^24.7.1",
"jest-fetch-mock": "^1.6.5",
"metro-react-native-babel-preset": "^0.54.0",
"prettier": "^1.17.0",
"react-dom": "16.8.3",
"react-test-renderer": "16.8.3"
}
......
import React, {Component} from 'react';
import {Provider} from 'react-redux';
import {PersistGate} from 'redux-persist/es/integration/react'
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/es/integration/react';
import Config from 'react-native-config';
import {ApolloClient} from 'apollo-client';
import {HttpLink} from 'apollo-link-http';
import {InMemoryCache} from 'apollo-cache-inmemory';
import {ApolloProvider} from "react-apollo";
import Dusken from "./Dusken";
import {store, persistor} from './reduxStore';
import { ApolloClient } from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { ApolloProvider } from 'react-apollo';
import Dusken from './Dusken';
import { store, persistor } from './reduxStore';
const apolloClient = new ApolloClient({
link: new HttpLink({uri: `${Config.DUSKEN_API_URL}/api/graphql/`}),
cache: new InMemoryCache()
link: new HttpLink({ uri: `${Config.DUSKEN_API_URL}/api/graphql/` }),
cache: new InMemoryCache(),
});
export default class App extends Component {
render() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<ApolloProvider client={apolloClient}>
<Dusken />
</ApolloProvider>
</PersistGate>
</Provider>
)
}
render() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<ApolloProvider client={apolloClient}>
<Dusken />
</ApolloProvider>
</PersistGate>
</Provider>
);
}
}
import React, {Component} from 'react';
import {connect} from "react-redux";
import {Root} from 'native-base';
import DuskenNavigation from "./navigation";
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Root } from 'native-base';
import DuskenNavigation from './navigation';
class DuskenContainer extends Component {
render() {
return (<Root>
<DuskenNavigation/>
</Root>)
}
render() {
return (
<Root>
<DuskenNavigation />
</Root>
);
}
}
export default connect()(DuskenContainer);
\ No newline at end of file
export default connect()(DuskenContainer);
......@@ -13,103 +13,116 @@ const MEMBERSHIP_CHARGE_SUCCESS = 'MEMBERSHIP_CHARGE_SUCCESS';
const MEMBERSHIP_CHARGE_FAILURE = 'MEMBERSHIP_CHARGE_FAILURE';
function loginRequest() {
return {
type: LOGIN_REQUEST
}
return {
type: LOGIN_REQUEST,
};
}
function loginSuccess(username, token) {
return {
type: LOGIN_SUCCESS,
username,
token
}
return {
type: LOGIN_SUCCESS,
username,
token,
};
}
function loginFailure(loginError) {
return {
type: LOGIN_FAILURE,
loginError
}
return {
type: LOGIN_FAILURE,
loginError,
};
}
function logout() {
return {
type: LOGOUT
}
return {
type: LOGOUT,
};
}
function userDataRequest() {
return {
type: USER_DATA_REQUEST
}
return {
type: USER_DATA_REQUEST,
};
}
function userDataSuccess(data) {
return {
type: USER_DATA_SUCCESS,
data
}
return {
type: USER_DATA_SUCCESS,
data,
};
}
function userDataFailure(userError) {
return {
type: USER_DATA_FAILURE,
userError
}
return {
type: USER_DATA_FAILURE,
userError,
};
}
function registerUserRequest() {
return {
type: REGISTER_USER_REQUEST
}
return {
type: REGISTER_USER_REQUEST,
};
}
function registerUserSuccess(data) {
return {
type: REGISTER_USER_SUCCESS,
data
}
return {
type: REGISTER_USER_SUCCESS,
data,
};
}
function registerUserFailure(registerError) {
return {
type: REGISTER_USER_FAILURE,
registerError
}
return {
type: REGISTER_USER_FAILURE,
registerError,
};
}
function membershipChargeRequest() {
return {
type: MEMBERSHIP_CHARGE_REQUEST
}
return {
type: MEMBERSHIP_CHARGE_REQUEST,
};
}
function membershipChargeSuccess(data) {
return {
type: MEMBERSHIP_CHARGE_SUCCESS,
data
}
return {
type: MEMBERSHIP_CHARGE_SUCCESS,
data,
};
}
function membershipChargeFailure(chargeError) {
return {
type: MEMBERSHIP_CHARGE_FAILURE,
chargeError
}
return {
type: MEMBERSHIP_CHARGE_FAILURE,
chargeError,
};
}
export {
LOGIN_REQUEST, loginRequest,
LOGIN_SUCCESS, loginSuccess,
LOGIN_FAILURE, loginFailure,
LOGOUT, logout,
USER_DATA_REQUEST, userDataRequest,
USER_DATA_SUCCESS, userDataSuccess,
USER_DATA_FAILURE, userDataFailure,
REGISTER_USER_REQUEST, registerUserRequest,
REGISTER_USER_SUCCESS, registerUserSuccess,
REGISTER_USER_FAILURE, registerUserFailure,
MEMBERSHIP_CHARGE_REQUEST, membershipChargeRequest,
MEMBERSHIP_CHARGE_SUCCESS, membershipChargeSuccess,
MEMBERSHIP_CHARGE_FAILURE, membershipChargeFailure,
};
\ No newline at end of file
LOGIN_REQUEST,
loginRequest,
LOGIN_SUCCESS,
loginSuccess,
LOGIN_FAILURE,
loginFailure,
LOGOUT,
logout,
USER_DATA_REQUEST,
userDataRequest,
USER_DATA_SUCCESS,
userDataSuccess,
USER_DATA_FAILURE,
userDataFailure,
REGISTER_USER_REQUEST,
registerUserRequest,
REGISTER_USER_SUCCESS,
registerUserSuccess,
REGISTER_USER_FAILURE,
registerUserFailure,
MEMBERSHIP_CHARGE_REQUEST,
membershipChargeRequest,
MEMBERSHIP_CHARGE_SUCCESS,
membershipChargeSuccess,
MEMBERSHIP_CHARGE_FAILURE,
membershipChargeFailure,
};
import Config from 'react-native-config';
import {
loginFailure, loginRequest, loginSuccess,
registerUserFailure, registerUserRequest, registerUserSuccess,
userDataFailure, userDataRequest, userDataSuccess,
membershipChargeFailure, membershipChargeRequest, membershipChargeSuccess,
} from "./actions";
import { fetchWithTimeout } from "./utils";
loginFailure,
loginRequest,
loginSuccess,
registerUserFailure,
registerUserRequest,
registerUserSuccess,
userDataFailure,
userDataRequest,
userDataSuccess,
membershipChargeFailure,
membershipChargeRequest,
membershipChargeSuccess,
} from './actions';
import { fetchWithTimeout } from './utils';
export function requestLogin(username, password) {
return (dispatch) => {
// We are now logging in
dispatch(loginRequest());
return (dispatch) => {
// We are now logging in
dispatch(loginRequest());
return fetchWithTimeout(`${Config.DUSKEN_API_URL}/auth/obtain-token/`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'username': username,
'password': password
})
})
.then(response => response.json().then(json => ({ json, response })))
.then(({json, response}) => {
if (response.ok === false) {
return Promise.reject(json)
}
return json
})
.then(
data => {
dispatch(loginSuccess(username, data.token))
},
data => {
console.log(data);
dispatch(loginFailure(data || {'non_field_errors': ['Kunne ikke logge inn, pr酶v igjen']}))
}
)
}
return fetchWithTimeout(`${Config.DUSKEN_API_URL}/auth/obtain-token/`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
username,
password,
}),
})
.then((response) => response.json().then((json) => ({ json, response })))
.then(({ json, response }) => {
if (response.ok === false) {
return Promise.reject(json);
}
return json;
})
.then(
(data) => {
dispatch(loginSuccess(username, data.token));
},
(data) => {
console.log(data);
dispatch(loginFailure(data || { non_field_errors: ['Kunne ikke logge inn, pr酶v igjen'] }));
}
);
};
}
export function requestUserData(auth_token) {
return (dispatch) => {
// We are now fetching user data
dispatch(userDataRequest());
return (dispatch) => {
// We are now fetching user data
dispatch(userDataRequest());
return fetchWithTimeout(`${Config.DUSKEN_API_URL}/api/me/`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Token ${auth_token}`
}
})
.then(response => response.json().then(json => ({ json, response })))
.then(({json, response}) => {
if (response.ok === false) {
return Promise.reject(json)
}
return json
})
.then(
data => {
dispatch(userDataSuccess(data))
},
data => {
dispatch(userDataFailure(data || {'non_field_errors': ['Kunne ikke hente brukerdata']}))
}
)
}
return fetchWithTimeout(`${Config.DUSKEN_API_URL}/api/me/`, {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Token ${auth_token}`,
},
})
.then((response) => response.json().then((json) => ({ json, response })))
.then(({ json, response }) => {
if (response.ok === false) {
return Promise.reject(json);
}
return json;
})
.then(
(data) => {
dispatch(userDataSuccess(data));
},
(data) => {
dispatch(userDataFailure(data || { non_field_errors: ['Kunne ikke hente brukerdata'] }));
}
);
};
}
export function requestRegisterUser(firstName, lastName, email, phoneNumber, password) {
return (dispatch) => {
dispatch(registerUserRequest());
return (dispatch) => {
dispatch(registerUserRequest());
return fetchWithTimeout(`${Config.DUSKEN_API_URL}/api/user/register/`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
'first_name': firstName,
'last_name': lastName,
'email': email,
'phone_number': phoneNumber,
'password': password
})
})
.then(response => response.json().then(json => ({ json, response })))
.then(({json, response}) => {
if (response.ok === false) {
return Promise.reject(json)
}
return json
})
.then(
data => {
dispatch(registerUserSuccess(data))
},
data => {
dispatch(registerUserFailure(data || {'non_field_errors': ['Kunne ikke registrere bruker, pr酶v igjen']}))
}
)
}
return fetchWithTimeout(`${Config.DUSKEN_API_URL}/api/user/register/`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
first_name: firstName,
last_name: lastName,
email,
phone_number: phoneNumber,
password,
}),
})
.then((response) => response.json().then((json) => ({ json, response })))
.then(({ json, response }) => {
if (response.ok === false) {
return Promise.reject(json);
}
return json;
})
.then(
(data) => {
dispatch(registerUserSuccess(data));
},
(data) => {
dispatch(registerUserFailure(data || { non_field_errors: ['Kunne ikke registrere bruker, pr酶v igjen'] }));
}
);
};
}
export function requestMembershipCharge(auth_token, stripe_token, membership_type) {
return (dispatch) => {
dispatch(membershipChargeRequest());
return (dispatch) => {
dispatch(membershipChargeRequest());
return fetchWithTimeout(`${Config.DUSKEN_API_URL}/api/membership/charge/`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Token ${auth_token}`
},
body: JSON.stringify({
'stripe_token': stripe_token,
'membership_type': membership_type,
'payment_method': 'app',
})
})
.then(response => response.json().then(json => ({ json, response })))
.then(({json, response}) => {
if (response.ok === false) {
return Promise.reject(json)
}
return json
})
.then(
data => {
dispatch(membershipChargeSuccess(data))
},
data => {
dispatch(membershipChargeFailure(data['detail'] || 'Kunne ikke belaste bankkortet, pr酶v igjen'))
}
)
}
return fetchWithTimeout(`${Config.DUSKEN_API_URL}/api/membership/charge/`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Token ${auth_token}`,
},
body: JSON.stringify({
stripe_token,
membership_type,
payment_method: 'app',
}),
})
.then((response) => response.json().then((json) => ({ json, response })))
.then(({ json, response }) => {
if (response.ok === false) {
return Promise.reject(json);
}
return json;
})
.then(
(data) => {
dispatch(membershipChargeSuccess(data));
},
(data) => {
dispatch(membershipChargeFailure(data.detail || 'Kunne ikke belaste bankkortet, pr酶v igjen'));
}
);
};
}
This diff is collapsed.
import {connect} from "react-redux";
import React, {Component} from 'react';
import Config from 'react-native-config';
import { connect } from 'react-redux';
import React, { Component } from 'react';
import About from "./About";
import About from './About';
class AboutContainer extends Component {
// constructor(props) {
// super(props);
// this.state = {
// openingHours: '',
// loading: false,
// error: null,
// };
// }
//
// componentDidMount() {
// this.fetchOpeningHours();
// }
//
// fetchOpeningHours() {
// const url = `${Config.EVENT_API_URL}/wp-json/wp/v2/pages/?slug=aapningstider`;
// this.setState({ loading: true });
//
// fetch(url)
// .then(res => res.json())