From 54bca72e0c2c19977bd22ae5b5d4de61455eac70 Mon Sep 17 00:00:00 2001 From: Luke Busstra Date: Sun, 16 Jun 2019 14:18:28 +1000 Subject: [PATCH] lint and prettier --- .dockerignore | 1 + config/admin.js | 2 +- public/data/countries.js | 2 +- public/data/currencies.js | 2 +- public/data/timezones.js | 2 +- src/apps/facebook-customer-chat.js | 10 +- src/apps/facebook-sdk.js | 8 +- src/apps/google-analytics.js | 2 +- src/apps/jivosite.js | 8 +- src/apps/site-verification.js | 18 +- src/lib/api.js | 6 +- src/lib/apiWebSocket.js | 8 +- src/lib/auth.js | 10 +- src/lib/helper.js | 39 +- src/lib/webstoreAuth.js | 10 +- .../apps/account/components/account.js | 116 +++--- .../apps/account/components/details.js | 18 +- .../apps/account/components/developer.js | 128 ++++--- src/modules/apps/account/index.js | 42 +-- src/modules/apps/actions.js | 43 +-- src/modules/apps/appDetails/description.js | 2 +- src/modules/apps/appDetails/index.js | 6 +- src/modules/apps/head/components/buttons.js | 38 +- src/modules/apps/head/index.js | 8 +- .../apps/serviceDetails/components/actions.js | 4 +- .../serviceDetails/components/description.js | 7 +- .../apps/serviceDetails/components/details.js | 37 +- .../apps/serviceDetails/components/logs.js | 2 +- .../serviceDetails/components/settings.js | 23 +- src/modules/apps/serviceDetails/index.js | 48 ++- .../apps/services/components/appItem.js | 16 +- src/modules/apps/services/components/item.js | 68 ++-- src/modules/apps/services/components/list.js | 4 +- .../apps/services/components/serviceItem.js | 20 +- src/modules/apps/services/index.js | 16 +- src/modules/customerGroups/actions.js | 19 +- src/modules/customerGroups/components/list.js | 4 +- .../customerGroups/edit/components/form.js | 14 +- src/modules/customerGroups/edit/index.js | 44 ++- .../customerGroups/head/components/buttons.js | 8 +- src/modules/customerGroups/head/index.js | 32 +- src/modules/customerGroups/list/index.js | 30 +- src/modules/customerGroups/select/index.js | 20 +- src/modules/customers/actions.js | 43 +-- .../customers/edit/components/addressForm.js | 24 +- .../customers/edit/components/addresses.js | 41 +-- .../customers/edit/components/orders.js | 9 +- .../customers/edit/components/summary.js | 14 +- .../customers/edit/components/summaryForm.js | 20 +- src/modules/customers/edit/index.js | 86 +++-- .../customers/editHead/components/buttons.js | 6 +- src/modules/customers/editHead/index.js | 22 +- .../customers/filter/components/fields.js | 101 +++--- src/modules/customers/filter/index.js | 52 ++- src/modules/customers/list/components/item.js | 8 +- src/modules/customers/list/components/list.js | 4 +- src/modules/customers/list/index.js | 60 ++-- .../customers/listHead/components/buttons.js | 14 +- .../customers/listHead/components/search.js | 38 +- src/modules/customers/listHead/index.js | 36 +- src/modules/customers/reducer.js | 4 +- src/modules/files/actions.js | 12 +- .../list/components/fileUploader/index.js | 10 +- src/modules/files/list/components/form.js | 24 +- src/modules/files/list/head.js | 8 +- src/modules/files/list/index.js | 36 +- src/modules/head/components/appBar.js | 5 +- src/modules/head/index.js | 6 +- src/modules/orderStatuses/actions.js | 19 +- src/modules/orderStatuses/components/list.js | 2 +- .../orderStatuses/edit/components/form.js | 14 +- src/modules/orderStatuses/edit/index.js | 44 ++- .../orderStatuses/head/components/buttons.js | 8 +- src/modules/orderStatuses/head/index.js | 32 +- src/modules/orderStatuses/list/index.js | 30 +- src/modules/orderStatuses/select/index.js | 20 +- .../orders/edit/components/customer.js | 81 ++--- src/modules/orders/edit/components/details.js | 3 +- src/modules/orders/edit/components/items.js | 40 +-- .../edit/components/shippingAddressForm.js | 23 +- src/modules/orders/edit/components/summary.js | 28 +- .../orders/edit/components/summaryForm.js | 22 +- src/modules/orders/edit/components/totals.js | 16 +- .../orders/editHead/components/buttons.js | 9 +- src/modules/orders/editHead/index.js | 54 ++- src/modules/orders/list/components/item.js | 17 +- src/modules/orders/list/components/list.js | 4 +- src/modules/orders/list/index.js | 60 ++-- .../orders/listHead/components/buttons.js | 6 +- .../orders/listHead/components/search.js | 38 +- src/modules/orders/listHead/index.js | 36 +- src/modules/pages/actions.js | 27 +- src/modules/pages/edit/components/form.js | 39 +- .../pages/edit/components/headButtons.js | 11 +- src/modules/pages/edit/head.js | 22 +- src/modules/pages/edit/index.js | 44 ++- src/modules/pages/list/components/form.js | 2 +- .../pages/list/components/headButtons.js | 2 +- src/modules/pages/list/head.js | 8 +- src/modules/pages/list/index.js | 20 +- src/modules/productCategories/actions.js | 51 ++- .../productCategories/components/list.js | 9 +- .../components/multiselectList.js | 3 +- .../productCategories/edit/components/form.js | 39 +- src/modules/productCategories/edit/index.js | 50 ++- .../head/components/buttons.js | 22 +- src/modules/productCategories/head/index.js | 52 ++- src/modules/productCategories/list/index.js | 36 +- src/modules/productCategories/select/index.js | 20 +- src/modules/products/actions.js | 93 +++-- .../edit/additional/components/form.js | 224 ++++++------ .../components/productCategoryMultiSelect.js | 11 +- .../components/productCategorySelect.js | 10 +- src/modules/products/edit/additional/index.js | 42 +-- .../edit/attributes/components/form.js | 177 +++++----- src/modules/products/edit/attributes/index.js | 30 +- .../products/edit/general/components/form.js | 37 +- src/modules/products/edit/general/index.js | 38 +- .../products/edit/images/components/images.js | 6 +- src/modules/products/edit/images/index.js | 46 ++- src/modules/products/edit/index.js | 40 +-- .../edit/inventory/components/form.js | 333 +++++++++--------- src/modules/products/edit/inventory/index.js | 56 ++- .../products/edit/option/components/option.js | 18 +- .../products/edit/option/components/values.js | 2 +- src/modules/products/edit/option/index.js | 56 ++- .../products/edit/variants/components/grid.js | 7 +- src/modules/products/edit/variants/index.js | 84 +++-- .../products/editHead/components/buttons.js | 33 +- src/modules/products/editHead/index.js | 22 +- src/modules/products/list/components/item.js | 25 +- src/modules/products/list/components/list.js | 4 +- src/modules/products/list/index.js | 68 ++-- .../products/listFilter/components/filter.js | 29 +- src/modules/products/listFilter/index.js | 46 ++- .../products/listHead/components/buttons.js | 16 +- .../products/listHead/components/search.js | 34 +- src/modules/products/listHead/index.js | 42 +-- src/modules/products/reducer.js | 4 +- src/modules/reports/ordersBar/index.js | 4 +- src/modules/reports/ordersBar/utils.js | 21 +- src/modules/settings/actions.js | 182 ++++------ .../settings/checkout/components/form.js | 46 ++- src/modules/settings/checkout/index.js | 20 +- .../checkoutFields/components/form.js | 10 +- src/modules/settings/checkoutFields/index.js | 30 +- src/modules/settings/email/components/form.js | 8 +- src/modules/settings/email/index.js | 20 +- .../emailTemplates/components/form.js | 12 +- src/modules/settings/emailTemplates/index.js | 28 +- .../settings/general/components/form.js | 136 ++++--- src/modules/settings/general/index.js | 26 +- .../settings/generalLogo/components/form.js | 2 +- src/modules/settings/generalLogo/index.js | 32 +- .../paymentGateway/components/form.js | 15 +- .../components/gatewaySettings.js | 250 +++++++------ src/modules/settings/paymentGateway/index.js | 28 +- .../settings/payments/components/form.js | 50 ++- .../payments/components/headButtons.js | 2 +- src/modules/settings/payments/head.js | 8 +- src/modules/settings/payments/index.js | 20 +- .../settings/paymentsEdit/components/form.js | 44 ++- .../paymentsEdit/components/headButtons.js | 4 +- .../paymentsEdit/components/selectShipping.js | 4 +- src/modules/settings/paymentsEdit/head.js | 22 +- src/modules/settings/paymentsEdit/index.js | 64 ++-- .../redirects/edit/components/form.js | 19 +- .../redirects/edit/components/headButtons.js | 9 +- src/modules/settings/redirects/edit/head.js | 22 +- src/modules/settings/redirects/edit/index.js | 38 +- .../redirects/list/components/form.js | 50 ++- .../redirects/list/components/headButtons.js | 2 +- src/modules/settings/redirects/list/head.js | 8 +- src/modules/settings/redirects/list/index.js | 20 +- .../settings/shipping/components/form.js | 50 ++- .../shipping/components/headButtons.js | 2 +- src/modules/settings/shipping/head.js | 8 +- src/modules/settings/shipping/index.js | 20 +- .../shippingEdit/components/fieldsEditor.js | 162 +++++---- .../settings/shippingEdit/components/form.js | 65 ++-- .../shippingEdit/components/headButtons.js | 4 +- src/modules/settings/shippingEdit/head.js | 22 +- src/modules/settings/shippingEdit/index.js | 156 ++++---- src/modules/settings/smtp/components/form.js | 18 +- src/modules/settings/smtp/index.js | 26 +- src/modules/settings/theme/components/form.js | 10 +- src/modules/settings/theme/index.js | 40 +-- .../themeSettings/components/arrayEditor.js | 122 ++++--- .../components/dynamicEditControl.js | 30 +- .../settings/themeSettings/components/form.js | 11 +- .../themeSettings/components/imageEditor.js | 80 ++--- src/modules/settings/themeSettings/index.js | 28 +- .../settings/tokens/edit/components/form.js | 16 +- src/modules/settings/tokens/edit/index.js | 46 ++- .../settings/tokens/list/components/form.js | 48 ++- .../tokens/list/components/headButtons.js | 2 +- src/modules/settings/tokens/list/head.js | 8 +- src/modules/settings/tokens/list/index.js | 20 +- .../settings/webhooks/edit/components/form.js | 23 +- .../webhooks/edit/components/headButtons.js | 9 +- src/modules/settings/webhooks/edit/head.js | 22 +- src/modules/settings/webhooks/edit/index.js | 38 +- .../settings/webhooks/list/components/form.js | 2 +- .../webhooks/list/components/headButtons.js | 2 +- src/modules/settings/webhooks/list/head.js | 8 +- src/modules/settings/webhooks/list/index.js | 20 +- src/modules/shared/confirmation/index.js | 4 +- .../shared/deleteConfirmation/index.js | 4 +- src/modules/shared/editor/index.js | 2 +- src/modules/shared/form/index.js | 63 ++-- src/modules/shared/imageUpload/index.js | 6 +- .../shared/imageUploadMultiple/index.js | 7 +- .../shared/imageUploadMultiple/item.js | 6 +- .../shared/imageUploadMultiple/uploader.js | 10 +- src/modules/shared/productSearch/index.js | 28 +- .../shared/tinymce/components/TinyMCE.js | 7 +- src/modules/shared/tinymce/helpers/uuid.js | 2 +- src/routes/apps/login.js | 6 +- src/routes/customers/groups/index.js | 2 +- src/routes/customers/index.js | 2 +- src/routes/login.js | 7 +- src/routes/orders/index.js | 2 +- src/routes/orders/statuses/index.js | 2 +- src/routes/pages/edit.js | 14 +- src/routes/products/categories/index.js | 2 +- src/routes/products/edit.js | 22 +- src/routes/products/index.js | 2 +- src/routes/settings.js | 95 +++-- 228 files changed, 3240 insertions(+), 3753 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/config/admin.js b/config/admin.js index 5d98bc09..7041079d 100644 --- a/config/admin.js +++ b/config/admin.js @@ -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 }; diff --git a/public/data/countries.js b/public/data/countries.js index 3a045dc9..9b7c9b0c 100644 --- a/public/data/countries.js +++ b/public/data/countries.js @@ -1,4 +1,4 @@ -var APPLICATION_DATA_COUNTRIES = { +const APPLICATION_DATA_COUNTRIES = { AF: 'Afghanistan', AX: '\u00c5land Islands', AL: 'Albania', diff --git a/public/data/currencies.js b/public/data/currencies.js index b0dc4c70..369f797d 100644 --- a/public/data/currencies.js +++ b/public/data/currencies.js @@ -1,4 +1,4 @@ -var APPLICATION_DATA_CURRENCIES = { +const APPLICATION_DATA_CURRENCIES = { AED: 'United Arab Emirates Dirham', AFN: 'Afghan Afghani', ALL: 'Albanian Lek', diff --git a/public/data/timezones.js b/public/data/timezones.js index 05532681..229a010d 100644 --- a/public/data/timezones.js +++ b/public/data/timezones.js @@ -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': { diff --git a/src/apps/facebook-customer-chat.js b/src/apps/facebook-customer-chat.js index 5a378f1a..29502aca 100644 --- a/src/apps/facebook-customer-chat.js +++ b/src/apps/facebook-customer-chat.js @@ -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', @@ -85,7 +85,7 @@ export class App extends React.Component {
diff --git a/src/apps/facebook-sdk.js b/src/apps/facebook-sdk.js index 4a723193..395a7e79 100644 --- a/src/apps/facebook-sdk.js +++ b/src/apps/facebook-sdk.js @@ -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 @@ -100,7 +100,7 @@ export class App extends React.Component { diff --git a/src/apps/google-analytics.js b/src/apps/google-analytics.js index 8de99a90..51abb249 100644 --- a/src/apps/google-analytics.js +++ b/src/apps/google-analytics.js @@ -100,7 +100,7 @@ export class App extends React.Component {
diff --git a/src/apps/jivosite.js b/src/apps/jivosite.js index e89c1c58..01a3c3d7 100644 --- a/src/apps/jivosite.js +++ b/src/apps/jivosite.js @@ -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 @@ -60,8 +60,8 @@ export class App extends React.Component { diff --git a/src/apps/site-verification.js b/src/apps/site-verification.js index 6670733b..8ef1279a 100644 --- a/src/apps/site-verification.js +++ b/src/apps/site-verification.js @@ -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', { @@ -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} /> @@ -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} /> @@ -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} /> @@ -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} />
diff --git a/src/lib/api.js b/src/lib/api.js index 4a10d649..b85c1e2e 100644 --- a/src/lib/api.js +++ b/src/lib/api.js @@ -2,8 +2,8 @@ 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; @@ -11,7 +11,7 @@ if (dashboardToken || DEVELOPER_MODE === true) { api = new CezerinClient({ apiBaseUrl: settings.apiBaseUrl || '/api/v1', apiToken: dashboardToken, - webstoreToken: webstoreToken + webstoreToken }); } diff --git a/src/lib/apiWebSocket.js b/src/lib/apiWebSocket.js index 4d080b78..0661b13f 100644 --- a/src/lib/apiWebSocket.js +++ b/src/lib/apiWebSocket.js @@ -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; @@ -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 => { diff --git a/src/lib/auth.js b/src/lib/auth.js index b9372d50..cc5f2939 100644 --- a/src/lib/auth.js +++ b/src/lib/auth.js @@ -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, ' ')); @@ -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); } } }; diff --git a/src/lib/helper.js b/src/lib/helper.js index 250edef3..f64bb4db 100644 --- a/src/lib/helper.js +++ b/src/lib/helper.js @@ -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 => { diff --git a/src/lib/webstoreAuth.js b/src/lib/webstoreAuth.js index f2643768..176eca21 100644 --- a/src/lib/webstoreAuth.js +++ b/src/lib/webstoreAuth.js @@ -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, ' ')); @@ -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); } } }; diff --git a/src/modules/apps/account/components/account.js b/src/modules/apps/account/components/account.js index b4a6ba0d..13472692 100644 --- a/src/modules/apps/account/components/account.js +++ b/src/modules/apps/account/components/account.js @@ -4,74 +4,72 @@ import { TextField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; -const AccountForm = ({ handleSubmit, pristine, submitting, initialValues }) => { - return ( -
-
- {messages.account} -
-
- -
-
- -
-
- -
-
- -
+const AccountForm = ({ handleSubmit, pristine, submitting, initialValues }) => ( +
+
+ {messages.account} +
+ + +
+
+ +
+
-
- +
- - -
- ); -}; + +
+
+ +
+ + +
+); export default reduxForm({ form: 'WebStoreAccountForm', diff --git a/src/modules/apps/account/components/details.js b/src/modules/apps/account/components/details.js index c7002e47..99546765 100644 --- a/src/modules/apps/account/components/details.js +++ b/src/modules/apps/account/components/details.js @@ -14,19 +14,17 @@ export default class WebStoreAccountDetails extends React.Component { if (account) { return ( -
+
- {account && - account.is_developer === true && ( - - )} + {account && account.is_developer === true && ( + + )}
); - } else { - return null; } + return null; } } diff --git a/src/modules/apps/account/components/developer.js b/src/modules/apps/account/components/developer.js index 98f03beb..b060e93a 100644 --- a/src/modules/apps/account/components/developer.js +++ b/src/modules/apps/account/components/developer.js @@ -4,83 +4,81 @@ import { TextField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const DeveloperForm = ({ handleSubmit, pristine, submitting, initialValues -}) => { - return ( -
-
- {messages.developerProfile} -
-
- -
-
- -
-
- -
-
- -
-
- -
+}) => ( +
+
+ {messages.developerProfile} +
+ + +
+
+
-
- +
- - -
- ); -}; +
+ +
+
+ +
+
+
+ +
+ + +
+); export default reduxForm({ form: 'WebStoreDeveloperForm', diff --git a/src/modules/apps/account/index.js b/src/modules/apps/account/index.js index 33e9462c..607c139d 100644 --- a/src/modules/apps/account/index.js +++ b/src/modules/apps/account/index.js @@ -1,36 +1,32 @@ import { connect } from 'react-redux'; +import * as webstoreAuth from 'lib/webstoreAuth'; import { fetchAccount, updateAccount, updateDeveloperAccount } from '../actions'; import Details from './components/details'; -import * as webstoreAuth from 'lib/webstoreAuth'; -const mapStateToProps = (state, ownProps) => { - return { - account: state.apps.account - }; -}; +const mapStateToProps = (state, ownProps) => ({ + account: state.apps.account +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - fetchData: () => { - const webstoreAuthorized = webstoreAuth.isCurrentTokenValid(); - if (webstoreAuthorized) { - dispatch(fetchAccount()); - } else { - ownProps.history.push('/apps/login'); - } - }, - onAccountSubmit: values => { - dispatch(updateAccount(values)); - }, - onDeveloperSubmit: values => { - dispatch(updateDeveloperAccount(values)); +const mapDispatchToProps = (dispatch, ownProps) => ({ + fetchData: () => { + const webstoreAuthorized = webstoreAuth.isCurrentTokenValid(); + if (webstoreAuthorized) { + dispatch(fetchAccount()); + } else { + ownProps.history.push('/apps/login'); } - }; -}; + }, + onAccountSubmit: values => { + dispatch(updateAccount(values)); + }, + onDeveloperSubmit: values => { + dispatch(updateDeveloperAccount(values)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/apps/actions.js b/src/modules/apps/actions.js index 73f9d274..5babd80f 100644 --- a/src/modules/apps/actions.js +++ b/src/modules/apps/actions.js @@ -1,6 +1,6 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; +import * as t from './actionTypes'; const receiveAccount = account => ({ type: t.ACCOUNT_RECEIVE, @@ -39,34 +39,28 @@ const receiveServiceLogs = serviceLogs => ({ serviceLogs }); -export const fetchAccount = () => (dispatch, getState) => { - return api.webstore.account.retrieve().then(({ status, json }) => { +export const fetchAccount = () => (dispatch, getState) => + api.webstore.account.retrieve().then(({ status, json }) => { dispatch(receiveAccount(json)); }); -}; -export const updateAccount = account => (dispatch, getState) => { - return api.webstore.account.update(account).then(({ status, json }) => { +export const updateAccount = account => (dispatch, getState) => + api.webstore.account.update(account).then(({ status, json }) => { dispatch(receiveAccount(json)); }); -}; -export const updateDeveloperAccount = account => (dispatch, getState) => { - return api.webstore.account - .updateDeveloper(account) - .then(({ status, json }) => { - dispatch(receiveAccount(json)); - }); -}; +export const updateDeveloperAccount = account => (dispatch, getState) => + api.webstore.account.updateDeveloper(account).then(({ status, json }) => { + dispatch(receiveAccount(json)); + }); -export const fetchServices = () => (dispatch, getState) => { - return api.webstore.services.list().then(({ status, json }) => { +export const fetchServices = () => (dispatch, getState) => + api.webstore.services.list().then(({ status, json }) => { dispatch(receiveServices(json)); }); -}; -export const fetchService = serviceId => (dispatch, getState) => { - return api.webstore.services.retrieve(serviceId).then(({ status, json }) => { +export const fetchService = serviceId => (dispatch, getState) => + api.webstore.services.retrieve(serviceId).then(({ status, json }) => { const service = json; dispatch(receiveService(service)); if (service.enabled) { @@ -74,7 +68,6 @@ export const fetchService = serviceId => (dispatch, getState) => { dispatch(fetchServiceLogs(serviceId)); } }); -}; export const enableService = serviceId => (dispatch, getState) => { dispatch(requestEnableDisableService()); @@ -106,20 +99,18 @@ export const fetchServiceSettings = serviceId => (dispatch, getState) => { export const updateServiceSettings = (serviceId, settings) => ( dispatch, getState -) => { - return api.webstore.services.settings +) => + api.webstore.services.settings .update(serviceId, settings) .then(({ status, json }) => { dispatch(fetchServiceSettings(serviceId)); }) .catch(error => {}); -}; -export const fetchServiceLogs = serviceId => (dispatch, getState) => { - return api.webstore.services.logs +export const fetchServiceLogs = serviceId => (dispatch, getState) => + api.webstore.services.logs .list(serviceId) .then(({ status, json }) => { dispatch(receiveServiceLogs(json)); }) .catch(error => {}); -}; diff --git a/src/modules/apps/appDetails/description.js b/src/modules/apps/appDetails/description.js index 051ef642..cc1d2f00 100644 --- a/src/modules/apps/appDetails/description.js +++ b/src/modules/apps/appDetails/description.js @@ -1,10 +1,10 @@ import React from 'react'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const AppDescription = ({ name, diff --git a/src/modules/apps/appDetails/index.js b/src/modules/apps/appDetails/index.js index bf7a8d59..370dc43c 100644 --- a/src/modules/apps/appDetails/index.js +++ b/src/modules/apps/appDetails/index.js @@ -1,8 +1,8 @@ import React from 'react'; -import AppDescription from './description'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import apps from 'src/apps'; +import AppDescription from './description'; +import style from './style.css'; const AppDetails = ({ match }) => { const { appKey } = match.params; @@ -11,7 +11,7 @@ const AppDetails = ({ match }) => { const appDescription = app.Description; return ( -
+
diff --git a/src/modules/apps/head/components/buttons.js b/src/modules/apps/head/components/buttons.js index e55779fb..d5174276 100644 --- a/src/modules/apps/head/components/buttons.js +++ b/src/modules/apps/head/components/buttons.js @@ -7,25 +7,23 @@ import IconMenu from 'material-ui/IconMenu'; import IconButton from 'material-ui/IconButton'; import MenuItem from 'material-ui/MenuItem'; -const WebStoreMenu = () => { - return ( - - - more_vert - - - } - targetOrigin={{ horizontal: 'right', vertical: 'top' }} - anchorOrigin={{ horizontal: 'right', vertical: 'top' }} - > - } - primaryText={messages.account} - /> - - ); -}; +const WebStoreMenu = () => ( + + + more_vert + + + } + targetOrigin={{ horizontal: 'right', vertical: 'top' }} + anchorOrigin={{ horizontal: 'right', vertical: 'top' }} + > + } + primaryText={messages.account} + /> + +); export default WebStoreMenu; diff --git a/src/modules/apps/head/index.js b/src/modules/apps/head/index.js index 7b3367b6..dade7bd9 100644 --- a/src/modules/apps/head/index.js +++ b/src/modules/apps/head/index.js @@ -3,13 +3,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import Buttons from './components/buttons'; -const mapStateToProps = (state, ownProps) => { - return {}; -}; +const mapStateToProps = (state, ownProps) => ({}); -const mapDispatchToProps = (dispatch, ownProps) => { - return {}; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({}); export default withRouter( connect( diff --git a/src/modules/apps/serviceDetails/components/actions.js b/src/modules/apps/serviceDetails/components/actions.js index 78eb5838..9838b03d 100644 --- a/src/modules/apps/serviceDetails/components/actions.js +++ b/src/modules/apps/serviceDetails/components/actions.js @@ -3,12 +3,12 @@ import { Link } from 'react-router-dom'; import messages from 'lib/text'; import api from 'lib/api'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; +import style from './style.css'; class ActionComponent extends React.Component { constructor(props) { @@ -46,7 +46,7 @@ class ActionComponent extends React.Component {
diff --git a/src/modules/apps/serviceDetails/components/description.js b/src/modules/apps/serviceDetails/components/description.js index 91406da3..b28c6aef 100644 --- a/src/modules/apps/serviceDetails/components/description.js +++ b/src/modules/apps/serviceDetails/components/description.js @@ -2,12 +2,12 @@ import React from 'react'; import { Link } from 'react-router-dom'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; +import style from './style.css'; const ServiceDescription = ({ service, @@ -34,7 +34,7 @@ const ServiceDescription = ({ {!service.enabled && ( @@ -56,9 +56,8 @@ const ServiceDescription = ({
); - } else { - return null; } + return null; }; export default ServiceDescription; diff --git a/src/modules/apps/serviceDetails/components/details.js b/src/modules/apps/serviceDetails/components/details.js index 8b7799f2..5fb54e27 100644 --- a/src/modules/apps/serviceDetails/components/details.js +++ b/src/modules/apps/serviceDetails/components/details.js @@ -24,7 +24,7 @@ export default class ServiceDetails extends React.Component { } }, 5000); - this.setState({ timer: timer }); + this.setState({ timer }); } componentWillUnmount() { @@ -32,7 +32,7 @@ export default class ServiceDetails extends React.Component { } render() { - let { + const { serviceId, service, serviceSettings, @@ -55,7 +55,7 @@ export default class ServiceDetails extends React.Component { } return ( -
+
)} - {service && - service.enabled && - serviceSettings && - !serviceError && ( - - )} - {service && - service.enabled && - !serviceError && ( - - )} + {service && service.enabled && serviceSettings && !serviceError && ( + + )} + {service && service.enabled && !serviceError && ( + + )} {service && service.enabled && serviceLogs && diff --git a/src/modules/apps/serviceDetails/components/logs.js b/src/modules/apps/serviceDetails/components/logs.js index 4b9798ae..d6b20ea6 100644 --- a/src/modules/apps/serviceDetails/components/logs.js +++ b/src/modules/apps/serviceDetails/components/logs.js @@ -4,8 +4,8 @@ import moment from 'moment'; import messages from 'lib/text'; import api from 'lib/api'; -import style from './style.css'; import Paper from 'material-ui/Paper'; +import style from './style.css'; const ServiceLogs = ({ logs }) => { const list = logs.map((action, index) => { diff --git a/src/modules/apps/serviceDetails/components/settings.js b/src/modules/apps/serviceDetails/components/settings.js index 08c4c9e8..bcae5bcb 100644 --- a/src/modules/apps/serviceDetails/components/settings.js +++ b/src/modules/apps/serviceDetails/components/settings.js @@ -5,13 +5,13 @@ import { TextField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; import { List, ListItem } from 'material-ui/List'; +import style from './style.css'; const ServiceSettingsForm = ({ handleSubmit, @@ -39,22 +39,21 @@ const ServiceSettingsForm = ({ {typeof value === 'number' && ( )} - {typeof value !== 'boolean' && - typeof value !== 'number' && ( - - )} + {typeof value !== 'boolean' && typeof value !== 'number' && ( + + )}
); }); @@ -80,7 +79,7 @@ const ServiceSettingsForm = ({ diff --git a/src/modules/apps/serviceDetails/index.js b/src/modules/apps/serviceDetails/index.js index 260a604e..30f1a17f 100644 --- a/src/modules/apps/serviceDetails/index.js +++ b/src/modules/apps/serviceDetails/index.js @@ -12,7 +12,7 @@ const mapStateToProps = (state, ownProps) => { const { serviceId } = ownProps.match.params; return { - serviceId: serviceId, + serviceId, service: state.apps.service, serviceSettings: state.apps.serviceSettings, serviceLogs: state.apps.serviceLogs, @@ -20,30 +20,28 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - fetchData: () => { - const { serviceId } = ownProps.match.params; - dispatch(fetchService(serviceId)); - }, - enableService: () => { - const { serviceId } = ownProps.match.params; - dispatch(enableService(serviceId)); - }, - disableService: () => { - const { serviceId } = ownProps.match.params; - dispatch(disableService(serviceId)); - }, - updateSettings: values => { - const { serviceId } = ownProps.match.params; - dispatch(updateServiceSettings(serviceId, values)); - }, - fetchServiceLogs: () => { - const { serviceId } = ownProps.match.params; - dispatch(fetchServiceLogs(serviceId)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + fetchData: () => { + const { serviceId } = ownProps.match.params; + dispatch(fetchService(serviceId)); + }, + enableService: () => { + const { serviceId } = ownProps.match.params; + dispatch(enableService(serviceId)); + }, + disableService: () => { + const { serviceId } = ownProps.match.params; + dispatch(disableService(serviceId)); + }, + updateSettings: values => { + const { serviceId } = ownProps.match.params; + dispatch(updateServiceSettings(serviceId, values)); + }, + fetchServiceLogs: () => { + const { serviceId } = ownProps.match.params; + dispatch(fetchServiceLogs(serviceId)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/apps/services/components/appItem.js b/src/modules/apps/services/components/appItem.js index dede690d..1af8cc4d 100644 --- a/src/modules/apps/services/components/appItem.js +++ b/src/modules/apps/services/components/appItem.js @@ -1,14 +1,12 @@ import React from 'react'; import Item from './item'; -const ServiceItem = ({ app }) => { - return ( - - ); -}; +const ServiceItem = ({ app }) => ( + +); export default ServiceItem; diff --git a/src/modules/apps/services/components/item.js b/src/modules/apps/services/components/item.js index e2140c59..64483bf7 100644 --- a/src/modules/apps/services/components/item.js +++ b/src/modules/apps/services/components/item.js @@ -1,9 +1,9 @@ import React from 'react'; import { Link } from 'react-router-dom'; import messages from 'lib/text'; -import style from './style.css'; import { Card, CardMedia, CardTitle } from 'material-ui/Card'; import FontIcon from 'material-ui/FontIcon'; +import style from './style.css'; const styles = { card: { @@ -36,39 +36,37 @@ const styles = { } }; -const Item = ({ path, coverUrl, title, developer, enabled }) => { - return ( - - - - - {developer} - {enabled && ( - - check_circle - - )} -
- } - titleStyle={styles.title} - subtitleStyle={styles.subtitle} - /> - - - ); -}; +const Item = ({ path, coverUrl, title, developer, enabled }) => ( + + + + + {developer} + {enabled && ( + + check_circle + + )} +
+ } + titleStyle={styles.title} + subtitleStyle={styles.subtitle} + /> + + +); export default Item; diff --git a/src/modules/apps/services/components/list.js b/src/modules/apps/services/components/list.js index 74d4fe3b..d807b83c 100644 --- a/src/modules/apps/services/components/list.js +++ b/src/modules/apps/services/components/list.js @@ -1,11 +1,11 @@ import React from 'react'; import { Link } from 'react-router-dom'; import messages from 'lib/text'; +import apps from 'src/apps'; +import RaisedButton from 'material-ui/RaisedButton'; import ServiceItem from './serviceItem'; import AppItem from './appItem'; import style from './style.css'; -import apps from 'src/apps'; -import RaisedButton from 'material-ui/RaisedButton'; export default class ServicesList extends React.Component { componentDidMount() { diff --git a/src/modules/apps/services/components/serviceItem.js b/src/modules/apps/services/components/serviceItem.js index f10db908..8b30fe77 100644 --- a/src/modules/apps/services/components/serviceItem.js +++ b/src/modules/apps/services/components/serviceItem.js @@ -1,16 +1,14 @@ import React from 'react'; import Item from './item'; -const ServiceItem = ({ service }) => { - return ( - - ); -}; +const ServiceItem = ({ service }) => ( + +); export default ServiceItem; diff --git a/src/modules/apps/services/index.js b/src/modules/apps/services/index.js index d3345af1..61a2d5d4 100644 --- a/src/modules/apps/services/index.js +++ b/src/modules/apps/services/index.js @@ -1,24 +1,22 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; -import { fetchServices } from '../actions'; import * as webstoreAuth from 'lib/webstoreAuth'; +import { fetchServices } from '../actions'; import List from './components/list'; const mapStateToProps = (state, ownProps) => { const webstoreAuthorized = webstoreAuth.isCurrentTokenValid(); return { services: state.apps.services, - webstoreAuthorized: webstoreAuthorized + webstoreAuthorized }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - fetchData: () => { - dispatch(fetchServices()); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + fetchData: () => { + dispatch(fetchServices()); + } +}); export default withRouter( connect( diff --git a/src/modules/customerGroups/actions.js b/src/modules/customerGroups/actions.js index 657512f9..53d366a5 100644 --- a/src/modules/customerGroups/actions.js +++ b/src/modules/customerGroups/actions.js @@ -1,6 +1,6 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; +import * as t from './actionTypes'; function requestGroups() { return { @@ -92,9 +92,8 @@ function shouldFetchGroups(state) { const groups = state.customerGroups; if (groups.isFetched || groups.isFetching) { return false; - } else { - return true; } + return true; } export function fetchGroupsIfNeeded() { @@ -121,8 +120,8 @@ export function updateGroup(data) { } export function createGroup(data) { - return (dispatch, getState) => { - return api.customerGroups + return (dispatch, getState) => + api.customerGroups .create(data) .then(({ status, json }) => { dispatch(successCreateGroup(json.id)); @@ -130,15 +129,14 @@ export function createGroup(data) { dispatch(selectGroup(json.id)); }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); - }; } export function deleteGroup(id) { - return (dispatch, getState) => { - return api.customerGroups + return (dispatch, getState) => + api.customerGroups .delete(id) .then(({ status, json }) => { if (status === 200) { @@ -150,8 +148,7 @@ export function deleteGroup(id) { } }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); - }; } diff --git a/src/modules/customerGroups/components/list.js b/src/modules/customerGroups/components/list.js index f88ba5c9..616902e0 100644 --- a/src/modules/customerGroups/components/list.js +++ b/src/modules/customerGroups/components/list.js @@ -50,7 +50,7 @@ export default class Groups extends React.Component { clear} onClick={() => { @@ -63,7 +63,7 @@ export default class Groups extends React.Component { { diff --git a/src/modules/customerGroups/edit/components/form.js b/src/modules/customerGroups/edit/components/form.js index aeb72387..d31f449b 100644 --- a/src/modules/customerGroups/edit/components/form.js +++ b/src/modules/customerGroups/edit/components/form.js @@ -3,11 +3,11 @@ import { Field, reduxForm } from 'redux-form'; import { TextField } from 'redux-form-material-ui'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -28,7 +28,7 @@ class Form extends React.Component { } render() { - let { + const { handleSubmit, pristine, submitting, @@ -49,16 +49,16 @@ class Form extends React.Component {
@@ -71,7 +71,7 @@ class Form extends React.Component { diff --git a/src/modules/customerGroups/edit/index.js b/src/modules/customerGroups/edit/index.js index 1ef6fc57..b6929586 100644 --- a/src/modules/customerGroups/edit/index.js +++ b/src/modules/customerGroups/edit/index.js @@ -3,32 +3,28 @@ import { reset } from 'redux-form'; import { updateGroup, createGroup, deselectGroup } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - groupId: state.customerGroups.selectedId, - items: state.customerGroups.items, - initialValues: state.customerGroups.items.find( - item => item.id === state.customerGroups.selectedId - ), - isSaving: state.customerGroups.isSaving - }; -}; +const mapStateToProps = state => ({ + groupId: state.customerGroups.selectedId, + items: state.customerGroups.items, + initialValues: state.customerGroups.items.find( + item => item.id === state.customerGroups.selectedId + ), + isSaving: state.customerGroups.isSaving +}); -const mapDispatchToProps = dispatch => { - return { - onSubmit: values => { - if (values.id) { - dispatch(updateGroup(values)); - } else { - dispatch(createGroup(values)); - } - }, - onCancel: () => { - dispatch(deselectGroup()); - dispatch(reset('FormCustomerGroup')); +const mapDispatchToProps = dispatch => ({ + onSubmit: values => { + if (values.id) { + dispatch(updateGroup(values)); + } else { + dispatch(createGroup(values)); } - }; -}; + }, + onCancel: () => { + dispatch(deselectGroup()); + dispatch(reset('FormCustomerGroup')); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/customerGroups/head/components/buttons.js b/src/modules/customerGroups/head/components/buttons.js index 13503911..6a4212fb 100644 --- a/src/modules/customerGroups/head/components/buttons.js +++ b/src/modules/customerGroups/head/components/buttons.js @@ -8,7 +8,7 @@ import MenuItem from 'material-ui/MenuItem'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -43,7 +43,7 @@ export default class Buttons extends React.Component { {selected && ( )} { - return { - selected: state.customerGroups.items.find( - item => item.id === state.customerGroups.selectedId - ) - }; -}; +const mapStateToProps = state => ({ + selected: state.customerGroups.items.find( + item => item.id === state.customerGroups.selectedId + ) +}); -const mapDispatchToProps = dispatch => { - return { - onDelete: id => { - dispatch(deleteGroup(id)); - dispatch(reset('FormCustomerGroup')); - }, - onCreate: () => { - dispatch(deselectGroup()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onDelete: id => { + dispatch(deleteGroup(id)); + dispatch(reset('FormCustomerGroup')); + }, + onCreate: () => { + dispatch(deselectGroup()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/customerGroups/list/index.js b/src/modules/customerGroups/list/index.js index b6266e5c..3a1f1f44 100644 --- a/src/modules/customerGroups/list/index.js +++ b/src/modules/customerGroups/list/index.js @@ -3,24 +3,20 @@ import { selectGroup, fetchGroupsIfNeeded } from '../actions'; import { fetchCustomers } from '../../customers/actions'; import List from '../components/list'; -const mapStateToProps = state => { - return { - items: state.customerGroups.items, - selectedId: state.customerGroups.selectedId - }; -}; +const mapStateToProps = state => ({ + items: state.customerGroups.items, + selectedId: state.customerGroups.selectedId +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchGroupsIfNeeded()); - }, - onSelect: groupId => { - dispatch(selectGroup(groupId)); - dispatch(fetchCustomers()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchGroupsIfNeeded()); + }, + onSelect: groupId => { + dispatch(selectGroup(groupId)); + dispatch(fetchCustomers()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/customerGroups/select/index.js b/src/modules/customerGroups/select/index.js index dfe3a503..b35660a6 100644 --- a/src/modules/customerGroups/select/index.js +++ b/src/modules/customerGroups/select/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchGroupsIfNeeded } from '../actions'; import List from '../components/list'; -const mapStateToProps = state => { - return { - items: state.customerGroups.items - }; -}; +const mapStateToProps = state => ({ + items: state.customerGroups.items +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchGroupsIfNeeded()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchGroupsIfNeeded()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/customers/actions.js b/src/modules/customers/actions.js index 3e9db6b3..2595a9f0 100644 --- a/src/modules/customers/actions.js +++ b/src/modules/customers/actions.js @@ -1,6 +1,6 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; +import * as t from './actionTypes'; const push = () => {}; function requestCustomer() { @@ -103,9 +103,9 @@ function setGroupSuccess() { } const getFilter = (state, offset = 0) => { - let filter = { + const filter = { limit: 50, - offset: offset + offset }; if (state.customers.search && state.customers.search !== '') { @@ -126,7 +126,7 @@ export function fetchCustomers() { dispatch(requestCustomers()); dispatch(deselectAllCustomer()); - let filter = getFilter(state); + const filter = getFilter(state); return api.customers .list(filter) @@ -146,7 +146,7 @@ export function fetchMoreCustomers() { if (!state.customers.loadingItems) { dispatch(requestMoreCustomers()); - let filter = getFilter(state, state.customers.items.length); + const filter = getFilter(state, state.customers.items.length); return api.customers .list(filter) @@ -163,7 +163,7 @@ export function fetchMoreCustomers() { export function deleteCustomers() { return (dispatch, getState) => { const state = getState(); - let promises = state.customers.selected.map(customerId => + const promises = state.customers.selected.map(customerId => api.customers.delete(customerId) ); @@ -180,7 +180,7 @@ export function deleteCustomers() { export function deleteCurrentCustomer() { return (dispatch, getState) => { const state = getState(); - let customer = state.customers.editCustomer; + const customer = state.customers.editCustomer; if (customer && customer.id) { return api.customers.delete(customer.id).catch(err => { @@ -193,8 +193,8 @@ export function deleteCurrentCustomer() { export function setGroup(group_id) { return (dispatch, getState) => { const state = getState(); - let promises = state.customers.selected.map(customerId => - api.customers.update(customerId, { group_id: group_id }) + const promises = state.customers.selected.map(customerId => + api.customers.update(customerId, { group_id }) ); return Promise.all(promises) @@ -208,14 +208,13 @@ export function setGroup(group_id) { } export function updateCustomer(data) { - return (dispatch, getState) => { - return api.customers + return (dispatch, getState) => + api.customers .update(data.id, data) .then(customerResponse => { dispatch(receiveCustomer(customerResponse.json)); }) .catch(error => {}); - }; } export function fetchCustomer(customerId) { @@ -232,45 +231,41 @@ export function fetchCustomer(customerId) { } export function updateAddress(customerId, addressId, data) { - return (dispatch, getState) => { - return api.customers + return (dispatch, getState) => + api.customers .updateAddress(customerId, addressId, data) .then(customerResponse => { dispatch(fetchCustomer(customerId)); }) .catch(error => {}); - }; } export function deleteAddress(customerId, addressId) { - return (dispatch, getState) => { - return api.customers + return (dispatch, getState) => + api.customers .deleteAddress(customerId, addressId) .then(customerResponse => { dispatch(fetchCustomer(customerId)); }) .catch(error => {}); - }; } export function setDefaultBillingAddress(customerId, addressId) { - return (dispatch, getState) => { - return api.customers + return (dispatch, getState) => + api.customers .setDefaultBillingAddress(customerId, addressId) .then(customerResponse => { dispatch(fetchCustomer(customerId)); }) .catch(error => {}); - }; } export function setDefaultShippingAddress(customerId, addressId) { - return (dispatch, getState) => { - return api.customers + return (dispatch, getState) => + api.customers .setDefaultShippingAddress(customerId, addressId) .then(customerResponse => { dispatch(fetchCustomer(customerId)); }) .catch(error => {}); - }; } diff --git a/src/modules/customers/edit/components/addressForm.js b/src/modules/customers/edit/components/addressForm.js index 0c6376f0..f292d95f 100644 --- a/src/modules/customers/edit/components/addressForm.js +++ b/src/modules/customers/edit/components/addressForm.js @@ -4,11 +4,11 @@ import { TextField, SelectField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import messages from 'lib/text'; -import style from './style.css'; import Divider from 'material-ui/Divider'; import RaisedButton from 'material-ui/RaisedButton'; import FlatButton from 'material-ui/FlatButton'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -25,7 +25,7 @@ const validate = values => { class CustomerAddressForm extends React.Component { render() { - let { + const { handleSubmit, pristine, submitting, @@ -45,7 +45,7 @@ class CustomerAddressForm extends React.Component {
@@ -53,7 +53,7 @@ class CustomerAddressForm extends React.Component {
@@ -61,7 +61,7 @@ class CustomerAddressForm extends React.Component {
@@ -69,7 +69,7 @@ class CustomerAddressForm extends React.Component {
@@ -77,7 +77,7 @@ class CustomerAddressForm extends React.Component {
@@ -85,7 +85,7 @@ class CustomerAddressForm extends React.Component {
@@ -93,7 +93,7 @@ class CustomerAddressForm extends React.Component {
@@ -101,7 +101,7 @@ class CustomerAddressForm extends React.Component {
@@ -109,7 +109,7 @@ class CustomerAddressForm extends React.Component {
@@ -119,7 +119,7 @@ class CustomerAddressForm extends React.Component { { - return ( -
-
{address.full_name}
-
{address.company}
-
{address.address1}
-
{address.address2}
-
- {address.city},{' '} - {address.state && address.state.length > 0 ? address.state + ', ' : ''} - {address.postal_code} -
-
{address.country}
-
{address.phone}
+const Address = ({ address }) => ( +
+
{address.full_name}
+
{address.company}
+
{address.address1}
+
{address.address2}
+
+ {address.city},{' '} + {address.state && address.state.length > 0 ? `${address.state}, ` : ''} + {address.postal_code}
- ); -}; +
{address.country}
+
{address.phone}
+
+); const iconButtonElement = ( - + more_vert @@ -135,7 +133,7 @@ class CustomerAddress extends React.Component { modal={false} open={this.state.openEdit} onRequestClose={this.hideEditForm} - autoScrollBodyContent={true} + autoScrollBodyContent contentStyle={{ width: 600 }} > )); return
{addresses}
; - } else { - return null; } + return null; }; export default CustomerAddresses; diff --git a/src/modules/customers/edit/components/orders.js b/src/modules/customers/edit/components/orders.js index 6460cbe1..46c62386 100644 --- a/src/modules/customers/edit/components/orders.js +++ b/src/modules/customers/edit/components/orders.js @@ -5,15 +5,15 @@ import moment from 'moment'; import api from 'lib/api'; import messages from 'lib/text'; import * as helper from 'lib/helper'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; import { List, ListItem } from 'material-ui/List'; +import style from './style.css'; const getOrderStates = order => { - let states = []; + const states = []; if (order.hold) { states.push( @@ -67,7 +67,10 @@ const getOrderStates = order => { }; const CustomerOrder = ({ order, settings }) => { - let grandTotalFormatted = helper.formatCurrency(order.grand_total, settings); + const grandTotalFormatted = helper.formatCurrency( + order.grand_total, + settings + ); const dateCreated = moment(order.date_placed || order.date_created); const dateCreatedFormated = dateCreated.format(settings.date_format); const states = getOrderStates(order); diff --git a/src/modules/customers/edit/components/summary.js b/src/modules/customers/edit/components/summary.js index b90b576f..58acf4bd 100644 --- a/src/modules/customers/edit/components/summary.js +++ b/src/modules/customers/edit/components/summary.js @@ -4,8 +4,6 @@ import moment from 'moment'; import messages from 'lib/text'; import * as helper from 'lib/helper'; -import style from './style.css'; -import SummaryForm from './summaryForm.js'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; @@ -17,6 +15,8 @@ import IconMenu from 'material-ui/IconMenu'; import MenuItem from 'material-ui/MenuItem'; import SelectField from 'material-ui/SelectField'; import Dialog from 'material-ui/Dialog'; +import SummaryForm from './summaryForm.js'; +import style from './style.css'; export default class CustomerSummary extends React.Component { constructor(props) { @@ -56,32 +56,32 @@ export default class CustomerSummary extends React.Component {
-
+
{messages.email}
-
+
{messages.mobile}
{customer.mobile}
-
+
{messages.customers_totalSpent}
{totalSpent}
-
+
{messages.note}
diff --git a/src/modules/customers/edit/components/summaryForm.js b/src/modules/customers/edit/components/summaryForm.js index 32933a42..105b5440 100644 --- a/src/modules/customers/edit/components/summaryForm.js +++ b/src/modules/customers/edit/components/summaryForm.js @@ -5,12 +5,12 @@ import { TextField, SelectField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import api from 'lib/api'; import messages from 'lib/text'; -import style from './style.css'; import Divider from 'material-ui/Divider'; import RaisedButton from 'material-ui/RaisedButton'; import FlatButton from 'material-ui/FlatButton'; import MenuItem from 'material-ui/MenuItem'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -40,7 +40,7 @@ class CustomerEditForm extends React.Component { } render() { - let { + const { handleSubmit, pristine, submitting, @@ -48,7 +48,7 @@ class CustomerEditForm extends React.Component { onCancel } = this.props; - let groupItems = this.state.groups.map((item, index) => ( + const groupItems = this.state.groups.map((item, index) => ( )); groupItems.push( @@ -71,14 +71,14 @@ class CustomerEditForm extends React.Component {
@@ -87,7 +87,7 @@ class CustomerEditForm extends React.Component {
@@ -95,7 +95,7 @@ class CustomerEditForm extends React.Component {
@@ -103,10 +103,10 @@ class CustomerEditForm extends React.Component {
@@ -114,7 +114,7 @@ class CustomerEditForm extends React.Component { { - return { - settings: state.settings.settings, - customer: state.customers.editCustomer - }; -}; +const mapStateToProps = (state, ownProps) => ({ + settings: state.settings.settings, + customer: state.customers.editCustomer +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - fetchData: () => { - const { customerId } = ownProps.match.params; - dispatch(fetchCustomer(customerId)); - }, - clearData: () => { - dispatch(clearCustomerDetails()); - }, - onUpdateAddress: address => { - const { customerId } = ownProps.match.params; - dispatch(updateAddress(customerId, address.id, address)); - }, - onDeleteAddress: addressId => { - const { customerId } = ownProps.match.params; - dispatch(deleteAddress(customerId, addressId)); - }, - onSetDefaultBillingAddress: addressId => { - const { customerId } = ownProps.match.params; - dispatch(setDefaultBillingAddress(customerId, addressId)); - }, - onSetDefaultShippingAddress: addressId => { - const { customerId } = ownProps.match.params; - dispatch(setDefaultShippingAddress(customerId, addressId)); - }, - onCustomerSummaryUpdate: customer => { - dispatch( - updateCustomer({ - id: customer.id, - note: customer.note, - full_name: customer.full_name, - group_id: customer.group_id, - email: customer.email, - mobile: customer.mobile - }) - ); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + fetchData: () => { + const { customerId } = ownProps.match.params; + dispatch(fetchCustomer(customerId)); + }, + clearData: () => { + dispatch(clearCustomerDetails()); + }, + onUpdateAddress: address => { + const { customerId } = ownProps.match.params; + dispatch(updateAddress(customerId, address.id, address)); + }, + onDeleteAddress: addressId => { + const { customerId } = ownProps.match.params; + dispatch(deleteAddress(customerId, addressId)); + }, + onSetDefaultBillingAddress: addressId => { + const { customerId } = ownProps.match.params; + dispatch(setDefaultBillingAddress(customerId, addressId)); + }, + onSetDefaultShippingAddress: addressId => { + const { customerId } = ownProps.match.params; + dispatch(setDefaultShippingAddress(customerId, addressId)); + }, + onCustomerSummaryUpdate: customer => { + dispatch( + updateCustomer({ + id: customer.id, + note: customer.note, + full_name: customer.full_name, + group_id: customer.group_id, + email: customer.email, + mobile: customer.mobile + }) + ); + } +}); export default withRouter( connect( diff --git a/src/modules/customers/editHead/components/buttons.js b/src/modules/customers/editHead/components/buttons.js index f92ed2c2..cab403b3 100644 --- a/src/modules/customers/editHead/components/buttons.js +++ b/src/modules/customers/editHead/components/buttons.js @@ -5,7 +5,7 @@ import DeleteConfirmation from 'modules/shared/deleteConfirmation'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; import FlatButton from 'material-ui/FlatButton'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -38,7 +38,7 @@ export default class Buttons extends React.Component { return ( { - return { - customer: state.customers.editCustomer - }; -}; +const mapStateToProps = (state, ownProps) => ({ + customer: state.customers.editCustomer +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onDelete: () => { - dispatch(deleteCurrentCustomer()); - ownProps.history.push('/customers'); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onDelete: () => { + dispatch(deleteCurrentCustomer()); + ownProps.history.push('/customers'); + } +}); export default withRouter( connect( diff --git a/src/modules/customers/filter/components/fields.js b/src/modules/customers/filter/components/fields.js index 53d3b32b..c3785bf9 100644 --- a/src/modules/customers/filter/components/fields.js +++ b/src/modules/customers/filter/components/fields.js @@ -1,10 +1,10 @@ import React from 'react'; import messages from 'lib/text'; -import style from './style.css'; import SelectField from 'material-ui/SelectField'; import MenuItem from 'material-ui/MenuItem'; import Toggle from 'material-ui/Toggle'; +import style from './style.css'; export default ({ active, @@ -15,57 +15,52 @@ export default ({ setDiscontinued, setOnSale, setStock -}) => { - return ( -
- { - setActive(value); - }} - toggled={active} - className={style.toggle} - /> - { - setDiscontinued(value); - }} - toggled={discontinued} - className={style.toggle} +}) => ( +
+ { + setActive(value); + }} + toggled={active} + className={style.toggle} + /> + { + setDiscontinued(value); + }} + toggled={discontinued} + className={style.toggle} + /> + { + setOnSale(value); + }} + toggled={on_sale} + className={style.toggle} + /> + { + setStock(value); + }} + floatingLabelText={messages.products_stockStatus} + fullWidth + > + + + - { - setOnSale(value); - }} - toggled={on_sale} - className={style.toggle} + + + - { - setStock(value); - }} - floatingLabelText={messages.products_stockStatus} - fullWidth={true} - > - - - - - - - -
- ); -}; + +
+); diff --git a/src/modules/customers/filter/index.js b/src/modules/customers/filter/index.js index 1edef2c3..2cdaccf1 100644 --- a/src/modules/customers/filter/index.js +++ b/src/modules/customers/filter/index.js @@ -8,35 +8,31 @@ import { } from '../actions'; import Filter from './components/fields'; -const mapStateToProps = state => { - return { - active: state.products.filter_active, - discontinued: state.products.filter_discontinued, - on_sale: state.products.filter_on_sale, - stock_status: state.products.filter_stock_status - }; -}; +const mapStateToProps = state => ({ + active: state.products.filter_active, + discontinued: state.products.filter_discontinued, + on_sale: state.products.filter_on_sale, + stock_status: state.products.filter_stock_status +}); -const mapDispatchToProps = dispatch => { - return { - setActive: value => { - dispatch(setFilterActive(value)); - dispatch(fetchProducts()); - }, - setDiscontinued: value => { - dispatch(setFilterDiscontinued(value)); - dispatch(fetchProducts()); - }, - setOnSale: value => { - dispatch(setFilterOnSale(value)); - dispatch(fetchProducts()); - }, - setStock: value => { - dispatch(setFilterStock(value)); - dispatch(fetchProducts()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + setActive: value => { + dispatch(setFilterActive(value)); + dispatch(fetchProducts()); + }, + setDiscontinued: value => { + dispatch(setFilterDiscontinued(value)); + dispatch(fetchProducts()); + }, + setOnSale: value => { + dispatch(setFilterOnSale(value)); + dispatch(fetchProducts()); + }, + setStock: value => { + dispatch(setFilterStock(value)); + dispatch(fetchProducts()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/customers/list/components/item.js b/src/modules/customers/list/components/item.js index 0853d512..b1ac10d1 100644 --- a/src/modules/customers/list/components/item.js +++ b/src/modules/customers/list/components/item.js @@ -10,13 +10,13 @@ import style from './style.css'; const CustomersListItem = ({ customer, onSelect, selected, settings }) => { const checked = selected.includes(customer.id); - let totalSpentFormatted = helper.formatCurrency( + const totalSpentFormatted = helper.formatCurrency( customer.total_spent, settings ); return ( -
+
{
{customer.full_name} @@ -39,7 +39,7 @@ const CustomersListItem = ({ customer, onSelect, selected, settings }) => { {customer.group_name}
-
+
{customer.shipping && customer.shipping.city && ( { - return { - settings: state.settings.settings, - items: state.customers.items, - selected: state.customers.selected, - loadingItems: state.customers.loadingItems, - hasMore: state.customers.hasMore - }; -}; +const mapStateToProps = state => ({ + settings: state.settings.settings, + items: state.customers.items, + selected: state.customers.selected, + loadingItems: state.customers.loadingItems, + hasMore: state.customers.hasMore +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchCustomers()); - }, - onSelect: (customerId, checked) => { - if (checked) { - dispatch(selectCustomer(customerId)); - } else { - dispatch(deselectCustomer(customerId)); - } - }, - onSelectAll: checked => { - if (checked) { - dispatch(selectAllCustomer()); - } else { - dispatch(deselectAllCustomer()); - } - }, - loadMore: () => { - dispatch(fetchMoreCustomers()); +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchCustomers()); + }, + onSelect: (customerId, checked) => { + if (checked) { + dispatch(selectCustomer(customerId)); + } else { + dispatch(deselectCustomer(customerId)); } - }; -}; + }, + onSelectAll: checked => { + if (checked) { + dispatch(selectAllCustomer()); + } else { + dispatch(deselectAllCustomer()); + } + }, + loadMore: () => { + dispatch(fetchMoreCustomers()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/customers/listHead/components/buttons.js b/src/modules/customers/listHead/components/buttons.js index 38bc17cd..e45b967e 100644 --- a/src/modules/customers/listHead/components/buttons.js +++ b/src/modules/customers/listHead/components/buttons.js @@ -50,7 +50,7 @@ export default class Buttons extends React.Component { }; selectSetGroup = groupId => { - this.setState({ groupId: groupId }); + this.setState({ groupId }); }; render() { @@ -64,8 +64,8 @@ export default class Buttons extends React.Component { />, ]; @@ -76,7 +76,7 @@ export default class Buttons extends React.Component { {selectedCount > 0 && ( diff --git a/src/modules/customers/listHead/components/search.js b/src/modules/customers/listHead/components/search.js index 6a910dca..f5d6c42b 100644 --- a/src/modules/customers/listHead/components/search.js +++ b/src/modules/customers/listHead/components/search.js @@ -2,23 +2,21 @@ import React from 'react'; import messages from 'lib/text'; import TextField from 'material-ui/TextField'; -export default ({ value, setSearch }) => { - return ( - { - setSearch(v); - }} - hintText={messages.customers_search} - underlineShow={false} - className="searchField" - hintStyle={{ color: 'rgba(255,255,255,0.4)', textIndent: '16px' }} - inputStyle={{ - color: '#fff', - backgroundColor: 'rgba(255,255,255,0.2)', - borderRadius: '4px', - textIndent: '16px' - }} - /> - ); -}; +export default ({ value, setSearch }) => ( + { + setSearch(v); + }} + hintText={messages.customers_search} + underlineShow={false} + className="searchField" + hintStyle={{ color: 'rgba(255,255,255,0.4)', textIndent: '16px' }} + inputStyle={{ + color: '#fff', + backgroundColor: 'rgba(255,255,255,0.2)', + borderRadius: '4px', + textIndent: '16px' + }} + /> +); diff --git a/src/modules/customers/listHead/index.js b/src/modules/customers/listHead/index.js index 82bd8665..a118105b 100644 --- a/src/modules/customers/listHead/index.js +++ b/src/modules/customers/listHead/index.js @@ -8,27 +8,23 @@ import { } from '../actions'; import Buttons from './components/buttons'; -const mapStateToProps = state => { - return { - search: state.customers.search, - selectedCount: state.customers.selected.length - }; -}; +const mapStateToProps = state => ({ + search: state.customers.search, + selectedCount: state.customers.selected.length +}); -const mapDispatchToProps = dispatch => { - return { - setSearch: value => { - dispatch(setFilterSearch(value)); - dispatch(fetchCustomers()); - }, - onDelete: () => { - dispatch(deleteCustomers()); - }, - onSetGroup: group_id => { - dispatch(setGroup(group_id)); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + setSearch: value => { + dispatch(setFilterSearch(value)); + dispatch(fetchCustomers()); + }, + onDelete: () => { + dispatch(deleteCustomers()); + }, + onSetGroup: group_id => { + dispatch(setGroup(group_id)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/customers/reducer.js b/src/modules/customers/reducer.js index 6df28719..c083f133 100644 --- a/src/modules/customers/reducer.js +++ b/src/modules/customers/reducer.js @@ -48,9 +48,9 @@ export default (state = initialState, action) => { selected: [] }); case t.CUSTOMERS_SELECT_ALL: - let selected = state.items.map(item => item.id); + const selected = state.items.map(item => item.id); return Object.assign({}, state, { - selected: selected + selected }); case t.CUSTOMERS_FILTER_SET_SEARCH: return Object.assign({}, state, { diff --git a/src/modules/files/actions.js b/src/modules/files/actions.js index c8b9b8e3..8e59ae65 100644 --- a/src/modules/files/actions.js +++ b/src/modules/files/actions.js @@ -1,6 +1,6 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; +import * as t from './actionTypes'; function receiveFiles(files) { return { @@ -22,14 +22,13 @@ function filesUploadEnd() { } export function fetchFiles() { - return (dispatch, getState) => { - return api.files + return (dispatch, getState) => + api.files .list() .then(({ status, json }) => { dispatch(receiveFiles(json)); }) .catch(error => {}); - }; } export function uploadFiles(form) { @@ -48,12 +47,11 @@ export function uploadFiles(form) { } export function deleteFile(fileName) { - return (dispatch, getState) => { - return api.files + return (dispatch, getState) => + api.files .delete(fileName) .then(() => { dispatch(fetchFiles()); }) .catch(error => {}); - }; } diff --git a/src/modules/files/list/components/fileUploader/index.js b/src/modules/files/list/components/fileUploader/index.js index f1642fed..80ec5ef3 100644 --- a/src/modules/files/list/components/fileUploader/index.js +++ b/src/modules/files/list/components/fileUploader/index.js @@ -1,14 +1,14 @@ import React from 'react'; import Dropzone from 'react-dropzone'; import messages from 'lib/text'; -import style from './style.css'; import Snackbar from 'material-ui/Snackbar'; import FlatButton from 'material-ui/FlatButton'; +import style from './style.css'; export default class MultiUploader extends React.Component { onDrop = files => { - let form = new FormData(); + const form = new FormData(); files.map(file => { form.append('file', file); }); @@ -21,13 +21,13 @@ export default class MultiUploader extends React.Component {
{ this.dropzone = node; }} style={{}} - className={style.dropzone + (uploading ? ' ' + style.uploading : '')} + className={style.dropzone + (uploading ? ` ${style.uploading}` : '')} activeClassName={style.dropzoneActive} rejectClassName={style.dropzoneReject} > diff --git a/src/modules/files/list/components/form.js b/src/modules/files/list/components/form.js index c7a33583..224bcd79 100644 --- a/src/modules/files/list/components/form.js +++ b/src/modules/files/list/components/form.js @@ -4,18 +4,18 @@ import moment from 'moment'; import messages from 'lib/text'; import * as helper from 'lib/helper'; import DeleteConfirmation from 'modules/shared/deleteConfirmation'; -import style from './style.css'; -import FileUploader from './fileUploader'; import Paper from 'material-ui/Paper'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; import IconMenu from 'material-ui/IconMenu'; import MenuItem from 'material-ui/MenuItem'; -const Fragment = React.Fragment; +import FileUploader from './fileUploader'; +import style from './style.css'; +const { Fragment } = React; const iconButtonElement = ( - + more_vert @@ -53,15 +53,15 @@ class FileItem extends React.Component { const fileSizeFormated = helper.formatFileSize(file.size); return ( -
-
+
+ -
{modifiedDateFormated}
-
{fileSizeFormated}
-
+
{modifiedDateFormated}
+
{fileSizeFormated}
+
{messages.actions_delete} @@ -69,7 +69,7 @@ class FileItem extends React.Component { ( + const listItems = files.map((file, index) => ( -
+
{messages.fileName}
{messages.fileModified}
{messages.fileSize}
diff --git a/src/modules/files/list/head.js b/src/modules/files/list/head.js index 84e82ab9..d5ba9460 100644 --- a/src/modules/files/list/head.js +++ b/src/modules/files/list/head.js @@ -2,13 +2,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return {}; -}; +const mapStateToProps = (state, ownProps) => ({}); -const mapDispatchToProps = (dispatch, ownProps) => { - return {}; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({}); export default withRouter( connect( diff --git a/src/modules/files/list/index.js b/src/modules/files/list/index.js index 828af1da..00e8b09a 100644 --- a/src/modules/files/list/index.js +++ b/src/modules/files/list/index.js @@ -2,27 +2,23 @@ import { connect } from 'react-redux'; import { fetchFiles, uploadFiles, deleteFile } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - files: state.files.files, - uploading: state.files.uploading, - settings: state.settings.settings - }; -}; +const mapStateToProps = state => ({ + files: state.files.files, + uploading: state.files.uploading, + settings: state.settings.settings +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchFiles()); - }, - onDelete: fileName => { - dispatch(deleteFile(fileName)); - }, - onUpload: form => { - dispatch(uploadFiles(form)); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchFiles()); + }, + onDelete: fileName => { + dispatch(deleteFile(fileName)); + }, + onUpload: form => { + dispatch(uploadFiles(form)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/head/components/appBar.js b/src/modules/head/components/appBar.js index 497a0017..5596abb2 100644 --- a/src/modules/head/components/appBar.js +++ b/src/modules/head/components/appBar.js @@ -24,11 +24,11 @@ import WebhooksListHead from 'modules/settings/webhooks/list/head'; import WebhooksEditHead from 'modules/settings/webhooks/edit/head'; import AppsHead from 'modules/apps/head'; import FileListHead from 'modules/files/list/head'; -import DrawerMenu from './drawer'; import FontIcon from 'material-ui/FontIcon'; import AppBar from 'material-ui/AppBar'; import IconButton from 'material-ui/IconButton'; +import DrawerMenu from './drawer'; export default class AppBarTop extends React.Component { constructor(props) { @@ -37,6 +37,7 @@ export default class AppBarTop extends React.Component { } handleToggle = () => this.setState({ open: !this.state.open }); + handleClose = () => this.setState({ open: false }); render() { @@ -50,7 +51,7 @@ export default class AppBarTop extends React.Component { orderStatusName, orderNumber } = this.props; - const pathname = location.pathname; + const { pathname } = location; if (pathname === '/login' || pathname === '/logout') { return null; diff --git a/src/modules/head/index.js b/src/modules/head/index.js index d97781b0..1dcbe3ee 100644 --- a/src/modules/head/index.js +++ b/src/modules/head/index.js @@ -23,13 +23,11 @@ const mapStateToProps = state => { productCategoryName: productCategory ? productCategory.name : null, customerGroupName: customerGroup ? customerGroup.name : null, orderStatusName: orderStatus ? orderStatus.name : null, - orderNumber: orderNumber + orderNumber }; }; -const mapDispatchToProps = dispatch => { - return {}; -}; +const mapDispatchToProps = dispatch => ({}); export default withRouter( connect( diff --git a/src/modules/orderStatuses/actions.js b/src/modules/orderStatuses/actions.js index 6b96f6fe..cba47ac0 100644 --- a/src/modules/orderStatuses/actions.js +++ b/src/modules/orderStatuses/actions.js @@ -1,6 +1,6 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; +import * as t from './actionTypes'; function requestStatuses() { return { @@ -92,9 +92,8 @@ function shouldFetchStatuses(state) { const statuses = state.orderStatuses; if (statuses.isFetched || statuses.isFetching) { return false; - } else { - return true; } + return true; } export function fetchStatusesIfNeeded() { @@ -121,8 +120,8 @@ export function updateStatus(data) { } export function createStatus(data) { - return (dispatch, getState) => { - return api.orderStatuses + return (dispatch, getState) => + api.orderStatuses .create(data) .then(({ status, json }) => { dispatch(successCreateStatus(json.id)); @@ -130,15 +129,14 @@ export function createStatus(data) { dispatch(selectStatus(json.id)); }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); - }; } export function deleteStatus(id) { - return (dispatch, getState) => { - return api.orderStatuses + return (dispatch, getState) => + api.orderStatuses .delete(id) .then(({ status, json }) => { if (status === 200) { @@ -150,8 +148,7 @@ export function deleteStatus(id) { } }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); - }; } diff --git a/src/modules/orderStatuses/components/list.js b/src/modules/orderStatuses/components/list.js index 5353f776..ddf84532 100644 --- a/src/modules/orderStatuses/components/list.js +++ b/src/modules/orderStatuses/components/list.js @@ -43,7 +43,7 @@ export default class StatusesList extends React.Component { { diff --git a/src/modules/orderStatuses/edit/components/form.js b/src/modules/orderStatuses/edit/components/form.js index 1baec3ff..eb21932a 100644 --- a/src/modules/orderStatuses/edit/components/form.js +++ b/src/modules/orderStatuses/edit/components/form.js @@ -3,11 +3,11 @@ import { Field, reduxForm } from 'redux-form'; import { TextField } from 'redux-form-material-ui'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -24,7 +24,7 @@ const validate = values => { class Form extends React.Component { render() { - let { + const { handleSubmit, pristine, submitting, @@ -45,16 +45,16 @@ class Form extends React.Component {
@@ -67,7 +67,7 @@ class Form extends React.Component { diff --git a/src/modules/orderStatuses/edit/index.js b/src/modules/orderStatuses/edit/index.js index 6074ebd3..610148d9 100644 --- a/src/modules/orderStatuses/edit/index.js +++ b/src/modules/orderStatuses/edit/index.js @@ -3,32 +3,28 @@ import { reset } from 'redux-form'; import { updateStatus, createStatus, deselectStatus } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - statusId: state.orderStatuses.selectedId, - items: state.orderStatuses.items, - initialValues: state.orderStatuses.items.find( - item => item.id === state.orderStatuses.selectedId - ), - isSaving: state.orderStatuses.isSaving - }; -}; +const mapStateToProps = state => ({ + statusId: state.orderStatuses.selectedId, + items: state.orderStatuses.items, + initialValues: state.orderStatuses.items.find( + item => item.id === state.orderStatuses.selectedId + ), + isSaving: state.orderStatuses.isSaving +}); -const mapDispatchToProps = dispatch => { - return { - onSubmit: values => { - if (values.id) { - dispatch(updateStatus(values)); - } else { - dispatch(createStatus(values)); - } - }, - onCancel: () => { - dispatch(deselectStatus()); - dispatch(reset('FormOrderStatus')); +const mapDispatchToProps = dispatch => ({ + onSubmit: values => { + if (values.id) { + dispatch(updateStatus(values)); + } else { + dispatch(createStatus(values)); } - }; -}; + }, + onCancel: () => { + dispatch(deselectStatus()); + dispatch(reset('FormOrderStatus')); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/orderStatuses/head/components/buttons.js b/src/modules/orderStatuses/head/components/buttons.js index 068e88c6..aec3aeef 100644 --- a/src/modules/orderStatuses/head/components/buttons.js +++ b/src/modules/orderStatuses/head/components/buttons.js @@ -3,7 +3,7 @@ import messages from 'lib/text'; import DeleteConfirmation from 'modules/shared/deleteConfirmation'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -38,7 +38,7 @@ export default class Buttons extends React.Component { {selected && ( )} { - return { - selected: state.orderStatuses.items.find( - item => item.id === state.orderStatuses.selectedId - ) - }; -}; +const mapStateToProps = state => ({ + selected: state.orderStatuses.items.find( + item => item.id === state.orderStatuses.selectedId + ) +}); -const mapDispatchToProps = dispatch => { - return { - onDelete: id => { - dispatch(deleteStatus(id)); - dispatch(reset('FormOrderStatus')); - }, - onCreate: () => { - dispatch(deselectStatus()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onDelete: id => { + dispatch(deleteStatus(id)); + dispatch(reset('FormOrderStatus')); + }, + onCreate: () => { + dispatch(deselectStatus()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/orderStatuses/list/index.js b/src/modules/orderStatuses/list/index.js index ffe45c66..e7c637d5 100644 --- a/src/modules/orderStatuses/list/index.js +++ b/src/modules/orderStatuses/list/index.js @@ -3,24 +3,20 @@ import { selectStatus, fetchStatusesIfNeeded } from '../actions'; import { fetchOrders } from '../../orders/actions'; import List from '../components/list'; -const mapStateToProps = state => { - return { - items: state.orderStatuses.items, - selectedId: state.orderStatuses.selectedId - }; -}; +const mapStateToProps = state => ({ + items: state.orderStatuses.items, + selectedId: state.orderStatuses.selectedId +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchStatusesIfNeeded()); - }, - onSelect: statusId => { - dispatch(selectStatus(statusId)); - dispatch(fetchOrders()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchStatusesIfNeeded()); + }, + onSelect: statusId => { + dispatch(selectStatus(statusId)); + dispatch(fetchOrders()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/orderStatuses/select/index.js b/src/modules/orderStatuses/select/index.js index 3b4a5f7a..0023beee 100644 --- a/src/modules/orderStatuses/select/index.js +++ b/src/modules/orderStatuses/select/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchStatusesIfNeeded } from '../actions'; import List from '../components/list'; -const mapStateToProps = state => { - return { - items: state.orderStatuses.items - }; -}; +const mapStateToProps = state => ({ + items: state.orderStatuses.items +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchStatusesIfNeeded()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchStatusesIfNeeded()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/orders/edit/components/customer.js b/src/modules/orders/edit/components/customer.js index 87121119..bf7e68fe 100644 --- a/src/modules/orders/edit/components/customer.js +++ b/src/modules/orders/edit/components/customer.js @@ -3,20 +3,17 @@ import { Link } from 'react-router-dom'; import messages from 'lib/text'; import * as helper from 'lib/helper'; -import style from './style.css'; -import ShippingAddressForm from './shippingAddressForm.js'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; import Dialog from 'material-ui/Dialog'; +import ShippingAddressForm from './shippingAddressForm.js'; +import style from './style.css'; -const getShippingFieldLabel = ({ label, key }) => { - return label && label.length > 0 - ? label - : helper.getOrderFieldLabelByKey(key); -}; +const getShippingFieldLabel = ({ label, key }) => + label && label.length > 0 ? label : helper.getOrderFieldLabelByKey(key); const ShippingFields = ({ order, shippingMethod }) => { let rows = null; @@ -55,9 +52,9 @@ const ShippingAddress = ({ order, settings }) => {
{address.city} - {address.state && address.state.length > 0 ? ', ' + address.state : ''} + {address.state && address.state.length > 0 ? `, ${address.state}` : ''} {address.postal_code && address.postal_code.length > 0 - ? ', ' + address.postal_code + ? `, ${address.postal_code}` : ''}
@@ -83,7 +80,8 @@ const BillingAddress = ({ address, settings }) => { if (billinsAddressIsEmpty && settings.hide_billing_address) { return null; - } else if (billinsAddressIsEmpty && !settings.hide_billing_address) { + } + if (billinsAddressIsEmpty && !settings.hide_billing_address) { return (
{
); - } else { - return ( -
- -
- {messages.billingAddress} -
-
-
{address.full_name}
-
{address.company}
-
{address.address1}
-
{address.address2}
-
- {address.city},{' '} - {address.state && address.state.length > 0 - ? address.state + ', ' - : ''} - {address.postal_code} -
-
{address.country}
-
{address.phone}
+ } + return ( +
+ +
+ {messages.billingAddress} +
+
+
{address.full_name}
+
{address.company}
+
{address.address1}
+
{address.address2}
+
+ {address.city},{' '} + {address.state && address.state.length > 0 + ? `${address.state}, ` + : ''} + {address.postal_code}
+
{address.country}
+
{address.phone}
- ); - } +
+ ); }; export default class OrderCustomer extends React.Component { @@ -184,7 +181,7 @@ export default class OrderCustomer extends React.Component {
@@ -226,7 +223,7 @@ export default class OrderCustomer extends React.Component { modal={false} open={this.state.openShippingEdit} onRequestClose={this.hideShippingEdit} - autoScrollBodyContent={true} + autoScrollBodyContent contentStyle={{ width: 600 }} > + more_vert @@ -34,7 +34,7 @@ const ProductOption = ({ option, onChange, selectedOptions }) => { return ( { onChange(option.id, value); @@ -56,9 +56,8 @@ const ProductOptions = ({ options, onChange, selectedOptions }) => { /> )); return
{items}
; - } else { - return null; } + return null; }; export class OrderItem extends React.Component { @@ -104,7 +103,7 @@ export class OrderItem extends React.Component { onOptionChange = (optionId, valueId) => { this.setState({ quantity: 1 }); - let { selectedOptions } = this.state; + const { selectedOptions } = this.state; if (valueId === '') { delete selectedOptions[optionId]; @@ -112,13 +111,13 @@ export class OrderItem extends React.Component { selectedOptions[optionId] = valueId; } - this.setState({ selectedOptions: selectedOptions }); + this.setState({ selectedOptions }); this.findVariantBySelectedOptions(); }; findVariantBySelectedOptions = () => { const { selectedOptions } = this.state; - const product = this.props.item.product; + const { product } = this.props.item; for (const variant of product.variants) { const variantMutchSelectedOptions = variant.options.every( variantOption => @@ -135,7 +134,7 @@ export class OrderItem extends React.Component { getCurrentVariant = () => { const variantId = this.props.item.variant_id; - const product = this.props.item.product; + const { product } = this.props.item; let variant = null; if ( @@ -152,8 +151,8 @@ export class OrderItem extends React.Component { getOptionsByVariant = () => { const variantId = this.props.item.variant_id; - const product = this.props.item.product; - let selectedOptions = {}; + const { product } = this.props.item; + const selectedOptions = {}; if ( variantId && product && @@ -180,20 +179,19 @@ export class OrderItem extends React.Component { onClick={this.hideEditForm} style={{ marginRight: 10 }} />, - + ]; let { quantity } = this.state; const { selectedOptions, selectedVariant } = this.state; - const product = item.product; + const { product } = item; const price = helper.formatCurrency(item.price, settings); const priceTotal = helper.formatCurrency(item.price_total, settings); const discountTotal = helper.formatCurrency(item.discount_total, settings); - const imageUrl = product && product.images && product.images.length > 0 ? product.images[0].url : null; + const imageUrl = + product && product.images && product.images.length > 0 + ? product.images[0].url + : null; const thumbnailUrl = helper.getThumbnailUrl(imageUrl, 100); const productOptions = product ? product.options : []; @@ -225,13 +223,13 @@ export class OrderItem extends React.Component { return (
-
+
{thumbnailUrl && thumbnailUrl !== '' && ( )}
-
+
{item.name}
{item.variant_name}
@@ -282,7 +280,7 @@ export class OrderItem extends React.Component { /> diff --git a/src/modules/orders/edit/components/shippingAddressForm.js b/src/modules/orders/edit/components/shippingAddressForm.js index 00978266..b1537a83 100644 --- a/src/modules/orders/edit/components/shippingAddressForm.js +++ b/src/modules/orders/edit/components/shippingAddressForm.js @@ -5,10 +5,10 @@ import { TextField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import * as helper from 'lib/helper'; import messages from 'lib/text'; -import style from './style.css'; import Divider from 'material-ui/Divider'; import FlatButton from 'material-ui/FlatButton'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -23,15 +23,12 @@ const validate = values => { return errors; }; -const getShippingFieldLabel = ({ label, key }) => { - return label && label.length > 0 - ? label - : helper.getOrderFieldLabelByKey(key); -}; +const getShippingFieldLabel = ({ label, key }) => + label && label.length > 0 ? label : helper.getOrderFieldLabelByKey(key); class ShippingAddressForm extends React.Component { render() { - let { + const { handleSubmit, pristine, submitting, @@ -53,7 +50,7 @@ class ShippingAddressForm extends React.Component { @@ -67,7 +64,7 @@ class ShippingAddressForm extends React.Component { {shippingFields} @@ -75,7 +72,7 @@ class ShippingAddressForm extends React.Component {
@@ -83,7 +80,7 @@ class ShippingAddressForm extends React.Component {
@@ -91,7 +88,7 @@ class ShippingAddressForm extends React.Component {
@@ -100,7 +97,7 @@ class ShippingAddressForm extends React.Component { { - let states = []; + const states = []; if (order.hold) { states.push( @@ -117,63 +117,63 @@ export default class OrderSummary extends React.Component {
{states}
-
+
{messages.orderDate}
{dateCreatedFormated}
-
+
{messages.orderStatus}
{order.status}
-
+
{messages.referrer}
{referrerLink}
-
+
{messages.trackingNumber}
{order.tracking_number}
-
+
{messages.shippingStatus}
{order.shipping_status}
-
+
{messages.shippingMethod}
{order.shipping_method}
-
+
{messages.paymentsMethod}
{order.payment_method}
-
+
{messages.customerComment}
{order.comments}
-
+
{messages.note}
@@ -191,7 +191,7 @@ export default class OrderSummary extends React.Component { {isDraft && ( @@ -203,7 +203,7 @@ export default class OrderSummary extends React.Component { modal={false} open={this.state.openSummaryEdit} onRequestClose={this.hideSummaryEdit} - autoScrollBodyContent={true} + autoScrollBodyContent contentStyle={{ width: 600 }} > { const errors = {}; @@ -58,7 +58,7 @@ class SummaryForm extends React.Component { }; render() { - let { + const { handleSubmit, pristine, submitting, @@ -91,7 +91,7 @@ class SummaryForm extends React.Component {
@@ -101,7 +101,7 @@ class SummaryForm extends React.Component {
@@ -109,7 +109,7 @@ class SummaryForm extends React.Component { @@ -118,7 +118,7 @@ class SummaryForm extends React.Component { @@ -128,7 +128,7 @@ class SummaryForm extends React.Component {
@@ -137,7 +137,7 @@ class SummaryForm extends React.Component {
@@ -146,7 +146,7 @@ class SummaryForm extends React.Component {
@@ -155,7 +155,7 @@ class SummaryForm extends React.Component {
@@ -165,7 +165,7 @@ class SummaryForm extends React.Component { { const discountTotal = helper.formatCurrency(order.discount_total, settings); @@ -25,7 +25,7 @@ const OrderTotals = ({ order, settings }) => { settings ); const shippingPrice = helper.formatCurrency(order.shipping_price, settings); - let discountsDescription = + const discountsDescription = order.coupon && order.coupon.length > 0 ? ` (${messages.coupon}: ${order.coupon})` : ''; @@ -40,25 +40,25 @@ const OrderTotals = ({ order, settings }) => { return (
-
+
{messages.orderSubtotal}
{subtotal}
-
+
{messages.orderShipping}
{shippingTotal}
-
+
{messages.orderTax}
{taxIncludedTotal}
-
+
{messages.orderDiscount} @@ -67,7 +67,7 @@ const OrderTotals = ({ order, settings }) => {
{discountTotal}
-
+
{messages.grandTotal}
{grandTotal}
@@ -79,7 +79,7 @@ const OrderTotals = ({ order, settings }) => { }} /> -
+
{messages.amountPaid}
diff --git a/src/modules/orders/editHead/components/buttons.js b/src/modules/orders/editHead/components/buttons.js index 1558d15f..e2f658f7 100644 --- a/src/modules/orders/editHead/components/buttons.js +++ b/src/modules/orders/editHead/components/buttons.js @@ -88,7 +88,7 @@ export default class Buttons extends React.Component { if (order) { const orderName = `${messages.order} #${order.number}`; - let menuItems = []; + const menuItems = []; if (order.closed) { // } else if (order.cancelled) { @@ -169,7 +169,7 @@ export default class Buttons extends React.Component { + more_vert @@ -195,8 +195,7 @@ export default class Buttons extends React.Component { ); - } else { - return ; } + return ; } } diff --git a/src/modules/orders/editHead/index.js b/src/modules/orders/editHead/index.js index 700bafa6..b1c51026 100644 --- a/src/modules/orders/editHead/index.js +++ b/src/modules/orders/editHead/index.js @@ -10,36 +10,32 @@ import { } from '../actions'; import Buttons from './components/buttons'; -const mapStateToProps = (state, ownProps) => { - return { - settings: state.settings.settings, - order: state.orders.editOrder - }; -}; +const mapStateToProps = (state, ownProps) => ({ + settings: state.settings.settings, + order: state.orders.editOrder +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onDelete: () => { - dispatch(deleteCurrentOrder()); - ownProps.history.push('/orders'); - }, - setCancelled: orderId => { - dispatch(cancelOrder(orderId)); - }, - holdOrder: orderId => { - dispatch(updateOrder({ id: orderId, hold: true })); - }, - resumeOrder: orderId => { - dispatch(updateOrder({ id: orderId, hold: false })); - }, - setClosed: orderId => { - dispatch(closeOrder(orderId)); - }, - addItem: (orderId, productId) => { - dispatch(addOrderItem(orderId, productId)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onDelete: () => { + dispatch(deleteCurrentOrder()); + ownProps.history.push('/orders'); + }, + setCancelled: orderId => { + dispatch(cancelOrder(orderId)); + }, + holdOrder: orderId => { + dispatch(updateOrder({ id: orderId, hold: true })); + }, + resumeOrder: orderId => { + dispatch(updateOrder({ id: orderId, hold: false })); + }, + setClosed: orderId => { + dispatch(closeOrder(orderId)); + }, + addItem: (orderId, productId) => { + dispatch(addOrderItem(orderId, productId)); + } +}); export default withRouter( connect( diff --git a/src/modules/orders/list/components/item.js b/src/modules/orders/list/components/item.js index d3b98c7c..ebda81cd 100644 --- a/src/modules/orders/list/components/item.js +++ b/src/modules/orders/list/components/item.js @@ -6,11 +6,11 @@ import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; import messages from 'lib/text'; import * as helper from 'lib/helper'; -import style from './style.css'; import moment from 'moment'; +import style from './style.css'; const getOrderStateIcons = order => { - let icons = []; + const icons = []; if (order.hold) { icons.push( @@ -95,17 +95,20 @@ const getOrderStateIcons = order => { const OrdersListItem = ({ order, onSelect, selected, settings }) => { const checked = selected.includes(order.id); - let grandTotalFormatted = helper.formatCurrency(order.grand_total, settings); + const grandTotalFormatted = helper.formatCurrency( + order.grand_total, + settings + ); const stateIcons = getOrderStateIcons(order); const dateCreated = moment(order.date_placed || order.date_created); const dateCreatedFromNow = dateCreated.format(`${settings.date_format}`); - let shippingTo = order.shipping_address + const shippingTo = order.shipping_address ? order.shipping_address.full_name : ''; return ( -
+
{
{shippingTo}
{order.shipping_method}
-
+
{grandTotalFormatted}
{order.payment_method}
-
{order.status}
+
{order.status}
} /> diff --git a/src/modules/orders/list/components/list.js b/src/modules/orders/list/components/list.js index ff6261ce..784d45cf 100644 --- a/src/modules/orders/list/components/list.js +++ b/src/modules/orders/list/components/list.js @@ -1,11 +1,11 @@ import React from 'react'; import { List } from 'material-ui/List'; import Divider from 'material-ui/Divider'; -import Head from './head'; -import OrdersListItem from './item'; import RaisedButton from 'material-ui/RaisedButton'; import FontIcon from 'material-ui/FontIcon'; import messages from 'lib/text'; +import OrdersListItem from './item'; +import Head from './head'; import style from './style.css'; export default class OrdersList extends React.Component { diff --git a/src/modules/orders/list/index.js b/src/modules/orders/list/index.js index 41cf2e98..c7fd7506 100644 --- a/src/modules/orders/list/index.js +++ b/src/modules/orders/list/index.js @@ -10,40 +10,36 @@ import { } from '../actions'; import List from './components/list'; -const mapStateToProps = (state, ownProps) => { - return { - settings: state.settings.settings, - items: state.orders.items, - selected: state.orders.selected, - loadingItems: state.orders.loadingItems, - hasMore: state.orders.hasMore - }; -}; +const mapStateToProps = (state, ownProps) => ({ + settings: state.settings.settings, + items: state.orders.items, + selected: state.orders.selected, + loadingItems: state.orders.loadingItems, + hasMore: state.orders.hasMore +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - dispatch(fetchOrders()); - }, - onSelect: (orderId, checked) => { - if (checked) { - dispatch(selectOrder(orderId)); - } else { - dispatch(deselectOrder(orderId)); - } - }, - onSelectAll: checked => { - if (checked) { - dispatch(selectAllOrder()); - } else { - dispatch(deselectAllOrder()); - } - }, - loadMore: () => { - dispatch(fetchMoreOrders()); +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + dispatch(fetchOrders()); + }, + onSelect: (orderId, checked) => { + if (checked) { + dispatch(selectOrder(orderId)); + } else { + dispatch(deselectOrder(orderId)); } - }; -}; + }, + onSelectAll: checked => { + if (checked) { + dispatch(selectAllOrder()); + } else { + dispatch(deselectAllOrder()); + } + }, + loadMore: () => { + dispatch(fetchMoreOrders()); + } +}); export default withRouter( connect( diff --git a/src/modules/orders/listHead/components/buttons.js b/src/modules/orders/listHead/components/buttons.js index 6b262308..8d6e4220 100644 --- a/src/modules/orders/listHead/components/buttons.js +++ b/src/modules/orders/listHead/components/buttons.js @@ -6,7 +6,7 @@ import IconButton from 'material-ui/IconButton'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; import Search from './search'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -38,7 +38,7 @@ export default class Buttons extends React.Component { {selectedCount > 0 && ( )} { - return ( - { - setSearch(v); - }} - hintText={messages.orders_search} - underlineShow={false} - hintStyle={{ color: 'rgba(255,255,255,0.4)', textIndent: '16px' }} - inputStyle={{ - color: '#fff', - backgroundColor: 'rgba(255,255,255,0.2)', - borderRadius: '4px', - textIndent: '16px' - }} - /> - ); -}; +export default ({ value, setSearch }) => ( + { + setSearch(v); + }} + hintText={messages.orders_search} + underlineShow={false} + hintStyle={{ color: 'rgba(255,255,255,0.4)', textIndent: '16px' }} + inputStyle={{ + color: '#fff', + backgroundColor: 'rgba(255,255,255,0.2)', + borderRadius: '4px', + textIndent: '16px' + }} + /> +); diff --git a/src/modules/orders/listHead/index.js b/src/modules/orders/listHead/index.js index f2d9983f..d1a93dd1 100644 --- a/src/modules/orders/listHead/index.js +++ b/src/modules/orders/listHead/index.js @@ -4,27 +4,23 @@ import { withRouter } from 'react-router'; import { fetchOrders, setFilter, deleteOrders, createOrder } from '../actions'; import Buttons from './components/buttons'; -const mapStateToProps = (state, ownProps) => { - return { - search: state.orders.filter.search, - selectedCount: state.orders.selected.length - }; -}; +const mapStateToProps = (state, ownProps) => ({ + search: state.orders.filter.search, + selectedCount: state.orders.selected.length +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - setSearch: value => { - dispatch(setFilter({ search: value })); - dispatch(fetchOrders()); - }, - onDelete: () => { - dispatch(deleteOrders()); - }, - onCreate: () => { - dispatch(createOrder(ownProps.history)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + setSearch: value => { + dispatch(setFilter({ search: value })); + dispatch(fetchOrders()); + }, + onDelete: () => { + dispatch(deleteOrders()); + }, + onCreate: () => { + dispatch(createOrder(ownProps.history)); + } +}); export default withRouter( connect( diff --git a/src/modules/pages/actions.js b/src/modules/pages/actions.js index e4ea3d22..383a974f 100644 --- a/src/modules/pages/actions.js +++ b/src/modules/pages/actions.js @@ -1,6 +1,6 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; +import * as t from './actionTypes'; function receivePages(pages) { return { @@ -17,56 +17,51 @@ export function receivePage(pageEdit) { } export function fetchPages() { - return (dispatch, getState) => { - return api.pages + return (dispatch, getState) => + api.pages .list() .then(({ status, json }) => { dispatch(receivePages(json)); }) .catch(error => {}); - }; } export function fetchPage(id) { - return (dispatch, getState) => { - return api.pages + return (dispatch, getState) => + api.pages .retrieve(id) .then(({ status, json }) => { dispatch(receivePage(json)); }) .catch(error => {}); - }; } export function createPage(page) { - return (dispatch, getState) => { - return api.pages + return (dispatch, getState) => + api.pages .create(page) .then(({ status, json }) => { dispatch(fetchPages()); }) .catch(error => {}); - }; } export function updatePage(page) { - return (dispatch, getState) => { - return api.pages + return (dispatch, getState) => + api.pages .update(page.id, page) .then(({ status, json }) => { dispatch(receivePage(json)); }) .catch(error => {}); - }; } export function deletePage(pageId) { - return (dispatch, getState) => { - return api.pages + return (dispatch, getState) => + api.pages .delete(pageId) .then(({ status, json }) => { dispatch(fetchPages()); }) .catch(error => {}); - }; } diff --git a/src/modules/pages/edit/components/form.js b/src/modules/pages/edit/components/form.js index b4b4250d..4cbaa711 100644 --- a/src/modules/pages/edit/components/form.js +++ b/src/modules/pages/edit/components/form.js @@ -6,11 +6,11 @@ import { CustomToggle } from 'modules/shared/form'; import Editor from 'modules/shared/editor'; import TagsInput from 'react-tagsinput'; import messages from 'lib/text'; -import style from './style.css'; import api from 'lib/api'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const TagsField = ({ input, placeholder }) => { const tagsArray = @@ -18,7 +18,7 @@ const TagsField = ({ input, placeholder }) => { return ( { input.onChange(tags); }} @@ -39,25 +39,22 @@ const validate = values => { return errors; }; -const asyncValidate = (values /*, dispatch */) => { - return new Promise((resolve, reject) => { +const asyncValidate = (values /* , dispatch */) => + new Promise((resolve, reject) => { if (!values.slug && values.is_system) { resolve(); } else { api.sitemap.retrieve({ path: values.slug }).then(({ status, json }) => { if (status === 404) { resolve(); + } else if (json && !Object.is(json.resource, values.id)) { + reject({ slug: messages.errors_urlTaken }); } else { - if (json && !Object.is(json.resource, values.id)) { - reject({ slug: messages.errors_urlTaken }); - } else { - resolve(); - } + resolve(); } }); } }); -}; class EditPageForm extends React.Component { componentDidMount() { @@ -69,7 +66,7 @@ class EditPageForm extends React.Component { } render() { - let { + const { handleSubmit, pristine, submitting, @@ -87,14 +84,14 @@ class EditPageForm extends React.Component { name="meta_title" component={TextField} floatingLabelText={messages.pageTitle} - fullWidth={true} + fullWidth />

{messages.help_slug}

@@ -102,7 +99,7 @@ class EditPageForm extends React.Component { name="meta_description" component={TextField} floatingLabelText={messages.metaDescription} - fullWidth={true} + fullWidth />
{messages.content} @@ -127,17 +124,14 @@ class EditPageForm extends React.Component {
@@ -145,9 +139,8 @@ class EditPageForm extends React.Component { ); - } else { - return null; } + return null; } } diff --git a/src/modules/pages/edit/components/headButtons.js b/src/modules/pages/edit/components/headButtons.js index b98b7b2e..48bd9760 100644 --- a/src/modules/pages/edit/components/headButtons.js +++ b/src/modules/pages/edit/components/headButtons.js @@ -5,7 +5,7 @@ import DeleteConfirmation from 'modules/shared/deleteConfirmation'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; import FlatButton from 'material-ui/FlatButton'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -39,7 +39,7 @@ export default class Buttons extends React.Component { return ( @@ -63,7 +63,7 @@ export default class Buttons extends React.Component { )} ); - } else { - return null; } + return null; } } diff --git a/src/modules/pages/edit/head.js b/src/modules/pages/edit/head.js index dc34292e..effd0384 100644 --- a/src/modules/pages/edit/head.js +++ b/src/modules/pages/edit/head.js @@ -3,20 +3,16 @@ import { withRouter } from 'react-router'; import { deletePage } from '../actions'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return { - page: state.pages.pageEdit - }; -}; +const mapStateToProps = (state, ownProps) => ({ + page: state.pages.pageEdit +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onDelete: id => { - dispatch(deletePage(id)); - ownProps.history.push('/pages'); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onDelete: id => { + dispatch(deletePage(id)); + ownProps.history.push('/pages'); + } +}); export default withRouter( connect( diff --git a/src/modules/pages/edit/index.js b/src/modules/pages/edit/index.js index 794e7e70..7f62b396 100644 --- a/src/modules/pages/edit/index.js +++ b/src/modules/pages/edit/index.js @@ -5,34 +5,32 @@ import Form from './components/form'; const mapStateToProps = (state, ownProps) => { const { pageId } = ownProps.match.params; return { - pageId: pageId, + pageId, initialValues: state.pages.pageEdit }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - const { pageId } = ownProps.match.params; - if (pageId) { - dispatch(fetchPage(pageId)); - } else { - dispatch(receivePage({ enabled: true })); - } - }, - onSubmit: page => { - if (page.id) { - dispatch(updatePage(page)); - } else { - dispatch(createPage(page)); - ownProps.history.push('/pages'); - } - }, - eraseData: () => { - dispatch(receivePage(null)); +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + const { pageId } = ownProps.match.params; + if (pageId) { + dispatch(fetchPage(pageId)); + } else { + dispatch(receivePage({ enabled: true })); } - }; -}; + }, + onSubmit: page => { + if (page.id) { + dispatch(updatePage(page)); + } else { + dispatch(createPage(page)); + ownProps.history.push('/pages'); + } + }, + eraseData: () => { + dispatch(receivePage(null)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/pages/list/components/form.js b/src/modules/pages/list/components/form.js index fd955cd3..0472ed73 100644 --- a/src/modules/pages/list/components/form.js +++ b/src/modules/pages/list/components/form.js @@ -44,7 +44,7 @@ export default class PagesList extends React.Component { render() { const { pages } = this.props; - let listItems = pages.map((page, index) => ( + const listItems = pages.map((page, index) => ( )); diff --git a/src/modules/pages/list/components/headButtons.js b/src/modules/pages/list/components/headButtons.js index 748bf747..395c6b1e 100644 --- a/src/modules/pages/list/components/headButtons.js +++ b/src/modules/pages/list/components/headButtons.js @@ -8,7 +8,7 @@ const Buttons = () => ( diff --git a/src/modules/pages/list/head.js b/src/modules/pages/list/head.js index 84e82ab9..d5ba9460 100644 --- a/src/modules/pages/list/head.js +++ b/src/modules/pages/list/head.js @@ -2,13 +2,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return {}; -}; +const mapStateToProps = (state, ownProps) => ({}); -const mapDispatchToProps = (dispatch, ownProps) => { - return {}; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({}); export default withRouter( connect( diff --git a/src/modules/pages/list/index.js b/src/modules/pages/list/index.js index 5c032ae1..ddf76ac6 100644 --- a/src/modules/pages/list/index.js +++ b/src/modules/pages/list/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchPages } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - pages: state.pages.pages - }; -}; +const mapStateToProps = state => ({ + pages: state.pages.pages +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchPages()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchPages()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/productCategories/actions.js b/src/modules/productCategories/actions.js index 19d67ece..912a87a8 100644 --- a/src/modules/productCategories/actions.js +++ b/src/modules/productCategories/actions.js @@ -1,6 +1,6 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; +import * as t from './actionTypes'; function requestCategories() { return { @@ -115,9 +115,8 @@ function shouldFetchCategories(state) { const categories = state.productCategories; if (categories.isFetched || categories.isFetching) { return false; - } else { - return true; } + return true; } export function fetchCategoriesIfNeeded() { @@ -144,14 +143,12 @@ function sendUpdateCategory(id, data) { } export function updateCategory(data) { - return (dispatch, getState) => { - return dispatch(sendUpdateCategory(data.id, data)); - }; + return (dispatch, getState) => dispatch(sendUpdateCategory(data.id, data)); } export function createCategory() { - return (dispatch, getState) => { - return api.productCategories + return (dispatch, getState) => + api.productCategories .create({ enabled: false }) .then(({ status, json }) => { dispatch(successCreateCategory(json.id)); @@ -159,10 +156,9 @@ export function createCategory() { dispatch(selectCategory(json.id)); }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); - }; } export function deleteImage() { @@ -180,15 +176,15 @@ export function deleteImage() { } }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); }; } export function deleteCategory(id) { - return (dispatch, getState) => { - return api.productCategories + return (dispatch, getState) => + api.productCategories .delete(id) .then(({ status, json }) => { if (status === 200) { @@ -200,10 +196,9 @@ export function deleteCategory(id) { } }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); - }; } function moveCategory(allCategories = [], selectedCategory, isUp = true) { @@ -229,8 +224,8 @@ function moveCategory(allCategories = [], selectedCategory, isUp = true) { } if (allCategories.length > 0) { - let targetCategory = allCategories[0]; - let newPosition = targetCategory.position; + const targetCategory = allCategories[0]; + const newPosition = targetCategory.position; api.productCategories .update(selectedCategory.id, { position: targetCategory.position }) @@ -253,13 +248,13 @@ function moveCategory(allCategories = [], selectedCategory, isUp = true) { export function moveUpCategory() { return (dispatch, getState) => { - let state = getState(); - var allCategories = state.productCategories.items; - var selectedCategory = allCategories.find( + const state = getState(); + const allCategories = state.productCategories.items; + const selectedCategory = allCategories.find( item => item.id === state.productCategories.selectedId ); - var isUp = true; + const isUp = true; return moveCategory(allCategories, selectedCategory, isUp).then( newPosition => { @@ -272,12 +267,12 @@ export function moveUpCategory() { export function moveDownCategory() { return (dispatch, getState) => { - let state = getState(); - var allCategories = state.productCategories.items; - var selectedCategory = allCategories.find( + const state = getState(); + const allCategories = state.productCategories.items; + const selectedCategory = allCategories.find( item => item.id === state.productCategories.selectedId ); - var isUp = false; + const isUp = false; return moveCategory(allCategories, selectedCategory, isUp).then( newPosition => { @@ -290,8 +285,8 @@ export function moveDownCategory() { export function replaceCategory(parentId) { return (dispatch, getState) => { - let state = getState(); - var selectedCategory = state.productCategories.items.find( + const state = getState(); + const selectedCategory = state.productCategories.items.find( item => item.id === state.productCategories.selectedId ); @@ -302,7 +297,7 @@ export function replaceCategory(parentId) { dispatch(fetchCategories()); }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); }; diff --git a/src/modules/productCategories/components/list.js b/src/modules/productCategories/components/list.js index fc76e7d5..1ee51e60 100644 --- a/src/modules/productCategories/components/list.js +++ b/src/modules/productCategories/components/list.js @@ -76,9 +76,8 @@ export default class Categories extends React.Component { return allItems .filter(item => item.parent_id === id) .map(item => this.getItem(selectedId, allItems, item, opened)); - } else { - return []; } + return []; } handleClickAll = () => { @@ -101,7 +100,7 @@ export default class Categories extends React.Component { opened = false } = this.props; - var rows = items + const rows = items .filter(item => item.parent_id === null) .map(item => this.getItem(selectedId, items, item, opened)); @@ -110,7 +109,7 @@ export default class Categories extends React.Component { {showRoot && ( home} onClick={this.handleClickRoot} @@ -121,7 +120,7 @@ export default class Categories extends React.Component { folder} onClick={this.handleClickAll} diff --git a/src/modules/productCategories/components/multiselectList.js b/src/modules/productCategories/components/multiselectList.js index e324edda..de11003c 100644 --- a/src/modules/productCategories/components/multiselectList.js +++ b/src/modules/productCategories/components/multiselectList.js @@ -79,9 +79,8 @@ export default class Categories extends React.Component { return allItems .filter(item => item.parent_id === id) .map(item => this.getItem(selectedIds, allItems, item, opened)); - } else { - return []; } + return []; } render() { diff --git a/src/modules/productCategories/edit/components/form.js b/src/modules/productCategories/edit/components/form.js index 16a64a8f..bea43e13 100644 --- a/src/modules/productCategories/edit/components/form.js +++ b/src/modules/productCategories/edit/components/form.js @@ -6,13 +6,13 @@ import Editor from 'modules/shared/editor'; import { CustomToggle } from 'modules/shared/form'; import ImageUpload from 'modules/shared/imageUpload'; import messages from 'lib/text'; -import style from './style.css'; import settings from 'lib/settings'; import api from 'lib/api'; import Paper from 'material-ui/Paper'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -27,27 +27,24 @@ const validate = values => { return errors; }; -const asyncValidate = values => { - return new Promise((resolve, reject) => { +const asyncValidate = values => + new Promise((resolve, reject) => { if (values.slug && values.slug.length > 0) { api.sitemap - .retrieve({ path: '/' + values.slug }) + .retrieve({ path: `/${values.slug}` }) .then(({ status, json }) => { if (status === 404) { resolve(); + } else if (json && !Object.is(json.resource, values.id)) { + reject({ slug: messages.errors_urlTaken }); } else { - if (json && !Object.is(json.resource, values.id)) { - reject({ slug: messages.errors_urlTaken }); - } else { - resolve(); - } + resolve(); } }); } else { resolve(); } }); -}; const ProductCategoryEditForm = ({ uploadingImage, @@ -76,8 +73,8 @@ const ProductCategoryEditForm = ({
{messages.description} @@ -106,27 +103,26 @@ const ProductCategoryEditForm = ({ name="slug" component={TextField} floatingLabelText={messages.slug} - fullWidth={true} + fullWidth />

{messages.help_slug}

@@ -145,9 +141,8 @@ const ProductCategoryEditForm = ({ ); - } else { - return null; } + return null; }; export default reduxForm({ diff --git a/src/modules/productCategories/edit/index.js b/src/modules/productCategories/edit/index.js index 7c23a069..05380610 100644 --- a/src/modules/productCategories/edit/index.js +++ b/src/modules/productCategories/edit/index.js @@ -8,35 +8,31 @@ import { } from '../actions'; import ProductCategoryEditForm from './components/form'; -const mapStateToProps = state => { - return { - uploadingImage: state.productCategories.uploadingImage, - categoryId: state.productCategories.selectedId, - items: state.productCategories.items, - initialValues: state.productCategories.items.find( - item => item.id === state.productCategories.selectedId - ), - isSaving: state.productCategories.isSaving - }; -}; +const mapStateToProps = state => ({ + uploadingImage: state.productCategories.uploadingImage, + categoryId: state.productCategories.selectedId, + items: state.productCategories.items, + initialValues: state.productCategories.items.find( + item => item.id === state.productCategories.selectedId + ), + isSaving: state.productCategories.isSaving +}); -const mapDispatchToProps = dispatch => { - return { - onImageDelete: () => { - dispatch(deleteImage()); - }, - onImageUpload: form => { - dispatch(uploadImage(form)); - }, - onSubmit: values => { - delete values.image; - if (!values.slug || values.slug === '') { - values.slug = values.name; - } - dispatch(updateCategory(values)); +const mapDispatchToProps = dispatch => ({ + onImageDelete: () => { + dispatch(deleteImage()); + }, + onImageUpload: form => { + dispatch(uploadImage(form)); + }, + onSubmit: values => { + delete values.image; + if (!values.slug || values.slug === '') { + values.slug = values.name; } - }; -}; + dispatch(updateCategory(values)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/productCategories/head/components/buttons.js b/src/modules/productCategories/head/components/buttons.js index 9a5b8b78..1ba17b1b 100644 --- a/src/modules/productCategories/head/components/buttons.js +++ b/src/modules/productCategories/head/components/buttons.js @@ -9,7 +9,7 @@ import MenuItem from 'material-ui/MenuItem'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -66,8 +66,8 @@ export default class Buttons extends React.Component { />, ]; @@ -77,7 +77,7 @@ export default class Buttons extends React.Component { {selected && ( )} { - return { - selected: state.productCategories.items.find( - item => item.id === state.productCategories.selectedId - ) - }; -}; +const mapStateToProps = state => ({ + selected: state.productCategories.items.find( + item => item.id === state.productCategories.selectedId + ) +}); -const mapDispatchToProps = dispatch => { - return { - onMoveUp: () => { - dispatch(moveUpCategory()); - }, - onMoveDown: () => { - dispatch(moveDownCategory()); - }, - onDelete: id => { - dispatch(deleteCategory(id)); - dispatch(reset('FormProductCategory')); - }, - onMoveTo: id => { - dispatch(replaceCategory(id)); - dispatch(reset('FormProductCategory')); - }, - onCreate: () => { - dispatch(createCategory()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onMoveUp: () => { + dispatch(moveUpCategory()); + }, + onMoveDown: () => { + dispatch(moveDownCategory()); + }, + onDelete: id => { + dispatch(deleteCategory(id)); + dispatch(reset('FormProductCategory')); + }, + onMoveTo: id => { + dispatch(replaceCategory(id)); + dispatch(reset('FormProductCategory')); + }, + onCreate: () => { + dispatch(createCategory()); + } +}); export default withRouter( connect( diff --git a/src/modules/productCategories/list/index.js b/src/modules/productCategories/list/index.js index 1081807c..7e5703d2 100644 --- a/src/modules/productCategories/list/index.js +++ b/src/modules/productCategories/list/index.js @@ -3,27 +3,23 @@ import { selectCategory, fetchCategoriesIfNeeded } from '../actions'; import { fetchProducts } from '../../products/actions'; import List from '../components/list'; -const mapStateToProps = state => { - return { - items: state.productCategories.items, - selectedId: state.productCategories.selectedId - }; -}; +const mapStateToProps = state => ({ + items: state.productCategories.items, + selectedId: state.productCategories.selectedId +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchCategoriesIfNeeded()); - }, - onSelect: categoryId => { - dispatch(selectCategory(categoryId)); - dispatch(fetchProducts()); - }, - onCreate: () => { - dispatch(createCategory()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchCategoriesIfNeeded()); + }, + onSelect: categoryId => { + dispatch(selectCategory(categoryId)); + dispatch(fetchProducts()); + }, + onCreate: () => { + dispatch(createCategory()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/productCategories/select/index.js b/src/modules/productCategories/select/index.js index 32dfc26a..2c5a812f 100644 --- a/src/modules/productCategories/select/index.js +++ b/src/modules/productCategories/select/index.js @@ -6,19 +6,15 @@ import { } from '../actions'; import List from '../components/list'; -const mapStateToProps = state => { - return { - items: state.productCategories.items - }; -}; +const mapStateToProps = state => ({ + items: state.productCategories.items +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchCategoriesIfNeeded()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchCategoriesIfNeeded()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/products/actions.js b/src/modules/products/actions.js index 1d03371b..b5e67ec7 100644 --- a/src/modules/products/actions.js +++ b/src/modules/products/actions.js @@ -1,7 +1,7 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; import moment from 'moment'; +import * as t from './actionTypes'; function requestProduct() { return { @@ -116,7 +116,7 @@ export function selectAllProduct() { export function setFilter(filter) { return { type: t.PRODUCTS_SET_FILTER, - filter: filter + filter }; } @@ -174,12 +174,12 @@ const getFilter = (state, offset = 0) => { const searchTerm = state.products.filter.search; const sortOrder = searchTerm && searchTerm.length > 0 ? 'search' : 'name'; - let filter = { + const filter = { limit: 50, fields: 'id,name,category_id,category_ids,category_name,sku,images,enabled,discontinued,stock_status,stock_quantity,price,on_sale,regular_price,url', search: searchTerm, - offset: offset, + offset, sort: sortOrder }; @@ -218,7 +218,7 @@ export function fetchProducts() { dispatch(requestProducts()); dispatch(deselectAllProduct()); - let filter = getFilter(state); + const filter = getFilter(state); return api.products .list(filter) @@ -239,7 +239,7 @@ export function fetchMoreProducts() { dispatch(requestMoreProducts()); const offset = state.products.items.length; - let filter = getFilter(state, offset); + const filter = getFilter(state, offset); return api.products .list(filter) @@ -256,7 +256,7 @@ export function fetchMoreProducts() { export function deleteCurrentProduct() { return (dispatch, getState) => { const state = getState(); - let product = state.products.editProduct; + const product = state.products.editProduct; if (product && product.id) { return api.products .delete(product.id) @@ -271,7 +271,7 @@ export function deleteCurrentProduct() { export function deleteProducts() { return (dispatch, getState) => { const state = getState(); - let promises = state.products.selected.map(productId => + const promises = state.products.selected.map(productId => api.products.delete(productId) ); @@ -290,8 +290,8 @@ export function deleteProducts() { export function setCategory(category_id) { return (dispatch, getState) => { const state = getState(); - let promises = state.products.selected.map(productId => - api.products.update(productId, { category_id: category_id }) + const promises = state.products.selected.map(productId => + api.products.update(productId, { category_id }) ); return Promise.all(promises) @@ -335,7 +335,7 @@ export function createProduct(history) { .create(productDraft) .then(({ status, json }) => { dispatch(successCreateProduct(json.id)); - history.push('/product/' + json.id); + history.push(`/product/${json.id}`); }) .catch(error => {}); }; @@ -372,36 +372,33 @@ export function fetchProduct(id) { } export function fetchImages(productId) { - return (dispatch, getState) => { - return api.products.images + return (dispatch, getState) => + api.products.images .list(productId) .then(({ status, json }) => { dispatch(receiveImages(json)); }) .catch(error => {}); - }; } export function fetchOptions(productId) { - return (dispatch, getState) => { - return api.products.options + return (dispatch, getState) => + api.products.options .list(productId) .then(({ status, json }) => { dispatch(receiveOptions(json)); }) .catch(error => {}); - }; } export function fetchVariants(productId) { - return (dispatch, getState) => { - return api.products.variants + return (dispatch, getState) => + api.products.variants .list(productId) .then(({ status, json }) => { dispatch(receiveVariants(json)); }) .catch(error => {}); - }; } export function createVariant(productId) { @@ -414,8 +411,8 @@ export function createVariant(productId) { } = state.products.editProduct; const variant = { price: regular_price, - stock_quantity: stock_quantity, - weight: weight + stock_quantity, + weight }; return api.products.variants @@ -428,14 +425,13 @@ export function createVariant(productId) { } export function updateVariant(productId, variantId, variant) { - return (dispatch, getState) => { - return api.products.variants + return (dispatch, getState) => + api.products.variants .update(productId, variantId, variant) .then(({ status, json }) => { dispatch(receiveVariants(json)); }) .catch(error => {}); - }; } export function setVariantOption(productId, variantId, optionId, valueId) { @@ -451,107 +447,98 @@ export function setVariantOption(productId, variantId, optionId, valueId) { } export function createOptionValue(productId, optionId, valueName) { - return (dispatch, getState) => { - return api.products.options.values + return (dispatch, getState) => + api.products.options.values .create(productId, optionId, { name: valueName }) .then(({ status, json }) => { dispatch(fetchOptions(productId)); }) .catch(error => {}); - }; } export function createOption(productId, option) { - return (dispatch, getState) => { - return api.products.options + return (dispatch, getState) => + api.products.options .create(productId, option) .then(({ status, json }) => { dispatch(receiveOptions(json)); }) .catch(error => {}); - }; } export function updateOptionValue(productId, optionId, valueId, valueName) { - return (dispatch, getState) => { - return api.products.options.values + return (dispatch, getState) => + api.products.options.values .update(productId, optionId, valueId, { name: valueName }) .then(({ status, json }) => { dispatch(fetchOptions(productId)); }) .catch(error => {}); - }; } export function updateOption(productId, optionId, option) { - return (dispatch, getState) => { - return api.products.options + return (dispatch, getState) => + api.products.options .update(productId, optionId, option) .then(({ status, json }) => { dispatch(receiveOptions(json)); }) .catch(error => {}); - }; } export function deleteOptionValue(productId, optionId, valueId) { - return (dispatch, getState) => { - return api.products.options.values + return (dispatch, getState) => + api.products.options.values .delete(productId, optionId, valueId) .then(({ status, json }) => { dispatch(fetchOptions(productId)); }) .catch(error => {}); - }; } export function deleteOption(productId, optionId) { - return (dispatch, getState) => { - return api.products.options + return (dispatch, getState) => + api.products.options .delete(productId, optionId) .then(({ status, json }) => { dispatch(receiveOptions(json)); }) .catch(error => {}); - }; } export function deleteVariant(productId, variantId) { - return (dispatch, getState) => { - return api.products.variants + return (dispatch, getState) => + api.products.variants .delete(productId, variantId) .then(({ status, json }) => { dispatch(receiveVariants(json)); }) .catch(error => {}); - }; } export function deleteImage(productId, imageId) { - return (dispatch, getState) => { - return api.products.images + return (dispatch, getState) => + api.products.images .delete(productId, imageId) .then(({ status, json }) => { dispatch(fetchImages(productId)); }) .catch(error => {}); - }; } export function updateImage(productId, image) { - return (dispatch, getState) => { - return api.products.images + return (dispatch, getState) => + api.products.images .update(productId, image.id, image) .then(() => { dispatch(fetchImages(productId)); }) .catch(error => {}); - }; } export function updateImages(productId, images) { return (dispatch, getState) => { - let promises = images.map(image => + const promises = images.map(image => api.products.images.update(productId, image.id, image) ); diff --git a/src/modules/products/edit/additional/components/form.js b/src/modules/products/edit/additional/components/form.js index a6c8e4bb..cde66535 100644 --- a/src/modules/products/edit/additional/components/form.js +++ b/src/modules/products/edit/additional/components/form.js @@ -6,12 +6,9 @@ import { TextField } from 'redux-form-material-ui'; import api from 'lib/api'; import * as helper from 'lib/helper'; import messages from 'lib/text'; -import style from './style.css'; import TagsInput from 'react-tagsinput'; import ProductSearchDialog from 'modules/shared/productSearch'; -import ProductCategorySelect from './productCategorySelect'; -import ProductCategoryMultiSelect from './productCategoryMultiSelect'; import Paper from 'material-ui/Paper'; import FontIcon from 'material-ui/FontIcon'; @@ -20,7 +17,10 @@ import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; import IconMenu from 'material-ui/IconMenu'; import MenuItem from 'material-ui/MenuItem'; -const Fragment = React.Fragment; +import ProductCategoryMultiSelect from './productCategoryMultiSelect'; +import ProductCategorySelect from './productCategorySelect'; +import style from './style.css'; +const { Fragment } = React; const TagsField = ({ input, placeholder }) => { const tagsArray = @@ -28,7 +28,7 @@ const TagsField = ({ input, placeholder }) => { return ( { input.onChange(tags); }} @@ -49,7 +49,7 @@ const ProductShort = ({ className={ style.relatedProduct + (enabled === false || discontinued === true - ? ' ' + style.relatedProductDisabled + ? ` ${style.relatedProductDisabled}` : '') } > @@ -70,7 +70,7 @@ const RelatedProductActions = ({ fields, index }) => ( targetOrigin={{ horizontal: 'right', vertical: 'top' }} anchorOrigin={{ horizontal: 'right', vertical: 'top' }} iconButtonElement={ - + more_vert @@ -113,18 +113,17 @@ const RelatedProduct = ({ settings, product, actions }) => { actions={actions} /> ); - } else { - // product doesn't exist - return ( - - ); } + // product doesn't exist + return ( + + ); }; class ProductsArray extends React.Component { @@ -170,7 +169,7 @@ class ProductsArray extends React.Component { limit: 50, fields: 'id,name,enabled,discontinued,price,on_sale,regular_price,images', - ids: ids + ids }) .then(productsResponse => { this.setState({ products: productsResponse.json.data }); @@ -239,111 +238,108 @@ const ProductAdditionalForm = ({ initialValues, settings, categories -}) => { - return ( -
- -
-
-
{messages.category}
-
- -
+}) => ( + + +
+
+
{messages.category}
+
+
+
-
-
- {messages.additionalCategories} -
-
- -
+
+
+ {messages.additionalCategories}
- -
-
{messages.tags}
-
- -
+
+
+
-
-
{messages.position}
-
- -
+
+
{messages.tags}
+
+
- - {messages.relatedProducts} -
+
- - +
{messages.position}
+
+ +
- - - ); -}; + + {messages.relatedProducts} + +
+
+ + +
+ + +); export default reduxForm({ form: 'ProductAdditionalForm', diff --git a/src/modules/products/edit/additional/components/productCategoryMultiSelect.js b/src/modules/products/edit/additional/components/productCategoryMultiSelect.js index a8299380..afccfcad 100644 --- a/src/modules/products/edit/additional/components/productCategoryMultiSelect.js +++ b/src/modules/products/edit/additional/components/productCategoryMultiSelect.js @@ -1,13 +1,13 @@ import React from 'react'; import { Field, FieldArray, reduxForm } from 'redux-form'; import messages from 'lib/text'; -import style from './style.css'; import CategoryMultiselect from 'modules/productCategories/components/multiselectList'; import FontIcon from 'material-ui/FontIcon'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; -const Fragment = React.Fragment; +import style from './style.css'; +const { Fragment } = React; const CategoryItemActions = ({ fields, index }) => ( { if (fields.get(index) === categoryId) { fields.remove(index); - return; } }); } else { @@ -73,8 +72,8 @@ export default class ProductCategoryMultiSelect extends React.Component { />, ]; @@ -103,7 +102,7 @@ export default class ProductCategoryMultiSelect extends React.Component { modal={false} open={open} onRequestClose={this.close} - autoScrollBodyContent={true} + autoScrollBodyContent > , ]; @@ -62,7 +62,7 @@ export default class ProductCategorySelect extends React.Component { modal={false} open={open} onRequestClose={this.close} - autoScrollBodyContent={true} + autoScrollBodyContent > { - return { - initialValues: state.products.editProduct, - settings: state.settings.settings, - categories: state.productCategories.items - }; -}; +const mapStateToProps = (state, ownProps) => ({ + initialValues: state.products.editProduct, + settings: state.settings.settings, + categories: state.productCategories.items +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onSubmit: values => { - dispatch( - updateProduct({ - id: values.id, - tags: values.tags, - position: values.position, - related_product_ids: values.related_product_ids, - category_id: values.category_id, - category_ids: values.category_ids - }) - ); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onSubmit: values => { + dispatch( + updateProduct({ + id: values.id, + tags: values.tags, + position: values.position, + related_product_ids: values.related_product_ids, + category_id: values.category_id, + category_ids: values.category_ids + }) + ); + } +}); export default withRouter( connect( diff --git a/src/modules/products/edit/attributes/components/form.js b/src/modules/products/edit/attributes/components/form.js index b8bfe05b..b9b820f4 100644 --- a/src/modules/products/edit/attributes/components/form.js +++ b/src/modules/products/edit/attributes/components/form.js @@ -2,81 +2,79 @@ import React from 'react'; import { Field, FieldArray, reduxForm } from 'redux-form'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; -const AttributesGrid = ({ fields, meta: { touched, error, submitFailed } }) => { - return ( -
-
-
- {messages.attributeName} -
-
- {messages.attributeValue} -
+const AttributesGrid = ({ fields, meta: { touched, error, submitFailed } }) => ( +
+
+
+ {messages.attributeName} +
+
+ {messages.attributeValue}
+
- {fields.map((field, index) => { - const fieldName = `${field}.name`; - const fieldValue = `${field}.value`; - return ( -
-
- -
-
- -
-
- fields.remove(index)} - tabIndex={-1} + {fields.map((field, index) => { + const fieldName = `${field}.name`; + const fieldValue = `${field}.value`; + return ( +
+
+ +
+
+ +
+
+ fields.remove(index)} + tabIndex={-1} + > + - - delete - - -
+ delete + +
- ); - })} +
+ ); + })} -
- fields.push({})} - /> -
+
+ fields.push({})} + />
- ); -}; +
+); const ProductAttributesForm = ({ handleSubmit, @@ -84,35 +82,32 @@ const ProductAttributesForm = ({ reset, submitting, initialValues -}) => { - return ( -
- - -
- - -
-
-
- ); -}; +}) => ( +
+ + +
+ + +
+
+
+); export default reduxForm({ form: 'ProductAttributesForm', diff --git a/src/modules/products/edit/attributes/index.js b/src/modules/products/edit/attributes/index.js index 6bffed64..8c786e77 100644 --- a/src/modules/products/edit/attributes/index.js +++ b/src/modules/products/edit/attributes/index.js @@ -3,24 +3,20 @@ import { withRouter } from 'react-router'; import { updateProduct } from '../../actions'; import ProductAttributesForm from './components/form'; -const mapStateToProps = (state, ownProps) => { - return { - initialValues: state.products.editProduct - }; -}; +const mapStateToProps = (state, ownProps) => ({ + initialValues: state.products.editProduct +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onSubmit: values => { - dispatch( - updateProduct({ - id: values.id, - attributes: values.attributes - }) - ); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onSubmit: values => { + dispatch( + updateProduct({ + id: values.id, + attributes: values.attributes + }) + ); + } +}); export default withRouter( connect( diff --git a/src/modules/products/edit/general/components/form.js b/src/modules/products/edit/general/components/form.js index f31740e0..a2dac66d 100644 --- a/src/modules/products/edit/general/components/form.js +++ b/src/modules/products/edit/general/components/form.js @@ -5,12 +5,12 @@ import { TextField } from 'redux-form-material-ui'; import Editor from 'modules/shared/editor'; import messages from 'lib/text'; -import style from './style.css'; import api from 'lib/api'; import Paper from 'material-ui/Paper'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -30,14 +30,13 @@ const slugExists = values => { return api.products .slugExists(values.id, values.slug) .then(response => response.status === 200); - } else { - return Promise.resolve(false); } + return Promise.resolve(false); }; -const asyncValidate = values => { - return Promise.all([slugExists(values)]).then(([isSlugExists]) => { - let errors = {}; +const asyncValidate = values => + Promise.all([slugExists(values)]).then(([isSlugExists]) => { + const errors = {}; if (isSlugExists) { errors.slug = messages.errors_urlTaken; @@ -45,11 +44,9 @@ const asyncValidate = values => { if (Object.keys(errors).length > 0) { return Promise.reject(errors); - } else { - return Promise.resolve(); } + return Promise.resolve(); }); -}; const ProductGeneralForm = ({ handleSubmit, @@ -66,27 +63,27 @@ const ProductGeneralForm = ({

{messages.help_slug}

{messages.description} @@ -94,10 +91,9 @@ const ProductGeneralForm = ({
@@ -116,9 +112,8 @@ const ProductGeneralForm = ({ ); - } else { - return null; } + return null; }; export default reduxForm({ diff --git a/src/modules/products/edit/general/index.js b/src/modules/products/edit/general/index.js index bc9c49e5..6d6517da 100644 --- a/src/modules/products/edit/general/index.js +++ b/src/modules/products/edit/general/index.js @@ -3,28 +3,24 @@ import { withRouter } from 'react-router'; import { updateProduct } from '../../actions'; import ProductGeneralForm from './components/form'; -const mapStateToProps = (state, ownProps) => { - return { - initialValues: state.products.editProduct - }; -}; +const mapStateToProps = (state, ownProps) => ({ + initialValues: state.products.editProduct +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onSubmit: values => { - dispatch( - updateProduct({ - id: values.id, - name: values.name, - slug: values.slug, - meta_title: values.meta_title, - meta_description: values.meta_description, - description: values.description - }) - ); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onSubmit: values => { + dispatch( + updateProduct({ + id: values.id, + name: values.name, + slug: values.slug, + meta_title: values.meta_title, + meta_description: values.meta_description, + description: values.description + }) + ); + } +}); export default withRouter( connect( diff --git a/src/modules/products/edit/images/components/images.js b/src/modules/products/edit/images/components/images.js index 4a238fb0..67c9f4f1 100644 --- a/src/modules/products/edit/images/components/images.js +++ b/src/modules/products/edit/images/components/images.js @@ -60,8 +60,8 @@ export default class ProductImages extends React.Component { />, ]; @@ -89,7 +89,7 @@ export default class ProductImages extends React.Component { > diff --git a/src/modules/products/edit/images/index.js b/src/modules/products/edit/images/index.js index 14090304..04f72996 100644 --- a/src/modules/products/edit/images/index.js +++ b/src/modules/products/edit/images/index.js @@ -18,33 +18,31 @@ const mapStateToProps = (state, ownProps) => { return { images: state.products.editProductImages || oldImages, uploadingImages: state.products.uploadingImages, - productId: productId + productId }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onImageDelete: (productId, imageId) => { - dispatch(deleteImage(productId, imageId)); - }, - onImageSort: (productId, images) => { - dispatch(updateImages(productId, images)); - }, - onImageUpdate: image => { - const { productId } = ownProps.match.params; - dispatch( - updateImage(productId, { - id: image.id, - alt: image.alt - }) - ); - }, - onImageUpload: form => { - const { productId } = ownProps.match.params; - dispatch(uploadImages(productId, form)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onImageDelete: (productId, imageId) => { + dispatch(deleteImage(productId, imageId)); + }, + onImageSort: (productId, images) => { + dispatch(updateImages(productId, images)); + }, + onImageUpdate: image => { + const { productId } = ownProps.match.params; + dispatch( + updateImage(productId, { + id: image.id, + alt: image.alt + }) + ); + }, + onImageUpload: form => { + const { productId } = ownProps.match.params; + dispatch(uploadImages(productId, form)); + } +}); export default withRouter( connect( diff --git a/src/modules/products/edit/index.js b/src/modules/products/edit/index.js index 34726699..2e8ef185 100644 --- a/src/modules/products/edit/index.js +++ b/src/modules/products/edit/index.js @@ -8,6 +8,11 @@ import ProductImages from 'modules/products/edit/images'; import ProductGeneral from 'modules/products/edit/general'; import ProductAdditional from 'modules/products/edit/additional'; +import { connect } from 'react-redux'; +import { withRouter } from 'react-router'; +import { fetchCategoriesIfNeeded } from 'modules/productCategories/actions'; +import { fetchProduct, cancelProductEdit } from '../actions'; + class ProductEditContainer extends React.Component { componentDidMount() { this.props.fetchData(); @@ -54,29 +59,20 @@ class ProductEditContainer extends React.Component { } } -import { connect } from 'react-redux'; -import { withRouter } from 'react-router'; -import { fetchProduct, cancelProductEdit } from '../actions'; -import { fetchCategoriesIfNeeded } from 'modules/productCategories/actions'; +const mapStateToProps = (state, ownProps) => ({ + product: state.products.editProduct +}); -const mapStateToProps = (state, ownProps) => { - return { - product: state.products.editProduct - }; -}; - -const mapDispatchToProps = (dispatch, ownProps) => { - return { - fetchData: () => { - const { productId } = ownProps.match.params; - dispatch(fetchProduct(productId)); - dispatch(fetchCategoriesIfNeeded()); - }, - eraseData: () => { - dispatch(cancelProductEdit()); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + fetchData: () => { + const { productId } = ownProps.match.params; + dispatch(fetchProduct(productId)); + dispatch(fetchCategoriesIfNeeded()); + }, + eraseData: () => { + dispatch(cancelProductEdit()); + } +}); export default withRouter( connect( diff --git a/src/modules/products/edit/inventory/components/form.js b/src/modules/products/edit/inventory/components/form.js index 008a5072..22fe9745 100644 --- a/src/modules/products/edit/inventory/components/form.js +++ b/src/modules/products/edit/inventory/components/form.js @@ -5,13 +5,13 @@ import { TextField, SelectField, DatePicker } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import messages from 'lib/text'; -import style from './style.css'; import api from 'lib/api'; import Paper from 'material-ui/Paper'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; import Divider from 'material-ui/Divider'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -43,9 +43,8 @@ const slugExists = values => { return api.products .slugExists(values.id, values.slug) .then(response => response.status === 200); - } else { - return Promise.resolve(false); } + return Promise.resolve(false); }; const skuExists = values => { @@ -53,15 +52,14 @@ const skuExists = values => { return api.products .skuExists(values.id, values.sku) .then(response => response.status === 200); - } else { - return Promise.resolve(false); } + return Promise.resolve(false); }; -const asyncValidate = values => { - return Promise.all([slugExists(values), skuExists(values)]).then( +const asyncValidate = values => + Promise.all([slugExists(values), skuExists(values)]).then( ([isSlugExists, isSkuExists]) => { - let errors = {}; + const errors = {}; if (isSlugExists) { errors.slug = messages.errors_urlTaken; @@ -73,12 +71,10 @@ const asyncValidate = values => { if (Object.keys(errors).length > 0) { return Promise.reject(errors); - } else { - return Promise.resolve(); } + return Promise.resolve(); } ); -}; const ProductInventoryForm = ({ handleSubmit, @@ -87,173 +83,168 @@ const ProductInventoryForm = ({ submitting, initialValues, settings -}) => { - return ( -
- -
-
-
-
{messages.products_pricing}
-
-
- -
-
- -
-
- (value === '' ? null : value)} - floatingLabelText={messages.products_dateSaleFrom} - /> -
-
- (value === '' ? null : value)} - floatingLabelText={messages.products_dateSaleTo} - /> -
+}) => ( + + +
+
+
+
{messages.products_pricing}
+
+
+ +
+
+ +
+
+ (value === '' ? null : value)} + floatingLabelText={messages.products_dateSaleFrom} + /> +
+
+ (value === '' ? null : value)} + floatingLabelText={messages.products_dateSaleTo} + />
+
-
-
{messages.products_inventory}
- - - -
-
- -
-
- -
+
+
{messages.products_inventory}
+ + + +
+
+ +
+
+
- - (value === '' ? null : value)} - floatingLabelText={messages.products_dateStockExpected} - />
-
- - - - - - - - - -
-
- - + (value === '' ? null : value)} + floatingLabelText={messages.products_dateStockExpected} + /> +
- - - ); -}; + + + + + + + + + + +
+
+ + +
+ + +); export default reduxForm({ form: 'ProductInventoryForm', diff --git a/src/modules/products/edit/inventory/index.js b/src/modules/products/edit/inventory/index.js index 993dc34a..bdf3d0fa 100644 --- a/src/modules/products/edit/inventory/index.js +++ b/src/modules/products/edit/inventory/index.js @@ -3,37 +3,33 @@ import { withRouter } from 'react-router'; import { updateProduct } from '../../actions'; import ProductInventoryForm from './components/form'; -const mapStateToProps = (state, ownProps) => { - return { - settings: state.settings.settings, - initialValues: state.products.editProduct - }; -}; +const mapStateToProps = (state, ownProps) => ({ + settings: state.settings.settings, + initialValues: state.products.editProduct +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onSubmit: values => { - dispatch( - updateProduct({ - id: values.id, - regular_price: values.regular_price, - sale_price: values.sale_price, - date_sale_from: values.date_sale_from, - date_sale_to: values.date_sale_to, - sku: values.sku, - stock_quantity: values.stock_quantity, - weight: values.weight, - date_stock_expected: values.date_stock_expected, - stock_tracking: values.stock_tracking, - stock_preorder: values.stock_preorder, - stock_backorder: values.stock_backorder, - discontinued: values.discontinued, - enabled: values.enabled - }) - ); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onSubmit: values => { + dispatch( + updateProduct({ + id: values.id, + regular_price: values.regular_price, + sale_price: values.sale_price, + date_sale_from: values.date_sale_from, + date_sale_to: values.date_sale_to, + sku: values.sku, + stock_quantity: values.stock_quantity, + weight: values.weight, + date_stock_expected: values.date_stock_expected, + stock_tracking: values.stock_tracking, + stock_preorder: values.stock_preorder, + stock_backorder: values.stock_backorder, + discontinued: values.discontinued, + enabled: values.enabled + }) + ); + } +}); export default withRouter( connect( diff --git a/src/modules/products/edit/option/components/option.js b/src/modules/products/edit/option/components/option.js index a81517c7..ff028fb6 100644 --- a/src/modules/products/edit/option/components/option.js +++ b/src/modules/products/edit/option/components/option.js @@ -3,15 +3,15 @@ import { Link } from 'react-router-dom'; import { Field, reduxForm } from 'redux-form'; import { TextField, SelectField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; -import OptionValues from './values'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; import MenuItem from 'material-ui/MenuItem'; +import style from './style.css'; +import OptionValues from './values'; const validate = values => { const errors = {}; @@ -36,7 +36,7 @@ class ProductOptionForm extends React.Component { } render() { - let { + const { handleSubmit, pristine, reset, @@ -58,7 +58,7 @@ class ProductOptionForm extends React.Component { name="name" component={TextField} floatingLabelText={messages.optionName} - fullWidth={true} + fullWidth />
@@ -67,14 +67,14 @@ class ProductOptionForm extends React.Component { component={TextField} type="number" floatingLabelText={messages.position} - fullWidth={true} + fullWidth />
@@ -96,7 +96,7 @@ class ProductOptionForm extends React.Component {
diff --git a/src/modules/products/edit/option/components/values.js b/src/modules/products/edit/option/components/values.js index fa4ac441..39867aea 100644 --- a/src/modules/products/edit/option/components/values.js +++ b/src/modules/products/edit/option/components/values.js @@ -2,11 +2,11 @@ import React from 'react'; import { Link } from 'react-router-dom'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; +import style from './style.css'; class OptionValueEdit extends React.Component { constructor(props) { diff --git a/src/modules/products/edit/option/index.js b/src/modules/products/edit/option/index.js index d422efd5..30a50cb9 100644 --- a/src/modules/products/edit/option/index.js +++ b/src/modules/products/edit/option/index.js @@ -26,35 +26,33 @@ const mapStateToProps = (state, ownProps) => { }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - fetchData: () => { - const { productId } = ownProps.match.params; - dispatch(fetchOptions(productId)); - }, - deleteOption: () => { - const { productId, optionId } = ownProps.match.params; - dispatch(deleteOption(productId, optionId)); - ownProps.history.push(`/product/${productId}`); - }, - onSubmit: values => { - const { productId, optionId } = ownProps.match.params; - dispatch(updateOption(productId, optionId, values)); - }, - createOptionValue: valueName => { - const { productId, optionId } = ownProps.match.params; - dispatch(createOptionValue(productId, optionId, valueName)); - }, - updateOptionValue: (valueId, valueName) => { - const { productId, optionId } = ownProps.match.params; - dispatch(updateOptionValue(productId, optionId, valueId, valueName)); - }, - deleteOptionValue: valueId => { - const { productId, optionId } = ownProps.match.params; - dispatch(deleteOptionValue(productId, optionId, valueId)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + fetchData: () => { + const { productId } = ownProps.match.params; + dispatch(fetchOptions(productId)); + }, + deleteOption: () => { + const { productId, optionId } = ownProps.match.params; + dispatch(deleteOption(productId, optionId)); + ownProps.history.push(`/product/${productId}`); + }, + onSubmit: values => { + const { productId, optionId } = ownProps.match.params; + dispatch(updateOption(productId, optionId, values)); + }, + createOptionValue: valueName => { + const { productId, optionId } = ownProps.match.params; + dispatch(createOptionValue(productId, optionId, valueName)); + }, + updateOptionValue: (valueId, valueName) => { + const { productId, optionId } = ownProps.match.params; + dispatch(updateOptionValue(productId, optionId, valueId, valueName)); + }, + deleteOptionValue: valueId => { + const { productId, optionId } = ownProps.match.params; + dispatch(deleteOptionValue(productId, optionId, valueId)); + } +}); export default withRouter( connect( diff --git a/src/modules/products/edit/variants/components/grid.js b/src/modules/products/edit/variants/components/grid.js index c76ae1b6..1d1c08cb 100644 --- a/src/modules/products/edit/variants/components/grid.js +++ b/src/modules/products/edit/variants/components/grid.js @@ -2,7 +2,6 @@ import React from 'react'; import { Link } from 'react-router-dom'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import FontIcon from 'material-ui/FontIcon'; @@ -10,6 +9,7 @@ import IconButton from 'material-ui/IconButton'; import RaisedButton from 'material-ui/RaisedButton'; import MenuItem from 'material-ui/MenuItem'; import DropDownMenu from 'material-ui/DropDownMenu'; +import style from './style.css'; class VariantInput extends React.Component { constructor(props) { @@ -57,7 +57,7 @@ const VariantRow = ({ onOptionChange, onDeleteVariant }) => { - let cols = options.map((option, index) => { + const cols = options.map((option, index) => { const variantOption = variant.options.find(i => i.option_id === option.id); const variantOptionValueId = variantOption ? variantOption.value_id : null; @@ -81,9 +81,8 @@ const VariantRow = ({
); - } else { - return
; } + return
; }); return ( diff --git a/src/modules/products/edit/variants/index.js b/src/modules/products/edit/variants/index.js index 2f348fcd..de5f2559 100644 --- a/src/modules/products/edit/variants/index.js +++ b/src/modules/products/edit/variants/index.js @@ -21,52 +21,50 @@ const mapStateToProps = (state, ownProps) => { return { options: state.products.editProductOptions || oldOptions, variants: state.products.editProductVariants || oldVariants, - productId: productId + productId }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onSkuChange: (variantId, value) => { - const { productId } = ownProps.match.params; - dispatch(updateVariant(productId, variantId, { sku: value })); - }, - onPriceChange: (variantId, value) => { - const { productId } = ownProps.match.params; - dispatch(updateVariant(productId, variantId, { price: value })); - }, - onStockChange: (variantId, value) => { - const { productId } = ownProps.match.params; - dispatch(updateVariant(productId, variantId, { stock_quantity: value })); - }, - onWeightChange: (variantId, value) => { - const { productId } = ownProps.match.params; - dispatch(updateVariant(productId, variantId, { weight: value })); - }, - onOptionChange: (variantId, optionId, valueId) => { - const { productId } = ownProps.match.params; - dispatch(setVariantOption(productId, variantId, optionId, valueId)); - }, - createVariant: () => { - const { productId } = ownProps.match.params; - dispatch(createVariant(productId)); - }, - deleteVariant: variantId => { - const { productId } = ownProps.match.params; - dispatch(deleteVariant(productId, variantId)); - }, - createOption: () => { - const { productId } = ownProps.match.params; - const newOption = { - name: '+', - position: 0, - required: true, - control: 'select' - }; - dispatch(createOption(productId, newOption)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onSkuChange: (variantId, value) => { + const { productId } = ownProps.match.params; + dispatch(updateVariant(productId, variantId, { sku: value })); + }, + onPriceChange: (variantId, value) => { + const { productId } = ownProps.match.params; + dispatch(updateVariant(productId, variantId, { price: value })); + }, + onStockChange: (variantId, value) => { + const { productId } = ownProps.match.params; + dispatch(updateVariant(productId, variantId, { stock_quantity: value })); + }, + onWeightChange: (variantId, value) => { + const { productId } = ownProps.match.params; + dispatch(updateVariant(productId, variantId, { weight: value })); + }, + onOptionChange: (variantId, optionId, valueId) => { + const { productId } = ownProps.match.params; + dispatch(setVariantOption(productId, variantId, optionId, valueId)); + }, + createVariant: () => { + const { productId } = ownProps.match.params; + dispatch(createVariant(productId)); + }, + deleteVariant: variantId => { + const { productId } = ownProps.match.params; + dispatch(deleteVariant(productId, variantId)); + }, + createOption: () => { + const { productId } = ownProps.match.params; + const newOption = { + name: '+', + position: 0, + required: true, + control: 'select' + }; + dispatch(createOption(productId, newOption)); + } +}); export default withRouter( connect( diff --git a/src/modules/products/editHead/components/buttons.js b/src/modules/products/editHead/components/buttons.js index ff2fe2db..f7bd6f88 100644 --- a/src/modules/products/editHead/components/buttons.js +++ b/src/modules/products/editHead/components/buttons.js @@ -5,7 +5,7 @@ import DeleteConfirmation from 'modules/shared/deleteConfirmation'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; import FlatButton from 'material-ui/FlatButton'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -38,7 +38,7 @@ export default class Buttons extends React.Component { return ( - {product && - product.enabled && ( - - - - open_in_new - - - - )} + {product && product.enabled && ( + + + + open_in_new + + + + )} { - return { - product: state.products.editProduct - }; -}; +const mapStateToProps = (state, ownProps) => ({ + product: state.products.editProduct +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onDelete: () => { - dispatch(deleteCurrentProduct()); - ownProps.history.push('/products'); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onDelete: () => { + dispatch(deleteCurrentProduct()); + ownProps.history.push('/products'); + } +}); export default withRouter( connect( diff --git a/src/modules/products/list/components/item.js b/src/modules/products/list/components/item.js index 67361fe8..9b0d0dbb 100644 --- a/src/modules/products/list/components/item.js +++ b/src/modules/products/list/components/item.js @@ -20,14 +20,13 @@ const ItemImage = ({ images }) => { if (images && images.length > 0) { const imageUrl = helper.getThumbnailUrl(images[0].url, THUMBNAIL_WIDTH); return ; - } else { - return ImagePlaceholder; } + return ImagePlaceholder; }; const ItemPrice = ({ product, settings }) => { - let priceFormatted = helper.formatCurrency(product.price, settings); - let priceOldFormatted = product.on_sale + const priceFormatted = helper.formatCurrency(product.price, settings); + const priceOldFormatted = product.on_sale ? helper.formatCurrency(product.regular_price, settings) : ''; @@ -72,9 +71,9 @@ const ItemStock = ({ status, quantity }) => { const ProductItem = ({ product, onSelect, selected, settings }) => { let productClass = style.productName; if (!product.enabled || product.discontinued) { - productClass += ' ' + style.productInactive; + productClass += ` ${style.productInactive}`; } else { - productClass += ' ' + style.productActive; + productClass += ` ${style.productActive}`; } const productName = @@ -83,8 +82,8 @@ const ProductItem = ({ product, onSelect, selected, settings }) => { : `<${messages.draft}>`; return ( -
-
+
+
@@ -96,7 +95,7 @@ const ProductItem = ({ product, onSelect, selected, settings }) => { />
-
+
@@ -105,7 +104,7 @@ const ProductItem = ({ product, onSelect, selected, settings }) => {
- + {productName}
{product.category_name} @@ -113,14 +112,14 @@ const ProductItem = ({ product, onSelect, selected, settings }) => {
-
{product.sku}
-
+
{product.sku}
+
-
+
diff --git a/src/modules/products/list/components/list.js b/src/modules/products/list/components/list.js index f4427ca2..e493a654 100644 --- a/src/modules/products/list/components/list.js +++ b/src/modules/products/list/components/list.js @@ -1,11 +1,11 @@ import React from 'react'; import { List } from 'material-ui/List'; import Divider from 'material-ui/Divider'; -import Head from './head'; -import ProductsListItem from './item'; import RaisedButton from 'material-ui/RaisedButton'; import FontIcon from 'material-ui/FontIcon'; import messages from 'lib/text'; +import ProductsListItem from './item'; +import Head from './head'; import style from './style.css'; export default class ProductsList extends React.Component { diff --git a/src/modules/products/list/index.js b/src/modules/products/list/index.js index 98c88fea..3f97fa35 100644 --- a/src/modules/products/list/index.js +++ b/src/modules/products/list/index.js @@ -10,46 +10,42 @@ import { } from '../actions'; import List from './components/list'; -const mapStateToProps = (state, ownProps) => { - return { - settings: state.settings.settings, - items: state.products.items, - selected: state.products.selected, - loadingItems: state.products.loadingItems, - hasMore: state.products.hasMore, - totalCount: state.products.totalCount - }; -}; +const mapStateToProps = (state, ownProps) => ({ + settings: state.settings.settings, + items: state.products.items, + selected: state.products.selected, + loadingItems: state.products.loadingItems, + hasMore: state.products.hasMore, + totalCount: state.products.totalCount +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - dispatch(fetchProducts()); - }, - onSelect: event => { - const productId = event.target.value; - const checked = event.target.checked; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + dispatch(fetchProducts()); + }, + onSelect: event => { + const productId = event.target.value; + const { checked } = event.target; - if (checked) { - dispatch(selectProduct(productId)); - } else { - dispatch(deselectProduct(productId)); - } - }, - onSelectAll: event => { - const checked = event.target.checked; + if (checked) { + dispatch(selectProduct(productId)); + } else { + dispatch(deselectProduct(productId)); + } + }, + onSelectAll: event => { + const { checked } = event.target; - if (checked) { - dispatch(selectAllProduct()); - } else { - dispatch(deselectAllProduct()); - } - }, - loadMore: () => { - dispatch(fetchMoreProducts()); + if (checked) { + dispatch(selectAllProduct()); + } else { + dispatch(deselectAllProduct()); } - }; -}; + }, + loadMore: () => { + dispatch(fetchMoreProducts()); + } +}); export default withRouter( connect( diff --git a/src/modules/products/listFilter/components/filter.js b/src/modules/products/listFilter/components/filter.js index a945d4ba..2b79bbfc 100644 --- a/src/modules/products/listFilter/components/filter.js +++ b/src/modules/products/listFilter/components/filter.js @@ -1,10 +1,10 @@ import React from 'react'; import messages from 'lib/text'; -import style from './style.css'; import SelectField from 'material-ui/SelectField'; import MenuItem from 'material-ui/MenuItem'; import Toggle from 'material-ui/Toggle'; +import style from './style.css'; const Filter = ({ filter, @@ -23,11 +23,11 @@ const Filter = ({ setEnabled(value); }} floatingLabelText={messages.enabled} - fullWidth={true} + fullWidth > - + - + - + - + + + - - diff --git a/src/modules/products/listFilter/index.js b/src/modules/products/listFilter/index.js index 4d96b07b..2d298048 100644 --- a/src/modules/products/listFilter/index.js +++ b/src/modules/products/listFilter/index.js @@ -2,32 +2,28 @@ import { connect } from 'react-redux'; import { fetchProducts, setFilter } from '../actions'; import Filter from './components/filter'; -const mapStateToProps = state => { - return { - filter: state.products.filter - }; -}; +const mapStateToProps = state => ({ + filter: state.products.filter +}); -const mapDispatchToProps = dispatch => { - return { - setEnabled: value => { - dispatch(setFilter({ enabled: value })); - dispatch(fetchProducts()); - }, - setDiscontinued: value => { - dispatch(setFilter({ discontinued: value })); - dispatch(fetchProducts()); - }, - setOnSale: value => { - dispatch(setFilter({ onSale: value })); - dispatch(fetchProducts()); - }, - setStock: value => { - dispatch(setFilter({ stockStatus: value })); - dispatch(fetchProducts()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + setEnabled: value => { + dispatch(setFilter({ enabled: value })); + dispatch(fetchProducts()); + }, + setDiscontinued: value => { + dispatch(setFilter({ discontinued: value })); + dispatch(fetchProducts()); + }, + setOnSale: value => { + dispatch(setFilter({ onSale: value })); + dispatch(fetchProducts()); + }, + setStock: value => { + dispatch(setFilter({ stockStatus: value })); + dispatch(fetchProducts()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/products/listHead/components/buttons.js b/src/modules/products/listHead/components/buttons.js index 472eb9cc..0e9ee2fa 100644 --- a/src/modules/products/listHead/components/buttons.js +++ b/src/modules/products/listHead/components/buttons.js @@ -9,7 +9,7 @@ import IconButton from 'material-ui/IconButton'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import Search from './search'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -62,8 +62,8 @@ export default class Buttons extends React.Component { />, ]; @@ -74,7 +74,7 @@ export default class Buttons extends React.Component { {selectedCount > 0 && ( )} { - return ( - - ); -}; +export default ({ value, setSearch }) => ( + +); diff --git a/src/modules/products/listHead/index.js b/src/modules/products/listHead/index.js index 814faf41..2908f723 100644 --- a/src/modules/products/listHead/index.js +++ b/src/modules/products/listHead/index.js @@ -10,30 +10,26 @@ import { } from '../actions'; import Buttons from './components/buttons'; -const mapStateToProps = (state, ownProps) => { - return { - search: state.products.filter.search, - selectedCount: state.products.selected.length - }; -}; +const mapStateToProps = (state, ownProps) => ({ + search: state.products.filter.search, + selectedCount: state.products.selected.length +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - setSearch: (event, value) => { - dispatch(setFilter({ search: value })); - dispatch(fetchProducts()); - }, - onDelete: () => { - dispatch(deleteProducts()); - }, - onMoveTo: category_id => { - dispatch(setCategory(category_id)); - }, - onCreate: () => { - dispatch(createProduct(ownProps.history)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + setSearch: (event, value) => { + dispatch(setFilter({ search: value })); + dispatch(fetchProducts()); + }, + onDelete: () => { + dispatch(deleteProducts()); + }, + onMoveTo: category_id => { + dispatch(setCategory(category_id)); + }, + onCreate: () => { + dispatch(createProduct(ownProps.history)); + } +}); export default withRouter( connect( diff --git a/src/modules/products/reducer.js b/src/modules/products/reducer.js index 450b1c38..69686fa4 100644 --- a/src/modules/products/reducer.js +++ b/src/modules/products/reducer.js @@ -75,9 +75,9 @@ export default (state = initialState, action) => { selected: [] }); case t.PRODUCTS_SELECT_ALL: - let selected = state.items.map(item => item.id); + const selected = state.items.map(item => item.id); return Object.assign({}, state, { - selected: selected + selected }); case t.PRODUCTS_SET_FILTER: const newFilter = Object.assign({}, state.filter, action.filter); diff --git a/src/modules/reports/ordersBar/index.js b/src/modules/reports/ordersBar/index.js index 5bd3f888..7cc04e69 100644 --- a/src/modules/reports/ordersBar/index.js +++ b/src/modules/reports/ordersBar/index.js @@ -1,9 +1,9 @@ import React from 'react'; import messages from 'lib/text'; import api from 'lib/api'; +import moment from 'moment'; import BarChart from './barChart'; import * as utils from './utils'; -import moment from 'moment'; export default class OrdersBar extends React.Component { constructor(props) { @@ -49,7 +49,7 @@ export default class OrdersBar extends React.Component {
{ .rgbString(); }; -const getOrdersByDate = (orders, dateMoment) => { - return orders.filter(order => - moment(order.date_placed).isSame(dateMoment, 'day') - ); -}; +const getOrdersByDate = (orders, dateMoment) => + orders.filter(order => moment(order.date_placed).isSame(dateMoment, 'day')); const filterSuccessOrders = order => order.paid === true || order.closed === true; const filterNewOrders = order => !order.paid && !order.closed; export const getReportDataFromOrders = ordersResponse => { - let reportItems = []; - let dateFrom = moment().subtract(1, 'months'); - let dateTo = moment(); + const reportItems = []; + const dateFrom = moment().subtract(1, 'months'); + const dateTo = moment(); const daysDiff = dateFrom.diff(dateTo, 'days'); for (let i = daysDiff; i < 1; i++) { @@ -46,9 +43,7 @@ export const getReportDataFromOrders = ordersResponse => { const newOrdersCount = ordersPlacedThisDate.filter(filterNewOrders).length; const successOrdersRevenue = ordersPlacedThisDate .filter(filterSuccessOrders) - .reduce((a, b) => { - return a + b.grand_total; - }, 0); + .reduce((a, b) => a + b.grand_total, 0); reportItems.push({ date: reportingDate.format('D MMM'), @@ -68,7 +63,7 @@ export const getOrdersDataFromReportData = reportData => { const newData = reportData.map(item => item.new); return { - labels: labels, + labels, datasets: [ { label: messages.closedAndPaidOrders, @@ -91,7 +86,7 @@ export const getSalesDataFromReportData = reportData => { const revenueData = reportData.map(item => item.revenue); return { - labels: labels, + labels, datasets: [ { label: messages.closedAndPaidOrders, diff --git a/src/modules/settings/actions.js b/src/modules/settings/actions.js index 304da5b3..f2819cef 100644 --- a/src/modules/settings/actions.js +++ b/src/modules/settings/actions.js @@ -1,6 +1,6 @@ -import * as t from './actionTypes'; import api from 'lib/api'; import messages from 'lib/text'; +import * as t from './actionTypes'; export function exportRequest() { return { @@ -186,19 +186,18 @@ export function fetchSettings() { } export function fetchEmailSettings() { - return (dispatch, getState) => { - return api.settings + return (dispatch, getState) => + api.settings .retrieveEmailSettings() .then(({ status, json }) => { dispatch(receiveEmailSettings(json)); }) .catch(error => {}); - }; } export function deleteLogo() { - return (dispatch, getState) => { - return api.settings + return (dispatch, getState) => + api.settings .deleteLogo() .then(({ status, json }) => { if (status === 200) { @@ -208,10 +207,9 @@ export function deleteLogo() { } }) .catch(error => { - //dispatch error + // dispatch error console.log(error); }); - }; } export function updateSettings(settings) { @@ -227,14 +225,13 @@ export function updateSettings(settings) { } export function updateEmailSettings(emailSettings) { - return (dispatch, getState) => { - return api.settings + return (dispatch, getState) => + api.settings .updateEmailSettings(emailSettings) .then(({ status, json }) => { dispatch(receiveEmailSettings(json)); }) .catch(error => {}); - }; } export function fetchEmailTemplate(templateName) { @@ -251,26 +248,24 @@ export function fetchEmailTemplate(templateName) { } export function updateEmailTemplate(emailTemplate) { - return (dispatch, getState) => { - return api.settings + return (dispatch, getState) => + api.settings .updateEmailTemplate(emailTemplate.templateName, emailTemplate) .then(({ status, json }) => { json.templateName = templateName; dispatch(receiveEmailTemplate(json)); }) .catch(error => {}); - }; } export function fetchCheckoutFields() { - return (dispatch, getState) => { - return api.checkoutFields + return (dispatch, getState) => + api.checkoutFields .list() .then(({ status, json }) => { dispatch(receiveCheckoutFields(json)); }) .catch(error => {}); - }; } export function fetchCheckoutField(fieldName) { @@ -287,181 +282,165 @@ export function fetchCheckoutField(fieldName) { } export function updateCheckoutField(checkoutField) { - return (dispatch, getState) => { - return api.checkoutFields + return (dispatch, getState) => + api.checkoutFields .update(checkoutField.fieldName, checkoutField) .then(({ status, json }) => { json.fieldName = fieldName; dispatch(receiveCheckoutField(json)); }) .catch(error => {}); - }; } export function fetchShippingMethods() { - return (dispatch, getState) => { - return api.shippingMethods + return (dispatch, getState) => + api.shippingMethods .list() .then(({ status, json }) => { dispatch(receiveShippingMethods(json)); }) .catch(error => {}); - }; } export function fetchPaymentMethods() { - return (dispatch, getState) => { - return api.paymentMethods + return (dispatch, getState) => + api.paymentMethods .list() .then(({ status, json }) => { dispatch(receivePaymentMethods(json)); }) .catch(error => {}); - }; } export function updateShippingMethod(method) { - return (dispatch, getState) => { - return api.shippingMethods + return (dispatch, getState) => + api.shippingMethods .update(method.id, method) .then(({ status, json }) => { dispatch(fetchShippingMethods()); }) .catch(error => {}); - }; } export function updatePaymentMethod(method) { - return (dispatch, getState) => { - return api.paymentMethods + return (dispatch, getState) => + api.paymentMethods .update(method.id, method) .then(({ status, json }) => { dispatch(fetchPaymentMethods()); }) .catch(error => {}); - }; } export function fetchShippingMethod(id) { - return (dispatch, getState) => { - return api.shippingMethods + return (dispatch, getState) => + api.shippingMethods .retrieve(id) .then(({ status, json }) => { dispatch(receiveShippingMethod(json)); }) .catch(error => {}); - }; } export function fetchPaymentMethod(id) { - return (dispatch, getState) => { - return api.paymentMethods + return (dispatch, getState) => + api.paymentMethods .retrieve(id) .then(({ status, json }) => { dispatch(receivePaymentMethod(json)); }) .catch(error => {}); - }; } export function deleteShippingMethod(methodId) { - return (dispatch, getState) => { - return api.shippingMethods + return (dispatch, getState) => + api.shippingMethods .delete(methodId) .then(({ status, json }) => { dispatch(fetchShippingMethods()); }) .catch(error => {}); - }; } export function deletePaymentMethod(methodId) { - return (dispatch, getState) => { - return api.paymentMethods + return (dispatch, getState) => + api.paymentMethods .delete(methodId) .then(({ status, json }) => { dispatch(fetchPaymentMethods()); }) .catch(error => {}); - }; } export function createShippingMethod(method) { - return (dispatch, getState) => { - return api.shippingMethods + return (dispatch, getState) => + api.shippingMethods .create(method) .then(({ status, json }) => { dispatch(fetchShippingMethods()); }) .catch(error => {}); - }; } export function createPaymentMethod(method) { - return (dispatch, getState) => { - return api.paymentMethods + return (dispatch, getState) => + api.paymentMethods .create(method) .then(({ status, json }) => { dispatch(fetchPaymentMethods()); }) .catch(error => {}); - }; } export function fetchTokens() { - return (dispatch, getState) => { - return api.tokens + return (dispatch, getState) => + api.tokens .list() .then(({ status, json }) => { dispatch(receiveTokens(json)); }) .catch(error => {}); - }; } export function fetchToken(id) { - return (dispatch, getState) => { - return api.tokens + return (dispatch, getState) => + api.tokens .retrieve(id) .then(({ status, json }) => { dispatch(receiveToken(json)); }) .catch(error => {}); - }; } export function createToken(token) { - return (dispatch, getState) => { - return api.tokens + return (dispatch, getState) => + api.tokens .create(token) .then(({ status, json }) => { dispatch(fetchTokens()); dispatch(receiveNewToken(json.token)); }) .catch(error => {}); - }; } export function updateToken(token) { - return (dispatch, getState) => { - return api.tokens + return (dispatch, getState) => + api.tokens .update(token.id, token) .then(({ status, json }) => { dispatch(fetchTokens()); }) .catch(error => {}); - }; } export function deleteToken(tokenId) { - return (dispatch, getState) => { - return api.tokens + return (dispatch, getState) => + api.tokens .delete(tokenId) .then(({ status, json }) => { dispatch(fetchTokens()); }) .catch(error => {}); - }; } export function fetchPaymentGateway(gatewayName) { @@ -473,37 +452,34 @@ export function fetchPaymentGateway(gatewayName) { dispatch(receivePaymentGateway(json)); }) .catch(error => {}); - } else { - dispatch(receivePaymentGateway(null)); } + dispatch(receivePaymentGateway(null)); }; } export function updatePaymentGateway(gatewayName, data) { - return (dispatch, getState) => { - return api.paymentGateways + return (dispatch, getState) => + api.paymentGateways .update(gatewayName, data) .then(({ status, json }) => { dispatch(receivePaymentGateway(json)); }) .catch(error => {}); - }; } export function uploadLogo(form) { - return (dispatch, getState) => { - return api.settings + return (dispatch, getState) => + api.settings .uploadLogo(form) .then(() => { dispatch(fetchSettings()); }) .catch(error => {}); - }; } export function fetchThemeSettings() { - return (dispatch, getState) => { - return Promise.all([ + return (dispatch, getState) => + Promise.all([ api.theme.settings.retrieve(), api.theme.settings.retrieveSchema() ]) @@ -512,126 +488,114 @@ export function fetchThemeSettings() { dispatch(receiveThemeSettingsSchema(schemaResponse.json)); }) .catch(error => {}); - }; } export function updateThemeSettings(settings) { - return (dispatch, getState) => { - return api.theme.settings + return (dispatch, getState) => + api.theme.settings .update(settings) .then(() => { dispatch(fetchThemeSettings()); }) .catch(error => {}); - }; } export function fetchRedirects() { - return (dispatch, getState) => { - return api.redirects + return (dispatch, getState) => + api.redirects .list() .then(({ status, json }) => { dispatch(receiveRedirects(json)); }) .catch(error => {}); - }; } export function fetchRedirect(id) { - return (dispatch, getState) => { - return api.redirects + return (dispatch, getState) => + api.redirects .retrieve(id) .then(({ status, json }) => { dispatch(receiveRedirect(json)); }) .catch(error => {}); - }; } export function createRedirect(redirect) { - return (dispatch, getState) => { - return api.redirects + return (dispatch, getState) => + api.redirects .create(redirect) .then(({ status, json }) => { dispatch(fetchRedirects()); }) .catch(error => {}); - }; } export function updateRedirect(redirect) { - return (dispatch, getState) => { - return api.redirects + return (dispatch, getState) => + api.redirects .update(redirect.id, redirect) .then(({ status, json }) => { dispatch(fetchRedirects()); }) .catch(error => {}); - }; } export function deleteRedirect(redirectId) { - return (dispatch, getState) => { - return api.redirects + return (dispatch, getState) => + api.redirects .delete(redirectId) .then(({ status, json }) => { dispatch(fetchRedirects()); }) .catch(error => {}); - }; } export function fetchWebhooks() { - return (dispatch, getState) => { - return api.webhooks + return (dispatch, getState) => + api.webhooks .list() .then(({ status, json }) => { dispatch(receiveWebhooks(json)); }) .catch(error => {}); - }; } export function fetchWebhook(id) { - return (dispatch, getState) => { - return api.webhooks + return (dispatch, getState) => + api.webhooks .retrieve(id) .then(({ status, json }) => { dispatch(receiveWebhook(json)); }) .catch(error => {}); - }; } export function createWebhook(webhook) { - return (dispatch, getState) => { - return api.webhooks + return (dispatch, getState) => + api.webhooks .create(webhook) .then(({ status, json }) => { dispatch(fetchWebhooks()); }) .catch(error => {}); - }; } export function updateWebhook(webhook) { - return (dispatch, getState) => { - return api.webhooks + return (dispatch, getState) => + api.webhooks .update(webhook.id, webhook) .then(({ status, json }) => { dispatch(fetchWebhooks()); }) .catch(error => {}); - }; } export function deleteWebhook(webhookId) { - return (dispatch, getState) => { - return api.webhooks + return (dispatch, getState) => + api.webhooks .delete(webhookId) .then(({ status, json }) => { dispatch(fetchWebhooks()); }) .catch(error => {}); - }; } diff --git a/src/modules/settings/checkout/components/form.js b/src/modules/settings/checkout/components/form.js index cd37d474..371f9afa 100644 --- a/src/modules/settings/checkout/components/form.js +++ b/src/modules/settings/checkout/components/form.js @@ -7,31 +7,29 @@ import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; import { List, ListItem } from 'material-ui/List'; -const CheckoutFieldItem = ({ name, status, path }) => { - return ( -
- - - keyboard_arrow_right - } - primaryText={ -
-
{name}
-
- {status} -
+const CheckoutFieldItem = ({ name, status, path }) => ( +
+ + + keyboard_arrow_right + } + primaryText={ +
+
{name}
+
+ {status}
- } - /> - -
- ); -}; +
+ } + /> + +
+); export default class EmailSettings extends React.Component { componentDidMount() { diff --git a/src/modules/settings/checkout/index.js b/src/modules/settings/checkout/index.js index 8ed39c57..f6b3c65e 100644 --- a/src/modules/settings/checkout/index.js +++ b/src/modules/settings/checkout/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchCheckoutFields } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - checkoutFields: state.settings.checkoutFields - }; -}; +const mapStateToProps = state => ({ + checkoutFields: state.settings.checkoutFields +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchCheckoutFields()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchCheckoutFields()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/checkoutFields/components/form.js b/src/modules/settings/checkoutFields/components/form.js index fb1d28e8..e41e36f2 100644 --- a/src/modules/settings/checkoutFields/components/form.js +++ b/src/modules/settings/checkoutFields/components/form.js @@ -3,11 +3,11 @@ import { Field, reduxForm } from 'redux-form'; import { TextField, RadioButtonGroup } from 'redux-form-material-ui'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; import { RadioButton } from 'material-ui/RadioButton'; +import style from './style.css'; const radioButtonStyle = { marginTop: 14, @@ -20,7 +20,7 @@ class CheckoutFieldForm extends React.Component { } render() { - let { handleSubmit, pristine, submitting, initialValues } = this.props; + const { handleSubmit, pristine, submitting, initialValues } = this.props; return (
@@ -43,7 +43,7 @@ class CheckoutFieldForm extends React.Component {
@@ -73,7 +73,7 @@ class CheckoutFieldForm extends React.Component { diff --git a/src/modules/settings/checkoutFields/index.js b/src/modules/settings/checkoutFields/index.js index c9d659f5..8eb92378 100644 --- a/src/modules/settings/checkoutFields/index.js +++ b/src/modules/settings/checkoutFields/index.js @@ -2,24 +2,20 @@ import { connect } from 'react-redux'; import { fetchCheckoutField, updateCheckoutField } from '../actions'; import Form from './components/form'; -const mapStateToProps = (state, ownProps) => { - return { - initialValues: state.settings.checkoutField - }; -}; +const mapStateToProps = (state, ownProps) => ({ + initialValues: state.settings.checkoutField +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - const { fieldName } = ownProps.match.params; - dispatch(fetchCheckoutField(fieldName)); - }, - onSubmit: values => { - dispatch(updateCheckoutField(values)); - ownProps.history.push('/settings/checkout'); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + const { fieldName } = ownProps.match.params; + dispatch(fetchCheckoutField(fieldName)); + }, + onSubmit: values => { + dispatch(updateCheckoutField(values)); + ownProps.history.push('/settings/checkout'); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/email/components/form.js b/src/modules/settings/email/components/form.js index cfab6b2f..5614209a 100644 --- a/src/modules/settings/email/components/form.js +++ b/src/modules/settings/email/components/form.js @@ -83,7 +83,7 @@ export default class EmailSettings extends React.Component { primaryText={messages.settings_customerRegistration} /> - {/* @@ -108,7 +108,7 @@ export default class EmailSettings extends React.Component { } primaryText={messages.settings_customerRegistration} /> - */} + */} - {/* @@ -147,7 +147,7 @@ export default class EmailSettings extends React.Component { } primaryText={messages.settings_customerRecovery} /> - */} + */}
diff --git a/src/modules/settings/email/index.js b/src/modules/settings/email/index.js index 17f13a47..ea2397cd 100644 --- a/src/modules/settings/email/index.js +++ b/src/modules/settings/email/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchEmailSettings } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - emailSettings: state.settings.emailSettings - }; -}; +const mapStateToProps = state => ({ + emailSettings: state.settings.emailSettings +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchEmailSettings()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchEmailSettings()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/emailTemplates/components/form.js b/src/modules/settings/emailTemplates/components/form.js index 885f1a1f..95de5234 100644 --- a/src/modules/settings/emailTemplates/components/form.js +++ b/src/modules/settings/emailTemplates/components/form.js @@ -3,10 +3,10 @@ import { Field, reduxForm } from 'redux-form'; import { TextField } from 'redux-form-material-ui'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; class EmailTemplate extends React.Component { componentDidMount() { @@ -14,7 +14,7 @@ class EmailTemplate extends React.Component { } render() { - let { handleSubmit, pristine, submitting, initialValues } = this.props; + const { handleSubmit, pristine, submitting, initialValues } = this.props; return ( @@ -37,9 +37,9 @@ class EmailTemplate extends React.Component {
@@ -48,7 +48,7 @@ class EmailTemplate extends React.Component { diff --git a/src/modules/settings/emailTemplates/index.js b/src/modules/settings/emailTemplates/index.js index 7cd9899d..f013256e 100644 --- a/src/modules/settings/emailTemplates/index.js +++ b/src/modules/settings/emailTemplates/index.js @@ -2,23 +2,19 @@ import { connect } from 'react-redux'; import { fetchEmailTemplate, updateEmailTemplate } from '../actions'; import Form from './components/form'; -const mapStateToProps = (state, ownProps) => { - return { - initialValues: state.settings.emailTemplate - }; -}; +const mapStateToProps = (state, ownProps) => ({ + initialValues: state.settings.emailTemplate +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - const { templateName } = ownProps.match.params; - dispatch(fetchEmailTemplate(templateName)); - }, - onSubmit: values => { - dispatch(updateEmailTemplate(values)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + const { templateName } = ownProps.match.params; + dispatch(fetchEmailTemplate(templateName)); + }, + onSubmit: values => { + dispatch(updateEmailTemplate(values)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/general/components/form.js b/src/modules/settings/general/components/form.js index 8a2874c7..20c15f05 100644 --- a/src/modules/settings/general/components/form.js +++ b/src/modules/settings/general/components/form.js @@ -5,7 +5,6 @@ import { TextField, SelectField, DatePicker } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import messages from 'lib/text'; -import style from './style.css'; import data from 'lib/data'; import Paper from 'material-ui/Paper'; @@ -15,6 +14,7 @@ import DropDownMenu from 'material-ui/DropDownMenu'; import MenuItem from 'material-ui/MenuItem'; import FontIcon from 'material-ui/FontIcon'; import { List, ListItem } from 'material-ui/List'; +import style from './style.css'; class GeneralSettings extends React.Component { componentDidMount() { @@ -22,9 +22,9 @@ class GeneralSettings extends React.Component { } render() { - let { handleSubmit, pristine, submitting, initialValues } = this.props; + const { handleSubmit, pristine, submitting, initialValues } = this.props; - let currencyItems = []; + const currencyItems = []; for (const key in data.currencies) { currencyItems.push( @@ -75,48 +75,42 @@ class GeneralSettings extends React.Component { }} > -
+
+ + + + keyboard_arrow_right + + } + primaryText={messages.logo} + /> + + + +
-
- - - - keyboard_arrow_right - - } - primaryText={messages.logo} - /> - - - -
-
{messages.settings_storeName}
- +
- +
{messages.currency}
{currencyItems} @@ -138,23 +132,23 @@ class GeneralSettings extends React.Component {
@@ -166,8 +160,8 @@ class GeneralSettings extends React.Component { @@ -177,8 +171,8 @@ class GeneralSettings extends React.Component { @@ -219,7 +213,7 @@ class GeneralSettings extends React.Component {
{timezoneItems} @@ -264,8 +258,8 @@ class GeneralSettings extends React.Component {
@@ -322,25 +316,25 @@ class GeneralSettings extends React.Component {
@@ -360,17 +354,17 @@ class GeneralSettings extends React.Component {
@@ -390,7 +384,7 @@ class GeneralSettings extends React.Component {
@@ -409,7 +403,7 @@ class GeneralSettings extends React.Component {
@@ -428,7 +422,7 @@ class GeneralSettings extends React.Component {
{countryItems} @@ -473,7 +467,7 @@ class GeneralSettings extends React.Component {
@@ -493,7 +487,7 @@ class GeneralSettings extends React.Component {
@@ -525,7 +519,7 @@ class GeneralSettings extends React.Component {
@@ -546,7 +540,7 @@ class GeneralSettings extends React.Component {
@@ -556,7 +550,7 @@ class GeneralSettings extends React.Component { diff --git a/src/modules/settings/general/index.js b/src/modules/settings/general/index.js index 9c33b8c2..08d6258d 100644 --- a/src/modules/settings/general/index.js +++ b/src/modules/settings/general/index.js @@ -2,22 +2,18 @@ import { connect } from 'react-redux'; import { fetchSettings, updateSettings } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - initialValues: state.settings.settings - }; -}; +const mapStateToProps = state => ({ + initialValues: state.settings.settings +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchSettings()); - }, - onSubmit: values => { - dispatch(updateSettings(values)); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchSettings()); + }, + onSubmit: values => { + dispatch(updateSettings(values)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/generalLogo/components/form.js b/src/modules/settings/generalLogo/components/form.js index eb2feb4d..d0af605c 100644 --- a/src/modules/settings/generalLogo/components/form.js +++ b/src/modules/settings/generalLogo/components/form.js @@ -9,7 +9,7 @@ export default class GeneralLogoSettingsForm extends React.Component { render() { const { onImageUpload, onImageDelete, settings } = this.props; - let imageUrl = settings && settings.logo ? settings.logo : ''; + const imageUrl = settings && settings.logo ? settings.logo : ''; return ( diff --git a/src/modules/settings/generalLogo/index.js b/src/modules/settings/generalLogo/index.js index fc868984..86114c9e 100644 --- a/src/modules/settings/generalLogo/index.js +++ b/src/modules/settings/generalLogo/index.js @@ -2,25 +2,21 @@ import { connect } from 'react-redux'; import { fetchSettings, deleteLogo, uploadLogo } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - settings: state.settings.settings - }; -}; +const mapStateToProps = state => ({ + settings: state.settings.settings +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchSettings()); - }, - onImageDelete: () => { - dispatch(deleteLogo()); - }, - onImageUpload: form => { - dispatch(uploadLogo(form)); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchSettings()); + }, + onImageDelete: () => { + dispatch(deleteLogo()); + }, + onImageUpload: form => { + dispatch(uploadLogo(form)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/paymentGateway/components/form.js b/src/modules/settings/paymentGateway/components/form.js index 4e1be64b..3fa31f4a 100644 --- a/src/modules/settings/paymentGateway/components/form.js +++ b/src/modules/settings/paymentGateway/components/form.js @@ -1,14 +1,14 @@ import React from 'react'; import { reduxForm } from 'redux-form'; -import GatewaySettings from './gatewaySettings.js'; -import { AVAILABLE_PAYMENT_GATEWAYS } from '../availablePaymentGateways'; import messages from 'lib/text'; -import style from './style.css'; import Dialog from 'material-ui/Dialog'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; +import { AVAILABLE_PAYMENT_GATEWAYS } from '../availablePaymentGateways'; +import GatewaySettings from './gatewaySettings.js'; class EditPaymentGatewayForm extends React.Component { constructor(props) { @@ -37,7 +37,7 @@ class EditPaymentGatewayForm extends React.Component { }; render() { - let { handleSubmit, pristine, submitting, initialValues } = this.props; + const { handleSubmit, pristine, submitting, initialValues } = this.props; const gatewayDetails = AVAILABLE_PAYMENT_GATEWAYS.find( item => item.key === this.props.gateway ); @@ -55,7 +55,7 @@ class EditPaymentGatewayForm extends React.Component { title={gatewayDetails.name} modal={false} open={this.state.open} - autoScrollBodyContent={true} + autoScrollBodyContent contentStyle={{ width: 600 }} onRequestClose={this.handleClose} > @@ -72,7 +72,7 @@ class EditPaymentGatewayForm extends React.Component { />
); - } else { - return null; } + return null; } } diff --git a/src/modules/settings/paymentGateway/components/gatewaySettings.js b/src/modules/settings/paymentGateway/components/gatewaySettings.js index 9713455a..b7ac0d1b 100644 --- a/src/modules/settings/paymentGateway/components/gatewaySettings.js +++ b/src/modules/settings/paymentGateway/components/gatewaySettings.js @@ -4,8 +4,8 @@ import { TextField, SelectField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import messages from 'lib/text'; -import style from './style.css'; import MenuItem from 'material-ui/MenuItem'; +import style from './style.css'; const GatewaySettings = ({ gateway }) => { switch (gateway) { @@ -22,140 +22,134 @@ const GatewaySettings = ({ gateway }) => { export default GatewaySettings; -const PayPalButton = props => { - return ( -
- - - - +const PayPalButton = props => ( +
+ + + + - + - - - - - - + + + + + + - - - - + + + + - - - - - - + + + + + + - -
- ); -}; + +
+); -const LiqPay = props => { - return ( -
- +const LiqPay = props => ( +
+ - + - - - - - + + + + + - -
- ); -}; + +
+); -const StripeElements = props => { - return ( -
- - - - - - -
- ); -}; +const StripeElements = props => ( +
+ + + + + + +
+); diff --git a/src/modules/settings/paymentGateway/index.js b/src/modules/settings/paymentGateway/index.js index d5ef82cc..acc008a1 100644 --- a/src/modules/settings/paymentGateway/index.js +++ b/src/modules/settings/paymentGateway/index.js @@ -2,23 +2,19 @@ import { connect } from 'react-redux'; import { fetchPaymentGateway, updatePaymentGateway } from '../actions'; import Form from './components/form'; -const mapStateToProps = (state, ownProps) => { - return { - gateway: ownProps.gateway, - initialValues: state.settings.paymentGatewayEdit - }; -}; +const mapStateToProps = (state, ownProps) => ({ + gateway: ownProps.gateway, + initialValues: state.settings.paymentGatewayEdit +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: gateway => { - dispatch(fetchPaymentGateway(gateway || ownProps.gateway)); - }, - onSubmit: data => { - dispatch(updatePaymentGateway(ownProps.gateway, data)); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: gateway => { + dispatch(fetchPaymentGateway(gateway || ownProps.gateway)); + }, + onSubmit: data => { + dispatch(updatePaymentGateway(ownProps.gateway, data)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/payments/components/form.js b/src/modules/settings/payments/components/form.js index 9b4d68c9..04fba87c 100644 --- a/src/modules/settings/payments/components/form.js +++ b/src/modules/settings/payments/components/form.js @@ -5,32 +5,30 @@ import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; import { List, ListItem } from 'material-ui/List'; -const MethodItem = ({ method }) => { - return ( -
- - - keyboard_arrow_right - } - style={!method.enabled ? { color: 'rgba(0, 0, 0, 0.3)' } : {}} - primaryText={ -
-
{method.name}
-
- {method.description} -
+const MethodItem = ({ method }) => ( +
+ + + keyboard_arrow_right + } + style={!method.enabled ? { color: 'rgba(0, 0, 0, 0.3)' } : {}} + primaryText={ +
+
{method.name}
+
+ {method.description}
- } - /> - -
- ); -}; +
+ } + /> + +
+); export default class EmailSettings extends React.Component { constructor(props) { @@ -43,7 +41,7 @@ export default class EmailSettings extends React.Component { render() { const { paymentMethods } = this.props; - let methods = paymentMethods.map((method, index) => ( + const methods = paymentMethods.map((method, index) => ( )); diff --git a/src/modules/settings/payments/components/headButtons.js b/src/modules/settings/payments/components/headButtons.js index 357bc5fa..14f2f6ab 100644 --- a/src/modules/settings/payments/components/headButtons.js +++ b/src/modules/settings/payments/components/headButtons.js @@ -8,7 +8,7 @@ const Buttons = () => ( diff --git a/src/modules/settings/payments/head.js b/src/modules/settings/payments/head.js index 84e82ab9..d5ba9460 100644 --- a/src/modules/settings/payments/head.js +++ b/src/modules/settings/payments/head.js @@ -2,13 +2,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return {}; -}; +const mapStateToProps = (state, ownProps) => ({}); -const mapDispatchToProps = (dispatch, ownProps) => { - return {}; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({}); export default withRouter( connect( diff --git a/src/modules/settings/payments/index.js b/src/modules/settings/payments/index.js index 222a9da8..d8c03b16 100644 --- a/src/modules/settings/payments/index.js +++ b/src/modules/settings/payments/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchPaymentMethods } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - paymentMethods: state.settings.paymentMethods - }; -}; +const mapStateToProps = state => ({ + paymentMethods: state.settings.paymentMethods +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchPaymentMethods()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchPaymentMethods()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/paymentsEdit/components/form.js b/src/modules/settings/paymentsEdit/components/form.js index b264e21d..ce5acf6b 100644 --- a/src/modules/settings/paymentsEdit/components/form.js +++ b/src/modules/settings/paymentsEdit/components/form.js @@ -5,15 +5,15 @@ import { TextField, SelectField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import PaymentGateway from 'modules/settings/paymentGateway'; import { AVAILABLE_PAYMENT_GATEWAYS } from 'modules/settings/paymentGateway/availablePaymentGateways'; -import SelectShippingMethodsField from './selectShipping.js'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; import RaisedButton from 'material-ui/RaisedButton'; import MenuItem from 'material-ui/MenuItem'; import Checkbox from 'material-ui/Checkbox'; +import style from './style.css'; +import SelectShippingMethodsField from './selectShipping.js'; const validate = values => { const errors = {}; @@ -50,12 +50,12 @@ class EditPaymentMethodForm extends React.Component { onGatewayChange = gateway => { this.setState({ - gateway: gateway + gateway }); }; render() { - let { + const { handleSubmit, pristine, submitting, @@ -65,7 +65,7 @@ class EditPaymentMethodForm extends React.Component { settings } = this.props; const isAdd = methodId === null || methodId === undefined; - let paymentGateways = []; + const paymentGateways = []; paymentGateways.push(); for (const gateway of AVAILABLE_PAYMENT_GATEWAYS) { paymentGateways.push( @@ -89,10 +89,10 @@ class EditPaymentMethodForm extends React.Component {
{ this.onGatewayChange(currentValue); @@ -113,7 +113,7 @@ class EditPaymentMethodForm extends React.Component {
@@ -121,9 +121,9 @@ class EditPaymentMethodForm extends React.Component {
@@ -147,7 +147,7 @@ class EditPaymentMethodForm extends React.Component {
@@ -171,11 +170,10 @@ class EditPaymentMethodForm extends React.Component { component={TextField} name="conditions.subtotal_max" type="number" - fullWidth={true} - floatingLabelText={ - messages.settings_maxSubtotal + - ` (${settings.currency_symbol})` - } + fullWidth + floatingLabelText={`${messages.settings_maxSubtotal} (${ + settings.currency_symbol + })`} />
@@ -194,7 +192,7 @@ class EditPaymentMethodForm extends React.Component { diff --git a/src/modules/settings/paymentsEdit/components/headButtons.js b/src/modules/settings/paymentsEdit/components/headButtons.js index 90ca8c7a..56e25812 100644 --- a/src/modules/settings/paymentsEdit/components/headButtons.js +++ b/src/modules/settings/paymentsEdit/components/headButtons.js @@ -35,7 +35,7 @@ export default class Buttons extends React.Component { return ( { - return this.state.selectedIds.includes(methodId); - }; + isCheckboxChecked = methodId => this.state.selectedIds.includes(methodId); render() { const items = this.props.shippingMethods.map(method => ( diff --git a/src/modules/settings/paymentsEdit/head.js b/src/modules/settings/paymentsEdit/head.js index b7d7dda4..c9d664a1 100644 --- a/src/modules/settings/paymentsEdit/head.js +++ b/src/modules/settings/paymentsEdit/head.js @@ -3,20 +3,16 @@ import { withRouter } from 'react-router'; import { deletePaymentMethod } from '../actions'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return { - paymentMethod: state.settings.paymentMethodEdit - }; -}; +const mapStateToProps = (state, ownProps) => ({ + paymentMethod: state.settings.paymentMethodEdit +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onDelete: id => { - dispatch(deletePaymentMethod(id)); - ownProps.history.push('/settings/payments'); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onDelete: id => { + dispatch(deletePaymentMethod(id)); + ownProps.history.push('/settings/payments'); + } +}); export default withRouter( connect( diff --git a/src/modules/settings/paymentsEdit/index.js b/src/modules/settings/paymentsEdit/index.js index 2ce224d6..bde27c4c 100644 --- a/src/modules/settings/paymentsEdit/index.js +++ b/src/modules/settings/paymentsEdit/index.js @@ -15,47 +15,45 @@ const mapStateToProps = (state, ownProps) => { : null; return { - methodId: methodId, - gateway: gateway, + methodId, + gateway, settings: state.settings.settings, initialValues: state.settings.paymentMethodEdit, shippingMethods: state.settings.shippingMethods }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - const { methodId } = ownProps.match.params; - if (methodId) { - dispatch(fetchPaymentMethod(methodId)); - } else { - dispatch(receivePaymentMethod({ enabled: true })); - } - dispatch(fetchShippingMethods()); - }, - onSubmit: method => { - if ( - method.conditions && - method.conditions.countries && - !Array.isArray(method.conditions.countries) - ) { - const countriesStr = method.conditions.countries; - method.conditions.countries = countriesStr - .split(',') - .map(item => item.trim().toUpperCase()) - .filter(item => item.length === 2); - } +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + const { methodId } = ownProps.match.params; + if (methodId) { + dispatch(fetchPaymentMethod(methodId)); + } else { + dispatch(receivePaymentMethod({ enabled: true })); + } + dispatch(fetchShippingMethods()); + }, + onSubmit: method => { + if ( + method.conditions && + method.conditions.countries && + !Array.isArray(method.conditions.countries) + ) { + const countriesStr = method.conditions.countries; + method.conditions.countries = countriesStr + .split(',') + .map(item => item.trim().toUpperCase()) + .filter(item => item.length === 2); + } - if (method.id) { - dispatch(updatePaymentMethod(method)); - } else { - dispatch(createPaymentMethod(method)); - ownProps.history.push('/settings/payments'); - } + if (method.id) { + dispatch(updatePaymentMethod(method)); + } else { + dispatch(createPaymentMethod(method)); + ownProps.history.push('/settings/payments'); } - }; -}; + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/redirects/edit/components/form.js b/src/modules/settings/redirects/edit/components/form.js index 8bb79650..00e3a1b5 100644 --- a/src/modules/settings/redirects/edit/components/form.js +++ b/src/modules/settings/redirects/edit/components/form.js @@ -3,11 +3,11 @@ import { Field, reduxForm } from 'redux-form'; import { TextField } from 'redux-form-material-ui'; import messages from 'lib/text'; -import style from './style.css'; import { CustomToggle, MultiSelect } from 'modules/shared/form'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const validate = values => { const errors = {}; @@ -28,7 +28,7 @@ class EditRedirectForm extends React.Component { } render() { - let { handleSubmit, pristine, submitting, redirectId } = this.props; + const { handleSubmit, pristine, submitting, redirectId } = this.props; const isAdd = redirectId === null || redirectId === undefined; return ( @@ -40,27 +40,24 @@ class EditRedirectForm extends React.Component { name="from" component={TextField} floatingLabelText="From (e.g. /old-path)" - fullWidth={true} + fullWidth />
diff --git a/src/modules/settings/redirects/edit/components/headButtons.js b/src/modules/settings/redirects/edit/components/headButtons.js index e4ab5b63..84206729 100644 --- a/src/modules/settings/redirects/edit/components/headButtons.js +++ b/src/modules/settings/redirects/edit/components/headButtons.js @@ -3,7 +3,7 @@ import messages from 'lib/text'; import DeleteConfirmation from 'modules/shared/deleteConfirmation'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -37,7 +37,7 @@ export default class Buttons extends React.Component { return ( ); - } else { - return null; } + return null; } } diff --git a/src/modules/settings/redirects/edit/head.js b/src/modules/settings/redirects/edit/head.js index 47d468f1..7fc30088 100644 --- a/src/modules/settings/redirects/edit/head.js +++ b/src/modules/settings/redirects/edit/head.js @@ -3,20 +3,16 @@ import { withRouter } from 'react-router'; import { deleteRedirect } from '../../actions'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return { - redirect: state.settings.redirectEdit - }; -}; +const mapStateToProps = (state, ownProps) => ({ + redirect: state.settings.redirectEdit +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onDelete: redirectId => { - dispatch(deleteRedirect(redirectId)); - ownProps.history.push('/settings/redirects'); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onDelete: redirectId => { + dispatch(deleteRedirect(redirectId)); + ownProps.history.push('/settings/redirects'); + } +}); export default withRouter( connect( diff --git a/src/modules/settings/redirects/edit/index.js b/src/modules/settings/redirects/edit/index.js index 4acaa1fc..1d5d6206 100644 --- a/src/modules/settings/redirects/edit/index.js +++ b/src/modules/settings/redirects/edit/index.js @@ -10,31 +10,29 @@ import Form from './components/form'; const mapStateToProps = (state, ownProps) => { const { redirectId } = ownProps.match.params; return { - redirectId: redirectId, + redirectId, initialValues: state.settings.redirectEdit }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - const { redirectId } = ownProps.match.params; - if (redirectId) { - dispatch(fetchRedirect(redirectId)); - } else { - dispatch(receiveRedirect({ enabled: true })); - } - }, - onSubmit: redirect => { - if (redirect.id) { - dispatch(updateRedirect(redirect)); - } else { - dispatch(createRedirect(redirect)); - ownProps.history.push('/settings/redirects'); - } +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + const { redirectId } = ownProps.match.params; + if (redirectId) { + dispatch(fetchRedirect(redirectId)); + } else { + dispatch(receiveRedirect({ enabled: true })); } - }; -}; + }, + onSubmit: redirect => { + if (redirect.id) { + dispatch(updateRedirect(redirect)); + } else { + dispatch(createRedirect(redirect)); + ownProps.history.push('/settings/redirects'); + } + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/redirects/list/components/form.js b/src/modules/settings/redirects/list/components/form.js index 7066a96b..a9fa147e 100644 --- a/src/modules/settings/redirects/list/components/form.js +++ b/src/modules/settings/redirects/list/components/form.js @@ -6,32 +6,30 @@ import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; import { List, ListItem } from 'material-ui/List'; -const RedirectItem = ({ redirect }) => { - return ( -
- - - keyboard_arrow_right - } - primaryText={ -
-
{redirect.from}
-
{redirect.to}
-
- 301 -
+const RedirectItem = ({ redirect }) => ( +
+ + + keyboard_arrow_right + } + primaryText={ +
+
{redirect.from}
+
{redirect.to}
+
+ 301
- } - /> - -
- ); -}; +
+ } + /> + +
+); export default class RedirectsList extends React.Component { constructor(props) { @@ -44,7 +42,7 @@ export default class RedirectsList extends React.Component { render() { const { redirects } = this.props; - let listItems = redirects.map((redirect, index) => ( + const listItems = redirects.map((redirect, index) => ( )); diff --git a/src/modules/settings/redirects/list/components/headButtons.js b/src/modules/settings/redirects/list/components/headButtons.js index 6b553b1b..3868b0c6 100644 --- a/src/modules/settings/redirects/list/components/headButtons.js +++ b/src/modules/settings/redirects/list/components/headButtons.js @@ -8,7 +8,7 @@ const Buttons = () => ( diff --git a/src/modules/settings/redirects/list/head.js b/src/modules/settings/redirects/list/head.js index 84e82ab9..d5ba9460 100644 --- a/src/modules/settings/redirects/list/head.js +++ b/src/modules/settings/redirects/list/head.js @@ -2,13 +2,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return {}; -}; +const mapStateToProps = (state, ownProps) => ({}); -const mapDispatchToProps = (dispatch, ownProps) => { - return {}; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({}); export default withRouter( connect( diff --git a/src/modules/settings/redirects/list/index.js b/src/modules/settings/redirects/list/index.js index 33e42960..60ab361d 100644 --- a/src/modules/settings/redirects/list/index.js +++ b/src/modules/settings/redirects/list/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchRedirects } from '../../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - redirects: state.settings.redirects - }; -}; +const mapStateToProps = state => ({ + redirects: state.settings.redirects +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchRedirects()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchRedirects()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/shipping/components/form.js b/src/modules/settings/shipping/components/form.js index 792eb9ef..20fdd06f 100644 --- a/src/modules/settings/shipping/components/form.js +++ b/src/modules/settings/shipping/components/form.js @@ -5,32 +5,30 @@ import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; import { List, ListItem } from 'material-ui/List'; -const MethodItem = ({ method }) => { - return ( -
- - - keyboard_arrow_right - } - style={!method.enabled ? { color: 'rgba(0, 0, 0, 0.3)' } : {}} - primaryText={ -
-
{method.name}
-
- {method.description} -
+const MethodItem = ({ method }) => ( +
+ + + keyboard_arrow_right + } + style={!method.enabled ? { color: 'rgba(0, 0, 0, 0.3)' } : {}} + primaryText={ +
+
{method.name}
+
+ {method.description}
- } - /> - -
- ); -}; +
+ } + /> + +
+); export default class EmailSettings extends React.Component { componentDidMount() { @@ -39,7 +37,7 @@ export default class EmailSettings extends React.Component { render() { const { shippingMethods } = this.props; - let methods = shippingMethods.map((method, index) => ( + const methods = shippingMethods.map((method, index) => ( )); diff --git a/src/modules/settings/shipping/components/headButtons.js b/src/modules/settings/shipping/components/headButtons.js index c7dee5f1..fe049fbc 100644 --- a/src/modules/settings/shipping/components/headButtons.js +++ b/src/modules/settings/shipping/components/headButtons.js @@ -8,7 +8,7 @@ const Buttons = () => ( diff --git a/src/modules/settings/shipping/head.js b/src/modules/settings/shipping/head.js index 84e82ab9..d5ba9460 100644 --- a/src/modules/settings/shipping/head.js +++ b/src/modules/settings/shipping/head.js @@ -2,13 +2,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return {}; -}; +const mapStateToProps = (state, ownProps) => ({}); -const mapDispatchToProps = (dispatch, ownProps) => { - return {}; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({}); export default withRouter( connect( diff --git a/src/modules/settings/shipping/index.js b/src/modules/settings/shipping/index.js index e6fee085..0845d02c 100644 --- a/src/modules/settings/shipping/index.js +++ b/src/modules/settings/shipping/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchShippingMethods } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - shippingMethods: state.settings.shippingMethods - }; -}; +const mapStateToProps = state => ({ + shippingMethods: state.settings.shippingMethods +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchShippingMethods()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchShippingMethods()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/shippingEdit/components/fieldsEditor.js b/src/modules/settings/shippingEdit/components/fieldsEditor.js index a3f168dd..c5016912 100644 --- a/src/modules/settings/shippingEdit/components/fieldsEditor.js +++ b/src/modules/settings/shippingEdit/components/fieldsEditor.js @@ -5,7 +5,6 @@ import { TextField, SelectField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; @@ -13,94 +12,93 @@ import FontIcon from 'material-ui/FontIcon'; import IconMenu from 'material-ui/IconMenu'; import IconButton from 'material-ui/IconButton'; import MenuItem from 'material-ui/MenuItem'; +import style from './style.css'; -const FieldsEditor = ({ fields, meta: { touched, error, submitFailed } }) => { - return ( -
- {fields.map((field, index) => { - const fieldKey = `${field}.key`; - const fieldLabel = `${field}.label`; - const fieldRequired = `${field}.required`; +const FieldsEditor = ({ fields, meta: { touched, error, submitFailed } }) => ( +
+ {fields.map((field, index) => { + const fieldKey = `${field}.key`; + const fieldLabel = `${field}.label`; + const fieldRequired = `${field}.required`; - return ( - -
-
- -
-
- -
-
- +
+
+ +
+
+ +
+
+ +
+
+ + + more_vert + + + } + > + fields.remove(index)} /> -
-
- - - more_vert - - - } - > + {index > 0 && ( + fields.move(index, index - 1)} + /> + )} + {index + 1 < fields.length && ( fields.remove(index)} + primaryText={messages.actions_moveDown} + onClick={() => fields.move(index, index + 1)} /> - {index > 0 && ( - fields.move(index, index - 1)} - /> - )} - {index + 1 < fields.length && ( - fields.move(index, index + 1)} - /> - )} - -
+ )} +
- - ); - })} +
+ + ); + })} -
- fields.push({})} /> -
+
+ fields.push({})} />
- ); -}; +
+); export default FieldsEditor; diff --git a/src/modules/settings/shippingEdit/components/form.js b/src/modules/settings/shippingEdit/components/form.js index 209193e0..c796a50c 100644 --- a/src/modules/settings/shippingEdit/components/form.js +++ b/src/modules/settings/shippingEdit/components/form.js @@ -2,13 +2,13 @@ import React from 'react'; import { Field, FieldArray, reduxForm } from 'redux-form'; import { TextField } from 'redux-form-material-ui'; import { CustomToggle } from 'modules/shared/form'; -import FieldsEditor from './fieldsEditor'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; +import FieldsEditor from './fieldsEditor'; const validate = values => { const errors = {}; @@ -29,7 +29,7 @@ class EditShippingMethodForm extends React.Component { } render() { - let { + const { handleSubmit, pristine, submitting, @@ -51,7 +51,7 @@ class EditShippingMethodForm extends React.Component {
@@ -59,9 +59,9 @@ class EditShippingMethodForm extends React.Component {
@@ -72,11 +72,10 @@ class EditShippingMethodForm extends React.Component { component={TextField} name="price" type="number" - fullWidth={true} - floatingLabelText={ - messages.settings_shippingRate + - ` (${settings.currency_symbol})` - } + fullWidth + floatingLabelText={`${messages.settings_shippingRate} (${ + settings.currency_symbol + })`} />
@@ -100,7 +99,7 @@ class EditShippingMethodForm extends React.Component {
@@ -143,11 +141,10 @@ class EditShippingMethodForm extends React.Component { component={TextField} name="conditions.weight_total_max" type="number" - fullWidth={true} - floatingLabelText={ - messages.settings_maxTotalWeight + - ` (${settings.weight_unit})` - } + fullWidth + floatingLabelText={`${ + messages.settings_maxTotalWeight + } (${settings.weight_unit})`} />
@@ -158,11 +155,10 @@ class EditShippingMethodForm extends React.Component { component={TextField} name="conditions.subtotal_min" type="number" - fullWidth={true} - floatingLabelText={ - messages.settings_minSubtotal + - ` (${settings.currency_symbol})` - } + fullWidth + floatingLabelText={`${messages.settings_minSubtotal} (${ + settings.currency_symbol + })`} />
@@ -170,11 +166,10 @@ class EditShippingMethodForm extends React.Component { component={TextField} name="conditions.subtotal_max" type="number" - fullWidth={true} - floatingLabelText={ - messages.settings_maxSubtotal + - ` (${settings.currency_symbol})` - } + fullWidth + floatingLabelText={`${messages.settings_maxSubtotal} (${ + settings.currency_symbol + })`} />
@@ -207,7 +202,7 @@ class EditShippingMethodForm extends React.Component { diff --git a/src/modules/settings/shippingEdit/components/headButtons.js b/src/modules/settings/shippingEdit/components/headButtons.js index 24f25145..4af56e6e 100644 --- a/src/modules/settings/shippingEdit/components/headButtons.js +++ b/src/modules/settings/shippingEdit/components/headButtons.js @@ -35,7 +35,7 @@ export default class Buttons extends React.Component { return ( { - return { - shippingMethod: state.settings.shippingMethodEdit - }; -}; +const mapStateToProps = (state, ownProps) => ({ + shippingMethod: state.settings.shippingMethodEdit +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onDelete: id => { - dispatch(deleteShippingMethod(id)); - ownProps.history.push('/settings/shipping'); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onDelete: id => { + dispatch(deleteShippingMethod(id)); + ownProps.history.push('/settings/shipping'); + } +}); export default withRouter( connect( diff --git a/src/modules/settings/shippingEdit/index.js b/src/modules/settings/shippingEdit/index.js index d3c86eb5..b4552f31 100644 --- a/src/modules/settings/shippingEdit/index.js +++ b/src/modules/settings/shippingEdit/index.js @@ -10,96 +10,94 @@ import Form from './components/form'; const mapStateToProps = (state, ownProps) => { const { methodId } = ownProps.match.params; return { - methodId: methodId, + methodId, settings: state.settings.settings, initialValues: state.settings.shippingMethodEdit }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - const { methodId } = ownProps.match.params; - if (methodId) { - dispatch(fetchShippingMethod(methodId)); - } else { - dispatch( - receiveShippingMethod({ - enabled: true, - fields: [ - { - key: 'full_name', - label: '', - required: true - }, - { - key: 'address1', - label: '', - required: true - }, - { - key: 'address2', - label: '', - required: false - }, - { - key: 'postal_code', - label: '', - required: false - }, - { - key: 'phone', - label: '', - required: false - } - ] - }) - ); +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + const { methodId } = ownProps.match.params; + if (methodId) { + dispatch(fetchShippingMethod(methodId)); + } else { + dispatch( + receiveShippingMethod({ + enabled: true, + fields: [ + { + key: 'full_name', + label: '', + required: true + }, + { + key: 'address1', + label: '', + required: true + }, + { + key: 'address2', + label: '', + required: false + }, + { + key: 'postal_code', + label: '', + required: false + }, + { + key: 'phone', + label: '', + required: false + } + ] + }) + ); + } + }, + onSubmit: method => { + if (method.conditions) { + if ( + method.conditions.countries && + !Array.isArray(method.conditions.countries) + ) { + const countriesStr = method.conditions.countries; + method.conditions.countries = countriesStr + .split(',') + .map(item => item.trim().toUpperCase()) + .filter(item => item.length === 2); } - }, - onSubmit: method => { - if (method.conditions) { - if ( - method.conditions.countries && - !Array.isArray(method.conditions.countries) - ) { - const countriesStr = method.conditions.countries; - method.conditions.countries = countriesStr - .split(',') - .map(item => item.trim().toUpperCase()) - .filter(item => item.length === 2); - } - if ( - method.conditions.states && - !Array.isArray(method.conditions.states) - ) { - const statesStr = method.conditions.states; - method.conditions.states = statesStr - .split(',') - .map(item => item.trim()); - } - - if ( - method.conditions.cities && - !Array.isArray(method.conditions.cities) - ) { - const citiesStr = method.conditions.cities; - method.conditions.cities = citiesStr - .split(',') - .map(item => item.trim()); - } + if ( + method.conditions.states && + !Array.isArray(method.conditions.states) + ) { + const statesStr = method.conditions.states; + method.conditions.states = statesStr + .split(',') + .map(item => item.trim()); } - if (method.id) { - dispatch(updateShippingMethod(method)); - } else { - dispatch(createShippingMethod(method)); - ownProps.history.push('/settings/shipping'); + if ( + method.conditions.cities && + !Array.isArray(method.conditions.cities) + ) { + const citiesStr = method.conditions.cities; + method.conditions.cities = citiesStr + .split(',') + .map(item => item.trim()); } } - }; -}; + + if (method.id) { + dispatch(updateShippingMethod(method)); + } else { + dispatch(createShippingMethod(method)); + ownProps.history.push('/settings/shipping'); + } + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/smtp/components/form.js b/src/modules/settings/smtp/components/form.js index f4a69fd0..300580d8 100644 --- a/src/modules/settings/smtp/components/form.js +++ b/src/modules/settings/smtp/components/form.js @@ -3,10 +3,10 @@ import { Field, reduxForm } from 'redux-form'; import { TextField } from 'redux-form-material-ui'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; class EmailSettings extends React.Component { componentDidMount() { @@ -14,7 +14,7 @@ class EmailSettings extends React.Component { } render() { - let { handleSubmit, pristine, submitting, initialValues } = this.props; + const { handleSubmit, pristine, submitting, initialValues } = this.props; return ( @@ -56,7 +56,7 @@ class EmailSettings extends React.Component {
@@ -73,7 +73,7 @@ class EmailSettings extends React.Component {
diff --git a/src/modules/settings/smtp/index.js b/src/modules/settings/smtp/index.js index 64462596..dc4f0dc6 100644 --- a/src/modules/settings/smtp/index.js +++ b/src/modules/settings/smtp/index.js @@ -2,22 +2,18 @@ import { connect } from 'react-redux'; import { fetchEmailSettings, updateEmailSettings } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - initialValues: state.settings.emailSettings - }; -}; +const mapStateToProps = state => ({ + initialValues: state.settings.emailSettings +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchEmailSettings()); - }, - onSubmit: values => { - dispatch(updateEmailSettings(values)); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchEmailSettings()); + }, + onSubmit: values => { + dispatch(updateEmailSettings(values)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/theme/components/form.js b/src/modules/settings/theme/components/form.js index 1d3edeca..6d8d22d6 100644 --- a/src/modules/settings/theme/components/form.js +++ b/src/modules/settings/theme/components/form.js @@ -1,13 +1,13 @@ import React from 'react'; import messages from 'lib/text'; -import style from './style.css'; import api from 'lib/api'; import ThemeSettings from 'modules/settings/themeSettings'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; import Divider from 'material-ui/Divider'; +import style from './style.css'; const styles = { button: { @@ -33,7 +33,7 @@ export default class Theme extends React.Component { if (json.file) { window.location = json.file; } else { - alert('Error: ' + JSON.stringify(json)); + alert(`Error: ${JSON.stringify(json)}`); } }); } @@ -41,7 +41,7 @@ export default class Theme extends React.Component { onImportFileChoose(e) { this.props.installRequest(); const file = e.target.files[0]; - var formData = new FormData(); + const formData = new FormData(); formData.append('file', file); api.theme.install(formData); @@ -67,7 +67,7 @@ export default class Theme extends React.Component { } disabled={exportInProcess || installInProcess} onClick={this.onExportClick.bind(this)} - primary={true} + primary />
@@ -95,7 +95,7 @@ export default class Theme extends React.Component { disabled={installInProcess} labelPosition="before" containerElement="label" - primary={true} + primary > { - return { - exportInProcess: state.settings.exportInProcess, - installInProcess: state.settings.installInProcess - }; -}; +const mapStateToProps = state => ({ + exportInProcess: state.settings.exportInProcess, + installInProcess: state.settings.installInProcess +}); -const mapDispatchToProps = dispatch => { - return { - exportRequest: () => { - dispatch(exportRequest()); - }, - exportReceive: () => { - dispatch(exportReceive()); - }, - installRequest: () => { - dispatch(installRequest()); - }, - installReceive: () => { - dispatch(installReceive()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + exportRequest: () => { + dispatch(exportRequest()); + }, + exportReceive: () => { + dispatch(exportReceive()); + }, + installRequest: () => { + dispatch(installRequest()); + }, + installReceive: () => { + dispatch(installReceive()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/themeSettings/components/arrayEditor.js b/src/modules/settings/themeSettings/components/arrayEditor.js index 24102878..d597ba08 100644 --- a/src/modules/settings/themeSettings/components/arrayEditor.js +++ b/src/modules/settings/themeSettings/components/arrayEditor.js @@ -1,84 +1,82 @@ import React from 'react'; import messages from 'lib/text'; -import style from './style.css'; -import DynamicEditControl from './dynamicEditControl'; import Paper from 'material-ui/Paper'; import FlatButton from 'material-ui/FlatButton'; import FontIcon from 'material-ui/FontIcon'; import FloatingActionButton from 'material-ui/FloatingActionButton'; +import DynamicEditControl from './dynamicEditControl'; +import style from './style.css'; const ArrayEditor = ({ label, properties, fields, meta: { touched, error, submitFailed } -}) => { - return ( -
-
- {label} - fields.push({})} - style={{ marginLeft: '20px' }} - > - add - -
+}) => ( +
+
+ {label} + fields.push({})} + style={{ marginLeft: '20px' }} + > + add + +
+ +
    + {fields.map((field, index) => ( +
  1. + +
    + fields.remove(index)} + /> -
      - {fields.map((field, index) => ( -
    1. - -
      + {index > 0 && ( fields.remove(index)} + label={messages.actions_moveUp} + onClick={() => fields.move(index, index - 1)} /> + )} - {index > 0 && ( - fields.move(index, index - 1)} - /> - )} + {index + 1 < fields.length && ( + fields.move(index, index + 1)} + /> + )} +
      - {index + 1 < fields.length && ( - fields.move(index, index + 1)} +
      + {properties.map((property, propertyIndex) => { + const fieldName = `${field}.${property.key}`; + return ( + - )} -
      - -
      - {properties.map((property, propertyIndex) => { - const fieldName = `${field}.${property.key}`; - return ( - - ); - })} -
      -
      -
    2. - ))} -
    -
    - ); -}; + ); + })} +
+ + + ))} + +
+); export default ArrayEditor; diff --git a/src/modules/settings/themeSettings/components/dynamicEditControl.js b/src/modules/settings/themeSettings/components/dynamicEditControl.js index 0556ef23..83e18612 100644 --- a/src/modules/settings/themeSettings/components/dynamicEditControl.js +++ b/src/modules/settings/themeSettings/components/dynamicEditControl.js @@ -4,12 +4,11 @@ import { TextField, SelectField } from 'redux-form-material-ui'; import { CustomToggle, NumberField, ColorField } from 'modules/shared/form'; import * as helper from 'lib/helper'; +import MenuItem from 'material-ui/MenuItem'; import style from './style.css'; import ArrayEditor from './arrayEditor'; import ImageEditor from './imageEditor'; -import MenuItem from 'material-ui/MenuItem'; - const DynamicEditControl = ({ type, fieldName, @@ -25,12 +24,13 @@ const DynamicEditControl = ({ return ( ); - } else if (type === 'string' && hasOptions) { + } + if (type === 'string' && hasOptions) { const selectOptions = options.map((option, index) => ( )); @@ -39,22 +39,25 @@ const DynamicEditControl = ({ component={SelectField} name={fieldName} floatingLabelText={label} - fullWidth={true} - autoWidth={true} + fullWidth + autoWidth > {selectOptions} ); - } else if (type === 'number') { + } + if (type === 'number') { return ; - } else if (type === 'color') { + } + if (type === 'color') { return (
); - } else if (type === 'boolean') { + } + if (type === 'boolean') { return ( ); - } else if (type === 'array' && hasProperties) { + } + if (type === 'array' && hasProperties) { return ( ); - } else if (type === 'image') { + } + if (type === 'image') { return ; - } else { - return null; } + return null; }; export default DynamicEditControl; diff --git a/src/modules/settings/themeSettings/components/form.js b/src/modules/settings/themeSettings/components/form.js index 6c688f73..cbcfa085 100644 --- a/src/modules/settings/themeSettings/components/form.js +++ b/src/modules/settings/themeSettings/components/form.js @@ -3,12 +3,12 @@ import { reduxForm } from 'redux-form'; import messages from 'lib/text'; import sortBy from 'lodash/sortBy'; -import style from './style.css'; -import DynamicEditControl from './dynamicEditControl'; import Paper from 'material-ui/Paper'; import FlatButton from 'material-ui/FlatButton'; import RaisedButton from 'material-ui/RaisedButton'; +import DynamicEditControl from './dynamicEditControl'; +import style from './style.css'; class ThemeSettings extends React.Component { componentDidMount() { @@ -16,7 +16,7 @@ class ThemeSettings extends React.Component { } render() { - let { + const { handleSubmit, pristine, submitting, @@ -75,7 +75,7 @@ class ThemeSettings extends React.Component { @@ -83,9 +83,8 @@ class ThemeSettings extends React.Component { ); - } else { - return null; } + return null; } } diff --git a/src/modules/settings/themeSettings/components/imageEditor.js b/src/modules/settings/themeSettings/components/imageEditor.js index 2cd39c04..c17281b7 100644 --- a/src/modules/settings/themeSettings/components/imageEditor.js +++ b/src/modules/settings/themeSettings/components/imageEditor.js @@ -1,40 +1,40 @@ -import React from 'react'; -import api from 'lib/api'; -import ImageUpload from 'modules/shared/imageUpload'; -import settings from 'lib/settings'; - -export default class ThemeImageUpload extends React.Component { - onDelete = () => { - const fileName = this.props.input.value; - api.theme.assets.deleteFile(fileName).then(() => { - this.props.input.onChange(''); - }); - }; - - onUpload = formData => { - api.theme.assets.uploadFile(formData).then(({ status, json }) => { - const fileName = json.file; - this.props.input.onChange(fileName); - }); - }; - - render() { - let { input, label } = this.props; - const imageUrl = - input.value && input.value.length > 0 - ? settings.assetsBaseURL + '/assets/images/' + input.value - : null; - - return ( -
-

{label}

- -
- ); - } -} +import React from 'react'; +import api from 'lib/api'; +import ImageUpload from 'modules/shared/imageUpload'; +import settings from 'lib/settings'; + +export default class ThemeImageUpload extends React.Component { + onDelete = () => { + const fileName = this.props.input.value; + api.theme.assets.deleteFile(fileName).then(() => { + this.props.input.onChange(''); + }); + }; + + onUpload = formData => { + api.theme.assets.uploadFile(formData).then(({ status, json }) => { + const fileName = json.file; + this.props.input.onChange(fileName); + }); + }; + + render() { + const { input, label } = this.props; + const imageUrl = + input.value && input.value.length > 0 + ? `${settings.assetsBaseURL}/assets/images/${input.value}` + : null; + + return ( +
+

{label}

+ +
+ ); + } +} diff --git a/src/modules/settings/themeSettings/index.js b/src/modules/settings/themeSettings/index.js index 3665a606..ed85b1ca 100644 --- a/src/modules/settings/themeSettings/index.js +++ b/src/modules/settings/themeSettings/index.js @@ -2,23 +2,19 @@ import { connect } from 'react-redux'; import { fetchThemeSettings, updateThemeSettings } from '../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - initialValues: state.settings.themeSettings, - settingsSchema: state.settings.themeSettingsSchema - }; -}; +const mapStateToProps = state => ({ + initialValues: state.settings.themeSettings, + settingsSchema: state.settings.themeSettingsSchema +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchThemeSettings()); - }, - onSubmit: values => { - dispatch(updateThemeSettings(values)); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchThemeSettings()); + }, + onSubmit: values => { + dispatch(updateThemeSettings(values)); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/tokens/edit/components/form.js b/src/modules/settings/tokens/edit/components/form.js index 4e86c219..16666906 100644 --- a/src/modules/settings/tokens/edit/components/form.js +++ b/src/modules/settings/tokens/edit/components/form.js @@ -3,13 +3,13 @@ import { Field, reduxForm } from 'redux-form'; import { TextField } from 'redux-form-material-ui'; import messages from 'lib/text'; -import style from './style.css'; import ConfirmationDialog from 'modules/shared/confirmation'; import { MultiSelect } from 'modules/shared/form'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const Scopes = [ 'admin', @@ -72,7 +72,7 @@ class EditTokenForm extends React.Component { } render() { - let { + const { handleSubmit, pristine, submitting, @@ -93,13 +93,13 @@ class EditTokenForm extends React.Component { name="name" component={TextField} floatingLabelText={messages.settings_tokenName} - fullWidth={true} + fullWidth /> @@ -107,7 +107,7 @@ class EditTokenForm extends React.Component { name="expiration" component={TextField} floatingLabelText={messages.settings_tokenExp} - fullWidth={true} + fullWidth type="number" />
{messages.settings_selectScopes}
@@ -122,7 +122,7 @@ class EditTokenForm extends React.Component { {!isAdd && ( @@ -130,7 +130,7 @@ class EditTokenForm extends React.Component { @@ -144,7 +144,7 @@ class EditTokenForm extends React.Component { description={newToken} submitLabel={messages.actions_done} cancelLabel={messages.cancel} - modal={true} + modal /> { const { tokenId } = ownProps.match.params; return { - tokenId: tokenId, + tokenId, initialValues: state.settings.tokenEdit, newToken: state.settings.newToken }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - const { tokenId } = ownProps.match.params; - if (tokenId) { - dispatch(fetchToken(tokenId)); - } else { - dispatch(receiveToken({ expiration: 24 })); - } - }, - onSubmit: token => { - if (token.id) { - dispatch(updateToken(token)); - } else { - dispatch(createToken(token)); - } - }, - onDelete: () => { - const { tokenId } = ownProps.match.params; - dispatch(deleteToken(tokenId)); - ownProps.history.push('/settings/tokens'); +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + const { tokenId } = ownProps.match.params; + if (tokenId) { + dispatch(fetchToken(tokenId)); + } else { + dispatch(receiveToken({ expiration: 24 })); } - }; -}; + }, + onSubmit: token => { + if (token.id) { + dispatch(updateToken(token)); + } else { + dispatch(createToken(token)); + } + }, + onDelete: () => { + const { tokenId } = ownProps.match.params; + dispatch(deleteToken(tokenId)); + ownProps.history.push('/settings/tokens'); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/tokens/list/components/form.js b/src/modules/settings/tokens/list/components/form.js index ac7af0f5..3349c8f8 100644 --- a/src/modules/settings/tokens/list/components/form.js +++ b/src/modules/settings/tokens/list/components/form.js @@ -6,31 +6,29 @@ import Divider from 'material-ui/Divider'; import FontIcon from 'material-ui/FontIcon'; import { List, ListItem } from 'material-ui/List'; -const TokenItem = ({ token }) => { - return ( -
- - - keyboard_arrow_right - } - primaryText={ -
-
{token.name}
-
- {token.email} -
+const TokenItem = ({ token }) => ( +
+ + + keyboard_arrow_right + } + primaryText={ +
+
{token.name}
+
+ {token.email}
- } - /> - -
- ); -}; +
+ } + /> + +
+); export default class TokensList extends React.Component { componentDidMount() { @@ -39,7 +37,7 @@ export default class TokensList extends React.Component { render() { const { tokens } = this.props; - let listItems = tokens.map((token, index) => ( + const listItems = tokens.map((token, index) => ( )); diff --git a/src/modules/settings/tokens/list/components/headButtons.js b/src/modules/settings/tokens/list/components/headButtons.js index c5794588..828fa193 100644 --- a/src/modules/settings/tokens/list/components/headButtons.js +++ b/src/modules/settings/tokens/list/components/headButtons.js @@ -8,7 +8,7 @@ const Buttons = () => ( diff --git a/src/modules/settings/tokens/list/head.js b/src/modules/settings/tokens/list/head.js index 84e82ab9..d5ba9460 100644 --- a/src/modules/settings/tokens/list/head.js +++ b/src/modules/settings/tokens/list/head.js @@ -2,13 +2,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return {}; -}; +const mapStateToProps = (state, ownProps) => ({}); -const mapDispatchToProps = (dispatch, ownProps) => { - return {}; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({}); export default withRouter( connect( diff --git a/src/modules/settings/tokens/list/index.js b/src/modules/settings/tokens/list/index.js index 22c506ac..ad6c194b 100644 --- a/src/modules/settings/tokens/list/index.js +++ b/src/modules/settings/tokens/list/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchTokens } from '../../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - tokens: state.settings.tokens - }; -}; +const mapStateToProps = state => ({ + tokens: state.settings.tokens +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchTokens()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchTokens()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/webhooks/edit/components/form.js b/src/modules/settings/webhooks/edit/components/form.js index 746b9741..aaddd7c8 100644 --- a/src/modules/settings/webhooks/edit/components/form.js +++ b/src/modules/settings/webhooks/edit/components/form.js @@ -3,11 +3,11 @@ import { Field, reduxForm } from 'redux-form'; import { TextField } from 'redux-form-material-ui'; import messages from 'lib/text'; -import style from './style.css'; import { CustomToggle, MultiSelect } from 'modules/shared/form'; import Paper from 'material-ui/Paper'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; const WEBHOOK_EVENTS = [ 'order.created', @@ -40,7 +40,7 @@ class EditWebhookForm extends React.Component { } render() { - let { + const { handleSubmit, pristine, submitting, @@ -58,20 +58,20 @@ class EditWebhookForm extends React.Component { name="description" component={TextField} floatingLabelText={messages.description} - fullWidth={true} - multiLine={true} + fullWidth + multiLine />
diff --git a/src/modules/settings/webhooks/edit/components/headButtons.js b/src/modules/settings/webhooks/edit/components/headButtons.js index 511426a6..9249a3fa 100644 --- a/src/modules/settings/webhooks/edit/components/headButtons.js +++ b/src/modules/settings/webhooks/edit/components/headButtons.js @@ -5,7 +5,7 @@ import DeleteConfirmation from 'modules/shared/deleteConfirmation'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; import FlatButton from 'material-ui/FlatButton'; -const Fragment = React.Fragment; +const { Fragment } = React; export default class Buttons extends React.Component { constructor(props) { @@ -37,7 +37,7 @@ export default class Buttons extends React.Component { return ( ); - } else { - return null; } + return null; } } diff --git a/src/modules/settings/webhooks/edit/head.js b/src/modules/settings/webhooks/edit/head.js index b5e5ab62..edc15b18 100644 --- a/src/modules/settings/webhooks/edit/head.js +++ b/src/modules/settings/webhooks/edit/head.js @@ -3,20 +3,16 @@ import { withRouter } from 'react-router'; import { deleteWebhook } from '../../actions'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return { - webhook: state.settings.webhookEdit - }; -}; +const mapStateToProps = (state, ownProps) => ({ + webhook: state.settings.webhookEdit +}); -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onDelete: webhookId => { - dispatch(deleteWebhook(webhookId)); - ownProps.history.push('/settings/webhooks'); - } - }; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({ + onDelete: webhookId => { + dispatch(deleteWebhook(webhookId)); + ownProps.history.push('/settings/webhooks'); + } +}); export default withRouter( connect( diff --git a/src/modules/settings/webhooks/edit/index.js b/src/modules/settings/webhooks/edit/index.js index 1d25c770..8ae0df2d 100644 --- a/src/modules/settings/webhooks/edit/index.js +++ b/src/modules/settings/webhooks/edit/index.js @@ -10,31 +10,29 @@ import Form from './components/form'; const mapStateToProps = (state, ownProps) => { const { webhookId } = ownProps.match.params; return { - webhookId: webhookId, + webhookId, initialValues: state.settings.webhookEdit }; }; -const mapDispatchToProps = (dispatch, ownProps) => { - return { - onLoad: () => { - const { webhookId } = ownProps.match.params; - if (webhookId) { - dispatch(fetchWebhook(webhookId)); - } else { - dispatch(receiveWebhook({ enabled: true })); - } - }, - onSubmit: webhook => { - if (webhook.id) { - dispatch(updateWebhook(webhook)); - } else { - dispatch(createWebhook(webhook)); - ownProps.history.push('/settings/webhooks'); - } +const mapDispatchToProps = (dispatch, ownProps) => ({ + onLoad: () => { + const { webhookId } = ownProps.match.params; + if (webhookId) { + dispatch(fetchWebhook(webhookId)); + } else { + dispatch(receiveWebhook({ enabled: true })); } - }; -}; + }, + onSubmit: webhook => { + if (webhook.id) { + dispatch(updateWebhook(webhook)); + } else { + dispatch(createWebhook(webhook)); + ownProps.history.push('/settings/webhooks'); + } + } +}); export default connect( mapStateToProps, diff --git a/src/modules/settings/webhooks/list/components/form.js b/src/modules/settings/webhooks/list/components/form.js index 1fcd856a..2df570e4 100644 --- a/src/modules/settings/webhooks/list/components/form.js +++ b/src/modules/settings/webhooks/list/components/form.js @@ -44,7 +44,7 @@ export default class WebhooksList extends React.Component { render() { const { webhooks } = this.props; - let listItems = webhooks.map((webhook, index) => ( + const listItems = webhooks.map((webhook, index) => ( )); diff --git a/src/modules/settings/webhooks/list/components/headButtons.js b/src/modules/settings/webhooks/list/components/headButtons.js index 1cd71daf..da491a41 100644 --- a/src/modules/settings/webhooks/list/components/headButtons.js +++ b/src/modules/settings/webhooks/list/components/headButtons.js @@ -8,7 +8,7 @@ const Buttons = () => ( diff --git a/src/modules/settings/webhooks/list/head.js b/src/modules/settings/webhooks/list/head.js index 84e82ab9..d5ba9460 100644 --- a/src/modules/settings/webhooks/list/head.js +++ b/src/modules/settings/webhooks/list/head.js @@ -2,13 +2,9 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import Buttons from './components/headButtons'; -const mapStateToProps = (state, ownProps) => { - return {}; -}; +const mapStateToProps = (state, ownProps) => ({}); -const mapDispatchToProps = (dispatch, ownProps) => { - return {}; -}; +const mapDispatchToProps = (dispatch, ownProps) => ({}); export default withRouter( connect( diff --git a/src/modules/settings/webhooks/list/index.js b/src/modules/settings/webhooks/list/index.js index 6c52b863..0b07209d 100644 --- a/src/modules/settings/webhooks/list/index.js +++ b/src/modules/settings/webhooks/list/index.js @@ -2,19 +2,15 @@ import { connect } from 'react-redux'; import { fetchWebhooks } from '../../actions'; import Form from './components/form'; -const mapStateToProps = state => { - return { - webhooks: state.settings.webhooks - }; -}; +const mapStateToProps = state => ({ + webhooks: state.settings.webhooks +}); -const mapDispatchToProps = dispatch => { - return { - onLoad: () => { - dispatch(fetchWebhooks()); - } - }; -}; +const mapDispatchToProps = dispatch => ({ + onLoad: () => { + dispatch(fetchWebhooks()); + } +}); export default connect( mapStateToProps, diff --git a/src/modules/shared/confirmation/index.js b/src/modules/shared/confirmation/index.js index b81a5612..5d05d034 100644 --- a/src/modules/shared/confirmation/index.js +++ b/src/modules/shared/confirmation/index.js @@ -49,8 +49,8 @@ export default class ConfirmationDialog extends React.Component { />, ]; diff --git a/src/modules/shared/deleteConfirmation/index.js b/src/modules/shared/deleteConfirmation/index.js index 2efdf0e4..b6d9d172 100644 --- a/src/modules/shared/deleteConfirmation/index.js +++ b/src/modules/shared/deleteConfirmation/index.js @@ -56,8 +56,8 @@ export default class ConfirmationDialog extends React.Component { />, ]; diff --git a/src/modules/shared/editor/index.js b/src/modules/shared/editor/index.js index 187ffea3..e7f7b4bb 100644 --- a/src/modules/shared/editor/index.js +++ b/src/modules/shared/editor/index.js @@ -1,6 +1,6 @@ import React from 'react'; -import TinyMCE from '../tinymce'; import settings from 'lib/settings'; +import TinyMCE from '../tinymce'; const config = { inline: true, diff --git a/src/modules/shared/form/index.js b/src/modules/shared/form/index.js index d0c206f3..54fd0cf7 100644 --- a/src/modules/shared/form/index.js +++ b/src/modules/shared/form/index.js @@ -10,20 +10,18 @@ export const CustomToggle = ({ className = '', disabled = false, style -}) => { - return ( - { - input.onChange(isInputChecked); - }} - className={className} - disabled={disabled} - style={style} - /> - ); -}; +}) => ( + { + input.onChange(isInputChecked); + }} + className={className} + disabled={disabled} + style={style} + /> +); export const NumberField = ({ input, @@ -34,13 +32,13 @@ export const NumberField = ({ }) => ( { let number = parseFloat(value); - number = number ? number : 0; + number = number || 0; input.onChange(number); }} /> @@ -83,9 +81,7 @@ export class MultiSelect extends React.Component { this.props.input.onChange(newSelectedItems); }; - isCheckboxChecked = item => { - return this.state.selectedItems.includes(item); - }; + isCheckboxChecked = item => this.state.selectedItems.includes(item); render() { const { items, disabled, columns = 2 } = this.props; @@ -93,21 +89,20 @@ export class MultiSelect extends React.Component { const elements = items.map((item, index) => (
- {item && - item !== '' && ( - { - this.onCheckboxChecked(item); - }} - /> - } - primaryText={item} - /> - )} + {item && item !== '' && ( + { + this.onCheckboxChecked(item); + }} + /> + } + primaryText={item} + /> + )}
)); diff --git a/src/modules/shared/imageUpload/index.js b/src/modules/shared/imageUpload/index.js index dd24b67e..d96121bc 100644 --- a/src/modules/shared/imageUpload/index.js +++ b/src/modules/shared/imageUpload/index.js @@ -31,7 +31,7 @@ export default class ImageUpload extends React.Component { } onDrop = files => { - let form = new FormData(); + const form = new FormData(); form.append('file', files[0]); this.props.onUpload(form); }; @@ -83,7 +83,7 @@ export default class ImageUpload extends React.Component {
{ this.dropzone.open(); @@ -96,7 +96,7 @@ export default class ImageUpload extends React.Component { {hasPreview && ( { - let sortedItems = arrayMove(images, oldIndex, newIndex); - let withNewPosition = sortedItems.map((image, index) => { + const sortedItems = arrayMove(images, oldIndex, newIndex); + const withNewPosition = sortedItems.map((image, index) => { image.position = index; return image; }); @@ -69,9 +69,8 @@ const Gallery = ({
); - } else { - return ; } + return ; }; export default Gallery; diff --git a/src/modules/shared/imageUploadMultiple/item.js b/src/modules/shared/imageUploadMultiple/item.js index 8b62b9f7..cef828d8 100644 --- a/src/modules/shared/imageUploadMultiple/item.js +++ b/src/modules/shared/imageUploadMultiple/item.js @@ -1,10 +1,10 @@ import React from 'react'; import messages from 'lib/text'; -import style from './style.css'; import Paper from 'material-ui/Paper'; import FontIcon from 'material-ui/FontIcon'; import IconButton from 'material-ui/IconButton'; +import style from './style.css'; const GalleryItem = ({ url, alt, id, onDelete, onImageEdit }) => ( @@ -13,7 +13,7 @@ const GalleryItem = ({ url, alt, id, onDelete, onImageEdit }) => (
( { diff --git a/src/modules/shared/imageUploadMultiple/uploader.js b/src/modules/shared/imageUploadMultiple/uploader.js index 2bd93169..930df38c 100644 --- a/src/modules/shared/imageUploadMultiple/uploader.js +++ b/src/modules/shared/imageUploadMultiple/uploader.js @@ -1,14 +1,14 @@ import React from 'react'; import Dropzone from 'react-dropzone'; import messages from 'lib/text'; -import style from './style.css'; import Snackbar from 'material-ui/Snackbar'; import RaisedButton from 'material-ui/RaisedButton'; +import style from './style.css'; export default class MultiUploader extends React.Component { onDrop = files => { - let form = new FormData(); + const form = new FormData(); files.map(file => { form.append('file', file); }); @@ -22,8 +22,8 @@ export default class MultiUploader extends React.Component {
{ this.dropzone = node; @@ -41,7 +41,7 @@ export default class MultiUploader extends React.Component { {!uploading && ( { diff --git a/src/modules/shared/productSearch/index.js b/src/modules/shared/productSearch/index.js index 2c0f4a81..bfbf2613 100644 --- a/src/modules/shared/productSearch/index.js +++ b/src/modules/shared/productSearch/index.js @@ -17,20 +17,18 @@ import { TableRowColumn } from 'material-ui/Table'; -const SearchBox = ({ text, onChange }) => { - return ( - - ); -}; +const SearchBox = ({ text, onChange }) => ( + +); const SearchResult = ({ products, selectedId, settings, onSelect }) => { const rows = products.map((product, index) => { - let priceFormatted = helper.formatCurrency(product.price, settings); + const priceFormatted = helper.formatCurrency(product.price, settings); const isSelected = product.id === selectedId; return ( @@ -48,7 +46,7 @@ const SearchResult = ({ products, selectedId, settings, onSelect }) => { return ( @@ -137,11 +135,7 @@ export default class ConfirmationDialog extends React.Component { onClick={this.handleCancel} style={{ marginRight: 10 }} />, - + ]; return ( diff --git a/src/modules/shared/tinymce/components/TinyMCE.js b/src/modules/shared/tinymce/components/TinyMCE.js index a715ed90..4eabe9d9 100644 --- a/src/modules/shared/tinymce/components/TinyMCE.js +++ b/src/modules/shared/tinymce/components/TinyMCE.js @@ -71,9 +71,7 @@ const EVENTS = [ 'dirty' ]; -const HANDLER_NAMES = EVENTS.map(event => { - return 'on' + ucFirst(event); -}); +const HANDLER_NAMES = EVENTS.map(event => `on${ucFirst(event)}`); export default class TinyMCE extends React.Component { constructor(props) { @@ -100,7 +98,6 @@ export default class TinyMCE extends React.Component { ) { this.id = nextProps.id; this._init(clone(nextProps.config), nextProps.content); - return; } } @@ -143,7 +140,7 @@ export default class TinyMCE extends React.Component { const setupCallback = config.setup; const hasSetupCallback = typeof setupCallback === 'function'; - config.selector = '#' + this.id; + config.selector = `#${this.id}`; config.setup = editor => { EVENTS.forEach((eventType, index) => { editor.on(eventType, e => { diff --git a/src/modules/shared/tinymce/helpers/uuid.js b/src/modules/shared/tinymce/helpers/uuid.js index b0f8c24f..e641209c 100644 --- a/src/modules/shared/tinymce/helpers/uuid.js +++ b/src/modules/shared/tinymce/helpers/uuid.js @@ -1,4 +1,4 @@ let count = 0; export default function uuid() { - return 'react-tinymce-' + count++; + return `react-tinymce-${count++}`; } diff --git a/src/routes/apps/login.js b/src/routes/apps/login.js index 8745ed6b..8148ae22 100644 --- a/src/routes/apps/login.js +++ b/src/routes/apps/login.js @@ -39,7 +39,7 @@ export default class LoginForm extends React.Component { CezerinClient.authorizeInWebStore( this.state.email, - location.origin + '/admin' + `${location.origin}/admin` ).then(({ status, json }) => { this.setState({ isFetching: false, @@ -82,14 +82,14 @@ export default class LoginForm extends React.Component { onChange={this.handleChange} onKeyPress={this.handleKeyPress} label={messages.email} - fullWidth={true} + fullWidth hintStyle={{ width: '100%' }} hintText={messages.email} /> diff --git a/src/routes/customers/groups/index.js b/src/routes/customers/groups/index.js index a92af517..8e4f2353 100644 --- a/src/routes/customers/groups/index.js +++ b/src/routes/customers/groups/index.js @@ -5,7 +5,7 @@ import Groups from 'modules/customerGroups/list'; export default () => (
- +
diff --git a/src/routes/customers/index.js b/src/routes/customers/index.js index affe7d4d..8b5ffebe 100644 --- a/src/routes/customers/index.js +++ b/src/routes/customers/index.js @@ -5,7 +5,7 @@ import Groups from 'modules/customerGroups/list'; export default () => (
- +
diff --git a/src/routes/login.js b/src/routes/login.js index 71e39eff..7c5e164d 100644 --- a/src/routes/login.js +++ b/src/routes/login.js @@ -54,7 +54,7 @@ export default class LoginForm extends React.Component { isFetching: false, isAuthorized: false, emailIsSent: false, - error: error + error }); }); }; @@ -62,6 +62,7 @@ export default class LoginForm extends React.Component { componentWillMount() { auth.checkTokenFromUrl(); } + componentDidMount() {} render() { @@ -93,14 +94,14 @@ export default class LoginForm extends React.Component { onChange={this.handleChange} onKeyPress={this.handleKeyPress} label={messages.email} - fullWidth={true} + fullWidth hintStyle={{ width: '100%' }} hintText={messages.email} />
diff --git a/src/routes/orders/index.js b/src/routes/orders/index.js index 9974f26c..f88df89f 100644 --- a/src/routes/orders/index.js +++ b/src/routes/orders/index.js @@ -6,7 +6,7 @@ import Statuses from 'modules/orderStatuses/list'; export default () => (
- +
diff --git a/src/routes/orders/statuses/index.js b/src/routes/orders/statuses/index.js index fa167eba..ad12c989 100644 --- a/src/routes/orders/statuses/index.js +++ b/src/routes/orders/statuses/index.js @@ -5,7 +5,7 @@ import List from 'modules/orderStatuses/list'; export default () => (
- +
diff --git a/src/routes/pages/edit.js b/src/routes/pages/edit.js index 110fc1fd..64d5f3df 100644 --- a/src/routes/pages/edit.js +++ b/src/routes/pages/edit.js @@ -1,14 +1,12 @@ import React from 'react'; import PageEdit from 'modules/pages/edit'; -const ProductDetails = props => { - return ( -
-
- -
+const ProductDetails = props => ( +
+
+
- ); -}; +
+); export default ProductDetails; diff --git a/src/routes/products/categories/index.js b/src/routes/products/categories/index.js index 1e2adf78..00518bb7 100644 --- a/src/routes/products/categories/index.js +++ b/src/routes/products/categories/index.js @@ -5,7 +5,7 @@ import Categories from 'modules/productCategories/list'; export default () => (
- +
diff --git a/src/routes/products/edit.js b/src/routes/products/edit.js index 448ee97b..c3277c9c 100644 --- a/src/routes/products/edit.js +++ b/src/routes/products/edit.js @@ -3,18 +3,16 @@ import { Route } from 'react-router-dom'; import ProductEdit from 'modules/products/edit'; import ProductOption from 'modules/products/edit/option'; -const ProductDetails = props => { - return ( -
-
- - -
+const ProductDetails = props => ( +
+
+ +
- ); -}; +
+); export default ProductDetails; diff --git a/src/routes/products/index.js b/src/routes/products/index.js index 38501bcc..3c1bf8c2 100644 --- a/src/routes/products/index.js +++ b/src/routes/products/index.js @@ -6,7 +6,7 @@ import Categories from 'modules/productCategories/list'; export default () => (
- +
diff --git a/src/routes/settings.js b/src/routes/settings.js index c7379bbd..6edbbdc7 100644 --- a/src/routes/settings.js +++ b/src/routes/settings.js @@ -42,7 +42,7 @@ const SettingsMenu = () => ( style={styles.link} activeStyle={styles.linkActive} to="/settings" - exact={true} + exact > ( ); -const Settings = ({ match }) => { - return ( -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
+const Settings = ({ match }) => ( +
+
+
- ); -}; +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+); export default Settings;