Skip to content

Commit

Permalink
Merge pull request #29 from Cezerin2/dev
Browse files Browse the repository at this point in the history
lint and prettier
  • Loading branch information
ngoyal16 authored Jun 16, 2019
2 parents 49895b6 + 54bca72 commit 56d3d52
Show file tree
Hide file tree
Showing 228 changed files with 3,240 additions and 3,753 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 1 addition & 1 deletion config/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
// dashboard UI language
language: process.env.LANGUAGE || 'en',
apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:3001/api/v1',
assetsBaseURL: process.env.ASSETS_BASE_URL || 'http://localhost:3001',
assetsBaseURL: process.env.ASSETS_BASE_URL || 'http://localhost:3001',
apiWebSocketUrl: process.env.API_WEB_SOCKET_URL || 'ws://localhost:3001',
developerMode: process.env.DEVELOPER_MODE || true
};
2 changes: 1 addition & 1 deletion public/data/countries.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var APPLICATION_DATA_COUNTRIES = {
const APPLICATION_DATA_COUNTRIES = {
AF: 'Afghanistan',
AX: '\u00c5land Islands',
AL: 'Albania',
Expand Down
2 changes: 1 addition & 1 deletion public/data/currencies.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var APPLICATION_DATA_CURRENCIES = {
const APPLICATION_DATA_CURRENCIES = {
AED: 'United Arab Emirates Dirham',
AFN: 'Afghan Afghani',
ALL: 'Albanian Lek',
Expand Down
2 changes: 1 addition & 1 deletion public/data/timezones.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var APPLICATION_DATA_TIMEZONES = {
const APPLICATION_DATA_TIMEZONES = {
'Africa/Abidjan': { utc: '+0000', utc_dst: '+0000', utc_v: 0, utc_dst_v: 0 },
'Africa/Accra': { utc: '+0000', utc_dst: '+0000', utc_v: 0, utc_dst_v: 0 },
'Africa/Addis_Ababa': {
Expand Down
10 changes: 5 additions & 5 deletions src/apps/facebook-customer-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export class App extends React.Component {
: '';

api.apps.settings.update('facebook-customer-chat', {
pageId: pageId,
minimized: minimized
pageId,
minimized
});
api.theme.placeholders.update('facebook-customer-chat', {
place: 'body_end',
Expand All @@ -85,15 +85,15 @@ export class App extends React.Component {
<div>
<TextField
type="text"
fullWidth={true}
fullWidth
value={this.state.pageId}
onChange={this.handlePageIdChange}
floatingLabelText="Page ID"
/>

<TextField
type="text"
fullWidth={true}
fullWidth
value={this.state.minimized}
onChange={this.handleMinimizedChange}
floatingLabelText="minimized"
Expand All @@ -103,7 +103,7 @@ export class App extends React.Component {
<div style={{ textAlign: 'right' }}>
<RaisedButton
label={messages.save}
primary={true}
primary
disabled={false}
onClick={this.updateSettings}
/>
Expand Down
8 changes: 4 additions & 4 deletions src/apps/facebook-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class App extends React.Component {
)
: '';

api.apps.settings.update('facebook-sdk', { appId: appId, locale: locale });
api.apps.settings.update('facebook-sdk', { appId, locale });
api.theme.placeholders.update('facebook-sdk', {
place: 'body_start',
value: htmlCode
Expand All @@ -100,15 +100,15 @@ export class App extends React.Component {

<TextField
type="text"
fullWidth={true}
fullWidth
value={this.state.appId}
onChange={this.handleAppIdChange}
floatingLabelText="App ID"
/>

<TextField
type="text"
fullWidth={true}
fullWidth
value={this.state.locale}
onChange={this.handleLocaleChange}
floatingLabelText="Locale"
Expand All @@ -118,7 +118,7 @@ export class App extends React.Component {
<div style={{ textAlign: 'right' }}>
<RaisedButton
label={messages.save}
primary={true}
primary
disabled={false}
onClick={this.updateSettings}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/apps/google-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class App extends React.Component {
<div style={{ textAlign: 'right' }}>
<RaisedButton
label={messages.save}
primary={true}
primary
disabled={false}
onClick={this.updateSettings}
/>
Expand Down
8 changes: 4 additions & 4 deletions src/apps/jivosite.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class App extends React.Component {
updateSettings = () => {
const { code } = this.state;

api.apps.settings.update('jivosite', { code: code });
api.apps.settings.update('jivosite', { code });
api.theme.placeholders.update('jivosite', {
place: 'body_end',
value: code
Expand All @@ -60,8 +60,8 @@ export class App extends React.Component {

<TextField
type="text"
multiLine={true}
fullWidth={true}
multiLine
fullWidth
rows={10}
value={this.state.code}
onChange={this.handleChange}
Expand All @@ -72,7 +72,7 @@ export class App extends React.Component {
<div style={{ textAlign: 'right' }}>
<RaisedButton
label={messages.save}
primary={true}
primary
disabled={false}
onClick={this.updateSettings}
/>
Expand Down
18 changes: 9 additions & 9 deletions src/apps/site-verification.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ export class App extends React.Component {
.join('\n');

api.apps.settings.update('site-verification', {
google: google,
bing: bing,
pinterest: pinterest,
yandex: yandex
google,
bing,
pinterest,
yandex
});

api.theme.placeholders.update('site-verification', {
Expand All @@ -110,7 +110,7 @@ export class App extends React.Component {
value={this.state.google}
onChange={this.handleGoogleChange}
floatingLabelText="Google"
fullWidth={true}
fullWidth
hintText={GOOGLE_EXAMPLE}
/>

Expand All @@ -119,7 +119,7 @@ export class App extends React.Component {
value={this.state.bing}
onChange={this.handleBingChange}
floatingLabelText="Bing"
fullWidth={true}
fullWidth
hintText={BING_EXAMPLE}
/>

Expand All @@ -128,7 +128,7 @@ export class App extends React.Component {
value={this.state.pinterest}
onChange={this.handlePinterestChange}
floatingLabelText="Pinterest"
fullWidth={true}
fullWidth
hintText={PINTEREST_EXAMPLE}
/>

Expand All @@ -137,14 +137,14 @@ export class App extends React.Component {
value={this.state.yandex}
onChange={this.handleYandexChange}
floatingLabelText="Yandex"
fullWidth={true}
fullWidth
hintText={YANDEX_EXAMPLE}
/>

<div style={{ textAlign: 'right', marginTop: 20 }}>
<RaisedButton
label={messages.save}
primary={true}
primary
disabled={false}
onClick={this.updateSettings}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import CezerinClient from 'cezerin2-client';
import settings from 'lib/settings';

let api = null;
let dashboardToken = localStorage.getItem('dashboard_token');
let webstoreToken = localStorage.getItem('webstore_token');
const dashboardToken = localStorage.getItem('dashboard_token');
const webstoreToken = localStorage.getItem('webstore_token');

const DEVELOPER_MODE = settings.developerMode === true;

if (dashboardToken || DEVELOPER_MODE === true) {
api = new CezerinClient({
apiBaseUrl: settings.apiBaseUrl || '/api/v1',
apiToken: dashboardToken,
webstoreToken: webstoreToken
webstoreToken
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/apiWebSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import settings from 'lib/settings';
import { installReceive } from 'modules/settings/actions';
import { fetchOrders } from 'modules/orders/actions';

const AUTO_RECONNECT_INTERVAL = 1000; //1 seconds
const AUTO_RECONNECT_INTERVAL = 1000; // 1 seconds
const ORDER_CREATED = 'order.created';
const THEME_INSTALLED = 'theme.installed';
let store = null;
Expand Down Expand Up @@ -61,10 +61,10 @@ const onClose = event => {
};

const showNotification = (title, body, requireInteraction = false) => {
let msg = new Notification(title, {
body: body,
const msg = new Notification(title, {
body,
tag: 'dashboard',
requireInteraction: requireInteraction
requireInteraction
});

msg.addEventListener('click', event => {
Expand Down
10 changes: 4 additions & 6 deletions src/lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const HOME_PATH = '/';
const getParameterByName = (name, url) => {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
const results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
Expand Down Expand Up @@ -40,10 +40,8 @@ export const checkTokenFromUrl = () => {
} else {
alert(messages.tokenInvalid);
}
} else {
if (isCurrentTokenValid()) {
location.replace(HOME_PATH);
}
} else if (isCurrentTokenValid()) {
location.replace(HOME_PATH);
}
}
};
Expand Down
39 changes: 15 additions & 24 deletions src/lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,45 @@ export const formatNumber = (number, settings) => {
const x = 3;
const floatNumber = parseFloat(number || 0) || 0;

const re =
'\\d(?=(\\d{' +
x +
'})+' +
(settings.decimal_number > 0 ? '\\D' : '$') +
')';
const re = `\\d(?=(\\d{${x}})+${settings.decimal_number > 0 ? '\\D' : '$'})`;

let num = floatNumber.toFixed(Math.max(0, ~~settings.decimal_number));
const num = floatNumber.toFixed(Math.max(0, ~~settings.decimal_number));

return (settings.decimal_separator
? num.replace('.', settings.decimal_separator)
: num
).replace(new RegExp(re, 'g'), '$&' + settings.thousand_separator);
).replace(new RegExp(re, 'g'), `$&${settings.thousand_separator}`);
};

const amountPattern = '{amount}';
export const formatCurrency = (number = 0, settings) => {
return settings.currency_format.replace(
export const formatCurrency = (number = 0, settings) =>
settings.currency_format.replace(
amountPattern,
formatNumber(number, settings)
);
};

export const formatFileSize = (bytes = 0) => {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0) {
return 'n/a';
} else {
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
if (i === 0) {
return `${bytes} ${sizes[i]}`;
} else {
return `${(bytes / 1024 ** i).toFixed(1)} ${sizes[i]}`;
}
}
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
if (i === 0) {
return `${bytes} ${sizes[i]}`;
}
return `${(bytes / 1024 ** i).toFixed(1)} ${sizes[i]}`;
};

export const getThumbnailUrl = (originalUrl, width) => {
if (originalUrl && originalUrl.length > 0) {
const pos = originalUrl.lastIndexOf('/');
const thumbnailUrl =
originalUrl.substring(0, pos) +
`/${width}/` +
originalUrl.substring(pos + 1);
const thumbnailUrl = `${originalUrl.substring(
0,
pos
)}/${width}/${originalUrl.substring(pos + 1)}`;
return thumbnailUrl;
} else {
return '';
}
return '';
};

export const getOrderFieldLabelByKey = key => {
Expand Down
10 changes: 4 additions & 6 deletions src/lib/webstoreAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const HOME_PATH = '/apps';
const getParameterByName = (name, url) => {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
const results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
Expand Down Expand Up @@ -38,10 +38,8 @@ export const checkTokenFromUrl = () => {
} else {
alert(messages.tokenInvalid);
}
} else {
if (isCurrentTokenValid()) {
location.replace(HOME_PATH);
}
} else if (isCurrentTokenValid()) {
location.replace(HOME_PATH);
}
}
};
Expand Down
Loading

0 comments on commit 56d3d52

Please sign in to comment.