diff --git a/Sources/AssemblyVersionAuto.cs b/Sources/AssemblyVersionAuto.cs index 23743d8f..020d349f 100644 --- a/Sources/AssemblyVersionAuto.cs +++ b/Sources/AssemblyVersionAuto.cs @@ -3,6 +3,6 @@ [assembly: AssemblyCopyright("Copyright ? 2020 Episerver")] -[assembly: AssemblyVersion("13.22.0.0")] -[assembly: AssemblyInformationalVersion("13.22.0")] -[assembly: AssemblyFileVersion("13.22.0.4155")] +[assembly: AssemblyVersion("13.26.0.0")] +[assembly: AssemblyInformationalVersion("13.26.0")] +[assembly: AssemblyFileVersion("13.26.0.4223")] diff --git a/Sources/EPiServer.Reference.Commerce.Manager/EPiServer.Reference.Commerce.Manager.csproj b/Sources/EPiServer.Reference.Commerce.Manager/EPiServer.Reference.Commerce.Manager.csproj index 1e30d27b..22bab25f 100644 --- a/Sources/EPiServer.Reference.Commerce.Manager/EPiServer.Reference.Commerce.Manager.csproj +++ b/Sources/EPiServer.Reference.Commerce.Manager/EPiServer.Reference.Commerce.Manager.csproj @@ -407,101 +407,101 @@ - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Business.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Business.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Commerce.Reporting.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Commerce.Reporting.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.BusinessFoundation.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.BusinessFoundation.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.BusinessFoundation.Data.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.BusinessFoundation.Data.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Website.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Website.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Workflow.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Workflow.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.DataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.DataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.FileUploader.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.FileUploader.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.MetaDataPlus.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.MetaDataPlus.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.Extensions.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.Extensions.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.SqlDataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.SqlDataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.WebConsoleLib.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.WebConsoleLib.dll True - ..\..\packages\EPiServer.CommerceManager.13.22.0\lib\net461\Mediachase.ConsoleManager.dll + ..\..\packages\EPiServer.CommerceManager.13.26.0\lib\net461\Mediachase.ConsoleManager.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\AjaxControlToolkit.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\AjaxControlToolkit.dll True - ..\..\packages\EPiServer.CommerceManager.13.22.0\lib\net461\ComponentArt.Web.UI.dll + ..\..\packages\EPiServer.CommerceManager.13.26.0\lib\net461\ComponentArt.Web.UI.dll True - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/Sources/EPiServer.Reference.Commerce.Manager/packages.config b/Sources/EPiServer.Reference.Commerce.Manager/packages.config index 2c90c045..e0fe5286 100644 --- a/Sources/EPiServer.Reference.Commerce.Manager/packages.config +++ b/Sources/EPiServer.Reference.Commerce.Manager/packages.config @@ -45,6 +45,6 @@ - - + + diff --git a/Sources/EPiServer.Reference.Commerce.Manager/web.config b/Sources/EPiServer.Reference.Commerce.Manager/web.config index 6576194f..7b1ccddb 100644 --- a/Sources/EPiServer.Reference.Commerce.Manager/web.config +++ b/Sources/EPiServer.Reference.Commerce.Manager/web.config @@ -580,79 +580,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/Sources/EPiServer.Reference.Commerce.Shared/EPiServer.Reference.Commerce.Shared.csproj b/Sources/EPiServer.Reference.Commerce.Shared/EPiServer.Reference.Commerce.Shared.csproj index 1c93fcda..354daec9 100644 --- a/Sources/EPiServer.Reference.Commerce.Shared/EPiServer.Reference.Commerce.Shared.csproj +++ b/Sources/EPiServer.Reference.Commerce.Shared/EPiServer.Reference.Commerce.Shared.csproj @@ -267,79 +267,79 @@ --> - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Business.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Business.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.BusinessFoundation.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.BusinessFoundation.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.BusinessFoundation.Data.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.BusinessFoundation.Data.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Website.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Website.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Workflow.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Workflow.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.DataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.DataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.FileUploader.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.FileUploader.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.MetaDataPlus.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.MetaDataPlus.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.Extensions.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.Extensions.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.SqlDataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.SqlDataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.WebConsoleLib.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.WebConsoleLib.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\AjaxControlToolkit.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\AjaxControlToolkit.dll True diff --git a/Sources/EPiServer.Reference.Commerce.Shared/packages.config b/Sources/EPiServer.Reference.Commerce.Shared/packages.config index 8bc0aa7c..84e02f32 100644 --- a/Sources/EPiServer.Reference.Commerce.Shared/packages.config +++ b/Sources/EPiServer.Reference.Commerce.Shared/packages.config @@ -39,5 +39,5 @@ - + diff --git a/Sources/EPiServer.Reference.Commerce.Site.Tests/EPiServer.Reference.Commerce.Site.Tests.csproj b/Sources/EPiServer.Reference.Commerce.Site.Tests/EPiServer.Reference.Commerce.Site.Tests.csproj index 3a0d316b..fbef2854 100644 --- a/Sources/EPiServer.Reference.Commerce.Site.Tests/EPiServer.Reference.Commerce.Site.Tests.csproj +++ b/Sources/EPiServer.Reference.Commerce.Site.Tests/EPiServer.Reference.Commerce.Site.Tests.csproj @@ -411,91 +411,91 @@ --> - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Business.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Business.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Commerce.Reporting.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Commerce.Reporting.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.BusinessFoundation.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.BusinessFoundation.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.BusinessFoundation.Data.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.BusinessFoundation.Data.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Website.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Website.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Workflow.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Workflow.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.DataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.DataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.FileUploader.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.FileUploader.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.MetaDataPlus.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.MetaDataPlus.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.Extensions.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.Extensions.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.SqlDataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.SqlDataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.WebConsoleLib.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.WebConsoleLib.dll True - ..\..\packages\EPiServer.Tracking.Commerce.3.2.18\lib\net461\EPiServer.Tracking.Commerce.dll + ..\..\packages\EPiServer.Tracking.Commerce.3.2.23\lib\net461\EPiServer.Tracking.Commerce.dll True - ..\..\packages\EPiServer.Personalization.Commerce.3.2.18\lib\net461\EPiServer.Personalization.Commerce.dll + ..\..\packages\EPiServer.Personalization.Commerce.3.2.23\lib\net461\EPiServer.Personalization.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\AjaxControlToolkit.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\AjaxControlToolkit.dll True diff --git a/Sources/EPiServer.Reference.Commerce.Site.Tests/packages.config b/Sources/EPiServer.Reference.Commerce.Site.Tests/packages.config index 6b6c9a26..4d741a0d 100644 --- a/Sources/EPiServer.Reference.Commerce.Site.Tests/packages.config +++ b/Sources/EPiServer.Reference.Commerce.Site.Tests/packages.config @@ -60,7 +60,7 @@ - - - + + + diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/CSRCustomUI.cs b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/CSRCustomUI.cs new file mode 100644 index 00000000..b4def68b --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/CSRCustomUI.cs @@ -0,0 +1,15 @@ +using EPiServer.Commerce.UI.CustomerService.Extensibility; +using EPiServer.ServiceLocation; + +namespace EPiServer.Reference.Commerce.Site.CSRExtensibility +{ + [ServiceConfiguration(typeof(CSRUIExtensionConfiguration))] + public class CSRCustomUI : CSRUIExtensionConfiguration + { + public CSRCustomUI() + { + // comment out the line below to make the CSR extended components samples visible + //ResourceScripts = new string[] { "/CSRExtensibility/react-app/dist/customized-csr-bundle.min.js" }; + } + } +} \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/Controllers/DemoApiController.cs b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/Controllers/DemoApiController.cs new file mode 100644 index 00000000..3ec1fa62 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/Controllers/DemoApiController.cs @@ -0,0 +1,17 @@ +using EPiServer.Commerce.UI.CustomerService.Extensibility; +using EPiServer.Commerce.UI.CustomerService.Routing; +using System.Web.Http; + +namespace EPiServer.Reference.Commerce.Site.CSRExtensibility.Controllers +{ + [EpiRoutePrefix("csr-demo")] + public class DemoApiController: CSRAPIController + { + [HttpGet] + [EpiRoute("getData")] + public IHttpActionResult Get() + { + return Ok("Sample data"); + } + } +} \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/.env b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/.env new file mode 100644 index 00000000..57727ee9 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/.env @@ -0,0 +1 @@ +PORT=4000 \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/.gitignore b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/.gitignore new file mode 100644 index 00000000..32d6f947 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/.gitignore @@ -0,0 +1,28 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* +internal-npm-packages/csr-app/node_modules + +yarn.lock + +/dist/static \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/README.md b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/README.md new file mode 100644 index 00000000..0013a666 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/README.md @@ -0,0 +1,110 @@ +## Introduction +For the CSR Extensibility feature, we created a sample react project, including: +- @episerver/csr-extension: use this package for declaring extension configuration. +- @episerver/csr-app : use this package for debugging purpose. +- scripts: to build the bundle config file and use it for injecting to CSR + +## Basic setup +Below are the basic steps to add a CSR extension module +- Declare a setting object + - We already defined `demo-setting.tsx` with sample configuration. You can change those configurations. +- Call function `CSRExtension.InitConfiguration` with `setting` object you defined as param. + - This function was defined by CSR itself. When you want to make a change to setting object, call function `CSRExtension.InitConfiguration` again. +- Create a bundle file from `csr-extension.tsx` as entry point by using script `yarn package` + - This script will output bundle file at `dist` folder +- Specify js and css files which will be injected into CSR + - By default, Quicksilver take `customized-csr-bundle.min.js` file and inject into current CSR page. + + You can change the injected js, css file at `CSRExtensibility/CSRCustomUI.cs` + + Sample code + + ```c# + namespace EPiServer.Reference.Commerce.Site.UIComponents + { + [ServiceConfiguration(typeof(CSRUIExtensionConfiguration))] + public class CSRCustomUI : CSRUIExtensionConfiguration + { + public CSRCustomUI() + { + ResourceScripts = new string[] { "/CSRExtensibility/react-app/dist/customized-csr-bundle.min.js" }; + + ResourceStyles = new string[]{}; + } + } + } + ``` + You can add ResourceStyles and ResourceScripts. We will take those files and inject into CSR. + + +## Available Scripts + +### `yarn package` and `yarn package:dev` + +This script will bundle `src/configuration/csr-extension.tsx` file and output result to `dist` folder. +If you want to pack in the development environment, you can use `yarn package:dev`. This will output bundle file without minified, for debugging. + +## Define new API controller +When there is a need to define new API for specific job, you can do by your own or using `HTTPRequest` included in the @episerver/csr-extension package. +HTTPRequest is an axios instance come with the baseURL config. + +- First, create a new Controller where extend CSRAPIController at server side: +```c# +[EpiRoutePrefix("csr-demo")] +public class DemoApiController: CSRAPIController +{ + [HttpGet] + [EpiRoute("getData")] + public IHttpActionResult Get() + { + return Ok("Sample data"); + } +} +``` +- Then make API request at the front-end side: +```javascript +import { HttpRequest } from '@episerver/csr-extension'; + +HTTPRequest.get('csr-demo/getData').then(resp => { + console.log(resp.data); +}); + +``` + +## Development environment +### How to debug the extension bundle in CSR app +We had exported CSRApp component include in internal `@episerver/csr-app` package +Follow these steps to setup debug environment: +- Declare component and passing `setting` object via props +- Setup local environment of the Quicksilver site and config proxy at `setupProxy.js` in the `src` folder + +Here is the sample code to running CSRApp in the development evironment +```javascript +import * as React from 'react'; +import ReactDOM from 'react-dom'; +import { CSRApp } from '@episerver/csr-app'; +import { setting } from './configuration/demo-setting'; + +import '@episerver/csr-app/bundle.css'; + +ReactDOM.render( +
+ +
, + document.getElementById('root') +); +``` + +- run `yarn start` to start debugging + +## Important Notes + +- To use the react hook, please config react as an external library. By default, we already set externals config at `webpack.extension.config.js` file +```javascript +externals: { + react: 'React' +}, +``` +We also injected the react library into CSR as a separate library, so that it guarantees the existing CSR and extension share the same react library. + + diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/env.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/env.js new file mode 100644 index 00000000..09ec03c5 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/env.js @@ -0,0 +1,101 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); + +// Make sure that including paths.js after env.js will read .env variables. +delete require.cache[require.resolve('./paths')]; + +const NODE_ENV = process.env.NODE_ENV; +if (!NODE_ENV) { + throw new Error( + 'The NODE_ENV environment variable is required but was not specified.' + ); +} + +// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use +const dotenvFiles = [ + `${paths.dotenv}.${NODE_ENV}.local`, + `${paths.dotenv}.${NODE_ENV}`, + // Don't include `.env.local` for `test` environment + // since normally you expect tests to produce the same + // results for everyone + NODE_ENV !== 'test' && `${paths.dotenv}.local`, + paths.dotenv, +].filter(Boolean); + +// Load environment variables from .env* files. Suppress warnings using silent +// if this file is missing. dotenv will never modify any environment variables +// that have already been set. Variable expansion is supported in .env files. +// https://github.com/motdotla/dotenv +// https://github.com/motdotla/dotenv-expand +dotenvFiles.forEach(dotenvFile => { + if (fs.existsSync(dotenvFile)) { + require('dotenv-expand')( + require('dotenv').config({ + path: dotenvFile, + }) + ); + } +}); + +// We support resolving modules according to `NODE_PATH`. +// This lets you use absolute paths in imports inside large monorepos: +// https://github.com/facebook/create-react-app/issues/253. +// It works similar to `NODE_PATH` in Node itself: +// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. +// Otherwise, we risk importing Node.js core modules into an app instead of webpack shims. +// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421 +// We also resolve them to make sure all tools using them work consistently. +const appDirectory = fs.realpathSync(process.cwd()); +process.env.NODE_PATH = (process.env.NODE_PATH || '') + .split(path.delimiter) + .filter(folder => folder && !path.isAbsolute(folder)) + .map(folder => path.resolve(appDirectory, folder)) + .join(path.delimiter); + +// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be +// injected into the application via DefinePlugin in webpack configuration. +const REACT_APP = /^REACT_APP_/i; + +function getClientEnvironment(publicUrl) { + const raw = Object.keys(process.env) + .filter(key => REACT_APP.test(key)) + .reduce( + (env, key) => { + env[key] = process.env[key]; + return env; + }, + { + // Useful for determining whether we’re running in production mode. + // Most importantly, it switches React into the correct mode. + NODE_ENV: process.env.NODE_ENV || 'development', + // Useful for resolving the correct path to static assets in `public`. + // For example, . + // This should only be used as an escape hatch. Normally you would put + // images into the `src` and `import` them in code to get their paths. + PUBLIC_URL: publicUrl, + // We support configuring the sockjs pathname during development. + // These settings let a developer run multiple simultaneous projects. + // They are used as the connection `hostname`, `pathname` and `port` + // in webpackHotDevClient. They are used as the `sockHost`, `sockPath` + // and `sockPort` options in webpack-dev-server. + WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST, + WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH, + WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT, + } + ); + // Stringify all values so we can feed into webpack DefinePlugin + const stringified = { + 'process.env': Object.keys(raw).reduce((env, key) => { + env[key] = JSON.stringify(raw[key]); + return env; + }, {}), + }; + + return { raw, stringified }; +} + +module.exports = getClientEnvironment; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/getHttpsConfig.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/getHttpsConfig.js new file mode 100644 index 00000000..013d493c --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/getHttpsConfig.js @@ -0,0 +1,66 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const crypto = require('crypto'); +const chalk = require('react-dev-utils/chalk'); +const paths = require('./paths'); + +// Ensure the certificate and key provided are valid and if not +// throw an easy to debug error +function validateKeyAndCerts({ cert, key, keyFile, crtFile }) { + let encrypted; + try { + // publicEncrypt will throw an error with an invalid cert + encrypted = crypto.publicEncrypt(cert, Buffer.from('test')); + } catch (err) { + throw new Error( + `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}` + ); + } + + try { + // privateDecrypt will throw an error with an invalid key + crypto.privateDecrypt(key, encrypted); + } catch (err) { + throw new Error( + `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${ + err.message + }` + ); + } +} + +// Read file and throw an error if it doesn't exist +function readEnvFile(file, type) { + if (!fs.existsSync(file)) { + throw new Error( + `You specified ${chalk.cyan( + type + )} in your env, but the file "${chalk.yellow(file)}" can't be found.` + ); + } + return fs.readFileSync(file); +} + +// Get the https config +// Return cert files if provided in env, otherwise just true or false +function getHttpsConfig() { + const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env; + const isHttps = HTTPS === 'true'; + + if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) { + const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE); + const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE); + const config = { + cert: readEnvFile(crtFile, 'SSL_CRT_FILE'), + key: readEnvFile(keyFile, 'SSL_KEY_FILE'), + }; + + validateKeyAndCerts({ ...config, keyFile, crtFile }); + return config; + } + return isHttps; +} + +module.exports = getHttpsConfig; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/jest/fileTransform.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/jest/fileTransform.js new file mode 100644 index 00000000..aab67618 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/jest/fileTransform.js @@ -0,0 +1,40 @@ +'use strict'; + +const path = require('path'); +const camelcase = require('camelcase'); + +// This is a custom Jest transformer turning file imports into filenames. +// http://facebook.github.io/jest/docs/en/webpack.html + +module.exports = { + process(src, filename) { + const assetFilename = JSON.stringify(path.basename(filename)); + + if (filename.match(/\.svg$/)) { + // Based on how SVGR generates a component name: + // https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6 + const pascalCaseFilename = camelcase(path.parse(filename).name, { + pascalCase: true, + }); + const componentName = `Svg${pascalCaseFilename}`; + return `const React = require('react'); + module.exports = { + __esModule: true, + default: ${assetFilename}, + ReactComponent: React.forwardRef(function ${componentName}(props, ref) { + return { + $$typeof: Symbol.for('react.element'), + type: 'svg', + ref: ref, + key: null, + props: Object.assign({}, props, { + children: ${assetFilename} + }) + }; + }), + };`; + } + + return `module.exports = ${assetFilename};`; + }, +}; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/modules.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/modules.js new file mode 100644 index 00000000..c8efd0dd --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/modules.js @@ -0,0 +1,141 @@ +'use strict'; + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); +const chalk = require('react-dev-utils/chalk'); +const resolve = require('resolve'); + +/** + * Get additional module paths based on the baseUrl of a compilerOptions object. + * + * @param {Object} options + */ +function getAdditionalModulePaths(options = {}) { + const baseUrl = options.baseUrl; + + // We need to explicitly check for null and undefined (and not a falsy value) because + // TypeScript treats an empty string as `.`. + if (baseUrl == null) { + // If there's no baseUrl set we respect NODE_PATH + // Note that NODE_PATH is deprecated and will be removed + // in the next major release of create-react-app. + + const nodePath = process.env.NODE_PATH || ''; + return nodePath.split(path.delimiter).filter(Boolean); + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + // We don't need to do anything if `baseUrl` is set to `node_modules`. This is + // the default behavior. + if (path.relative(paths.appNodeModules, baseUrlResolved) === '') { + return null; + } + + // Allow the user set the `baseUrl` to `appSrc`. + if (path.relative(paths.appSrc, baseUrlResolved) === '') { + return [paths.appSrc]; + } + + // If the path is equal to the root directory we ignore it here. + // We don't want to allow importing from the root directly as source files are + // not transpiled outside of `src`. We do allow importing them with the + // absolute path (e.g. `src/Components/Button.js`) but we set that up with + // an alias. + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return null; + } + + // Otherwise, throw an error. + throw new Error( + chalk.red.bold( + "Your project's `baseUrl` can only be set to `src` or `node_modules`." + + ' Create React App does not support other values at this time.' + ) + ); +} + +/** + * Get webpack aliases based on the baseUrl of a compilerOptions object. + * + * @param {*} options + */ +function getWebpackAliases(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return {}; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return { + src: paths.appSrc, + }; + } +} + +/** + * Get jest aliases based on the baseUrl of a compilerOptions object. + * + * @param {*} options + */ +function getJestAliases(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return {}; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return { + '^src/(.*)$': '/src/$1', + }; + } +} + +function getModules() { + // Check if TypeScript is setup + const hasTsConfig = fs.existsSync(paths.appTsConfig); + const hasJsConfig = fs.existsSync(paths.appJsConfig); + + if (hasTsConfig && hasJsConfig) { + throw new Error( + 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' + ); + } + + let config; + + // If there's a tsconfig.json we assume it's a + // TypeScript project and set up the config + // based on tsconfig.json + if (hasTsConfig) { + const ts = require(resolve.sync('typescript', { + basedir: paths.appNodeModules, + })); + config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config; + // Otherwise we'll check if there is jsconfig.json + // for non TS projects. + } else if (hasJsConfig) { + config = require(paths.appJsConfig); + } + + config = config || {}; + const options = config.compilerOptions || {}; + + const additionalModulePaths = getAdditionalModulePaths(options); + + return { + additionalModulePaths: additionalModulePaths, + webpackAliases: getWebpackAliases(options), + jestAliases: getJestAliases(options), + hasTsConfig, + }; +} + +module.exports = getModules(); diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/paths.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/paths.js new file mode 100644 index 00000000..78696f36 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/config/paths.js @@ -0,0 +1,72 @@ +'use strict'; + +const path = require('path'); +const fs = require('fs'); +const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath'); + +// Make sure any symlinks in the project folder are resolved: +// https://github.com/facebook/create-react-app/issues/637 +const appDirectory = fs.realpathSync(process.cwd()); +const resolveApp = relativePath => path.resolve(appDirectory, relativePath); + +// We use `PUBLIC_URL` environment variable or "homepage" field to infer +// "public path" at which the app is served. +// webpack needs to know it to put the right \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.css b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.css new file mode 100644 index 00000000..ddde6c76 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.css @@ -0,0 +1,950 @@ +body { + margin: 0; } + +#csr-ui { + font-family: Barlow, sans-serif; } + #csr-ui .textarea-input-control textarea { + height: 72px !important; + overflow: auto; } + #csr-ui .mdc-menu-surface--open { + z-index: 10000; } + #csr-ui .mdc-notched-outline { + overflow: visible; + opacity: 1; } + #csr-ui ::-ms-clear { + display: none; } + +.mdc-data-table__content { + font-family: Roboto, sans-serif; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-size: 0.875rem; + line-height: 1.25rem; + font-weight: 400; + letter-spacing: 0.01786em; + text-decoration: inherit; + text-transform: inherit; } + +.mdc-data-table { + background-color: #fff; + /* @alternate */ + background-color: var(--mdc-theme-surface, #fff); + border-radius: 4px; + border-width: 1px; + border-style: solid; + border-color: rgba(0, 0, 0, 0.12); + -webkit-overflow-scrolling: touch; + display: inline-flex; + flex-direction: column; + box-sizing: border-box; + overflow-x: auto; } + .mdc-data-table__row { + background-color: inherit; } + .mdc-data-table__header-row { + background-color: inherit; } + .mdc-data-table__row--selected { + background-color: rgba(98, 0, 238, 0.04); } + .mdc-data-table__row { + border-top-color: rgba(0, 0, 0, 0.12); } + .mdc-data-table__row { + border-top-width: 1px; + border-top-style: solid; } + .mdc-data-table__row:not(.mdc-data-table__row--selected):hover { + background-color: rgba(0, 0, 0, 0.04); } + .mdc-data-table__header-cell { + color: rgba(0, 0, 0, 0.87); } + .mdc-data-table__cell { + color: rgba(0, 0, 0, 0.87); } + .mdc-data-table__cell { + height: 52px; } + .mdc-data-table__header-cell { + height: 56px; } + .mdc-data-table__cell, + .mdc-data-table__header-cell { + padding-right: 16px; + padding-left: 16px; } + .mdc-data-table__header-cell--checkbox, + .mdc-data-table__cell--checkbox { + /* @noflip */ + padding-left: 16px; + /* @noflip */ + padding-right: 0; } + [dir="rtl"] .mdc-data-table__header-cell--checkbox, .mdc-data-table__header-cell--checkbox[dir="rtl"], [dir="rtl"] + .mdc-data-table__cell--checkbox, + .mdc-data-table__cell--checkbox[dir="rtl"] { + /* @noflip */ + padding-left: 0; + /* @noflip */ + padding-right: 16px; } + +.mdc-data-table__table { + min-width: 100%; + border: 0; + white-space: nowrap; + border-collapse: collapse; + /** + * With table-layout:fixed, table and column widths are defined by the width + * of the first row of cells. Cells in subsequent rows do not affect column + * widths. This results in a predictable table layout and may also speed up + * rendering. + */ + table-layout: fixed; } + +.mdc-data-table__cell { + font-family: Roboto, sans-serif; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-size: 0.875rem; + line-height: 1.25rem; + font-weight: 400; + letter-spacing: 0.01786em; + text-decoration: inherit; + text-transform: inherit; + box-sizing: border-box; + text-overflow: ellipsis; + overflow: hidden; } + +.mdc-data-table__cell--numeric { + text-align: right; } + [dir="rtl"] .mdc-data-table__cell--numeric, .mdc-data-table__cell--numeric[dir="rtl"] { + /* @noflip */ + text-align: left; } + +.mdc-data-table__header-cell { + font-family: Roboto, sans-serif; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-size: 0.875rem; + line-height: 1.375rem; + font-weight: 500; + letter-spacing: 0.00714em; + text-decoration: inherit; + text-transform: inherit; + box-sizing: border-box; + text-align: left; + text-overflow: ellipsis; + overflow: hidden; } + [dir="rtl"] .mdc-data-table__header-cell, .mdc-data-table__header-cell[dir="rtl"] { + /* @noflip */ + text-align: right; } + +.mdc-data-table__header-cell--numeric { + text-align: right; } + [dir="rtl"] .mdc-data-table__header-cell--numeric, .mdc-data-table__header-cell--numeric[dir="rtl"] { + /* @noflip */ + text-align: left; } + +.mdc-data-table__header-row-checkbox .mdc-checkbox__native-control:checked ~ .mdc-checkbox__background::before, +.mdc-data-table__header-row-checkbox .mdc-checkbox__native-control:indeterminate ~ .mdc-checkbox__background::before, +.mdc-data-table__row-checkbox .mdc-checkbox__native-control:checked ~ .mdc-checkbox__background::before, +.mdc-data-table__row-checkbox .mdc-checkbox__native-control:indeterminate ~ .mdc-checkbox__background::before { + background-color: #6200ee; } + @supports not (-ms-ime-align: auto) { + .mdc-data-table__header-row-checkbox .mdc-checkbox__native-control:checked ~ .mdc-checkbox__background::before, + .mdc-data-table__header-row-checkbox .mdc-checkbox__native-control:indeterminate ~ .mdc-checkbox__background::before, + .mdc-data-table__row-checkbox .mdc-checkbox__native-control:checked ~ .mdc-checkbox__background::before, + .mdc-data-table__row-checkbox .mdc-checkbox__native-control:indeterminate ~ .mdc-checkbox__background::before { + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } } + +.mdc-data-table__header-row-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::before, .mdc-data-table__header-row-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::after, +.mdc-data-table__row-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::before, +.mdc-data-table__row-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::after { + background-color: #6200ee; } + @supports not (-ms-ime-align: auto) { + .mdc-data-table__header-row-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::before, .mdc-data-table__header-row-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::after, + .mdc-data-table__row-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::before, + .mdc-data-table__row-checkbox.mdc-checkbox--selected .mdc-checkbox__ripple::after { + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } } + +.mdc-data-table__header-row-checkbox.mdc-checkbox--selected:hover .mdc-checkbox__ripple::before, +.mdc-data-table__row-checkbox.mdc-checkbox--selected:hover .mdc-checkbox__ripple::before { + opacity: 0.04; } + +.mdc-data-table__header-row-checkbox.mdc-checkbox--selected.mdc-ripple-upgraded--background-focused .mdc-checkbox__ripple::before, .mdc-data-table__header-row-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded):focus .mdc-checkbox__ripple::before, +.mdc-data-table__row-checkbox.mdc-checkbox--selected.mdc-ripple-upgraded--background-focused .mdc-checkbox__ripple::before, +.mdc-data-table__row-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded):focus .mdc-checkbox__ripple::before { + transition-duration: 75ms; + opacity: 0.12; } + +.mdc-data-table__header-row-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded) .mdc-checkbox__ripple::after, +.mdc-data-table__row-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded) .mdc-checkbox__ripple::after { + transition: opacity 150ms linear; } + +.mdc-data-table__header-row-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded):active .mdc-checkbox__ripple::after, +.mdc-data-table__row-checkbox.mdc-checkbox--selected:not(.mdc-ripple-upgraded):active .mdc-checkbox__ripple::after { + transition-duration: 75ms; + opacity: 0.12; } + +.mdc-data-table__header-row-checkbox.mdc-checkbox--selected.mdc-ripple-upgraded, +.mdc-data-table__row-checkbox.mdc-checkbox--selected.mdc-ripple-upgraded { + --mdc-ripple-fg-opacity: 0.12; } + +.mdc-data-table__header-row-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::before, +.mdc-data-table__header-row-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::after, +.mdc-data-table__row-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::before, +.mdc-data-table__row-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::after { + background-color: #6200ee; } + @supports not (-ms-ime-align: auto) { + .mdc-data-table__header-row-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::before, + .mdc-data-table__header-row-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::after, + .mdc-data-table__row-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::before, + .mdc-data-table__row-checkbox.mdc-ripple-upgraded--background-focused.mdc-checkbox--selected .mdc-checkbox__ripple::after { + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } } + +.mdc-data-table__header-row-checkbox .mdc-checkbox__native-control:enabled:not(:checked):not(:indeterminate) ~ .mdc-checkbox__background, +.mdc-data-table__row-checkbox .mdc-checkbox__native-control:enabled:not(:checked):not(:indeterminate) ~ .mdc-checkbox__background { + border-color: rgba(0, 0, 0, 0.54); + background-color: transparent; } + +.mdc-data-table__header-row-checkbox .mdc-checkbox__native-control:enabled:checked ~ .mdc-checkbox__background, +.mdc-data-table__header-row-checkbox .mdc-checkbox__native-control:enabled:indeterminate ~ .mdc-checkbox__background, +.mdc-data-table__row-checkbox .mdc-checkbox__native-control:enabled:checked ~ .mdc-checkbox__background, +.mdc-data-table__row-checkbox .mdc-checkbox__native-control:enabled:indeterminate ~ .mdc-checkbox__background { + border-color: #6200ee; + /* @alternate */ + border-color: var(--mdc-theme-primary, #6200ee); + background-color: #6200ee; + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } + +@keyframes mdc-checkbox-fade-in-background-u1700ed9b { + 0% { + border-color: rgba(0, 0, 0, 0.54); + background-color: transparent; } + 50% { + border-color: #6200ee; + /* @alternate */ + border-color: var(--mdc-theme-primary, #6200ee); + background-color: #6200ee; + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } } + +@keyframes mdc-checkbox-fade-out-background-u1700ed9b { + 0%, + 80% { + border-color: #6200ee; + /* @alternate */ + border-color: var(--mdc-theme-primary, #6200ee); + background-color: #6200ee; + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } + 100% { + border-color: rgba(0, 0, 0, 0.54); + background-color: transparent; } } + +.mdc-data-table__header-row-checkbox.mdc-checkbox--anim-unchecked-checked .mdc-checkbox__native-control:enabled ~ .mdc-checkbox__background, .mdc-data-table__header-row-checkbox.mdc-checkbox--anim-unchecked-indeterminate .mdc-checkbox__native-control:enabled ~ .mdc-checkbox__background, +.mdc-data-table__row-checkbox.mdc-checkbox--anim-unchecked-checked .mdc-checkbox__native-control:enabled ~ .mdc-checkbox__background, +.mdc-data-table__row-checkbox.mdc-checkbox--anim-unchecked-indeterminate .mdc-checkbox__native-control:enabled ~ .mdc-checkbox__background { + animation-name: mdc-checkbox-fade-in-background-u1700ed9b; } + +.mdc-data-table__header-row-checkbox.mdc-checkbox--anim-checked-unchecked .mdc-checkbox__native-control:enabled ~ .mdc-checkbox__background, .mdc-data-table__header-row-checkbox.mdc-checkbox--anim-indeterminate-unchecked .mdc-checkbox__native-control:enabled ~ .mdc-checkbox__background, +.mdc-data-table__row-checkbox.mdc-checkbox--anim-checked-unchecked .mdc-checkbox__native-control:enabled ~ .mdc-checkbox__background, +.mdc-data-table__row-checkbox.mdc-checkbox--anim-indeterminate-unchecked .mdc-checkbox__native-control:enabled ~ .mdc-checkbox__background { + animation-name: mdc-checkbox-fade-out-background-u1700ed9b; } + +@keyframes mdc-ripple-fg-radius-in { + from { + animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); + transform: translate(var(--mdc-ripple-fg-translate-start, 0)) scale(1); } + to { + transform: translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1)); } } + +@keyframes mdc-ripple-fg-opacity-in { + from { + animation-timing-function: linear; + opacity: 0; } + to { + opacity: var(--mdc-ripple-fg-opacity, 0); } } + +@keyframes mdc-ripple-fg-opacity-out { + from { + animation-timing-function: linear; + opacity: var(--mdc-ripple-fg-opacity, 0); } + to { + opacity: 0; } } + +.mdc-ripple-surface--test-edge-var-bug { + --mdc-ripple-surface-test-edge-var: 1px solid #000; + visibility: hidden; } + .mdc-ripple-surface--test-edge-var-bug::before { + border: var(--mdc-ripple-surface-test-edge-var); } + +.mdc-ripple-surface { + --mdc-ripple-fg-size: 0; + --mdc-ripple-left: 0; + --mdc-ripple-top: 0; + --mdc-ripple-fg-scale: 1; + --mdc-ripple-fg-translate-end: 0; + --mdc-ripple-fg-translate-start: 0; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); + position: relative; + outline: none; + overflow: hidden; } + .mdc-ripple-surface::before, .mdc-ripple-surface::after { + position: absolute; + border-radius: 50%; + opacity: 0; + pointer-events: none; + content: ""; } + .mdc-ripple-surface::before { + transition: opacity 15ms linear, background-color 15ms linear; + z-index: 1; } + .mdc-ripple-surface.mdc-ripple-upgraded::before { + transform: scale(var(--mdc-ripple-fg-scale, 1)); } + .mdc-ripple-surface.mdc-ripple-upgraded::after { + top: 0; + /* @noflip */ + left: 0; + transform: scale(0); + transform-origin: center center; } + .mdc-ripple-surface.mdc-ripple-upgraded--unbounded::after { + top: var(--mdc-ripple-top, 0); + /* @noflip */ + left: var(--mdc-ripple-left, 0); } + .mdc-ripple-surface.mdc-ripple-upgraded--foreground-activation::after { + animation: mdc-ripple-fg-radius-in 225ms forwards, mdc-ripple-fg-opacity-in 75ms forwards; } + .mdc-ripple-surface.mdc-ripple-upgraded--foreground-deactivation::after { + animation: mdc-ripple-fg-opacity-out 150ms; + transform: translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1)); } + .mdc-ripple-surface::before, .mdc-ripple-surface::after { + background-color: #000; } + .mdc-ripple-surface:hover::before { + opacity: 0.04; } + .mdc-ripple-surface.mdc-ripple-upgraded--background-focused::before, .mdc-ripple-surface:not(.mdc-ripple-upgraded):focus::before { + transition-duration: 75ms; + opacity: 0.12; } + .mdc-ripple-surface:not(.mdc-ripple-upgraded)::after { + transition: opacity 150ms linear; } + .mdc-ripple-surface:not(.mdc-ripple-upgraded):active::after { + transition-duration: 75ms; + opacity: 0.12; } + .mdc-ripple-surface.mdc-ripple-upgraded { + --mdc-ripple-fg-opacity: 0.12; } + .mdc-ripple-surface::before, .mdc-ripple-surface::after { + top: calc(50% - 100%); + /* @noflip */ + left: calc(50% - 100%); + width: 200%; + height: 200%; } + .mdc-ripple-surface.mdc-ripple-upgraded::after { + width: var(--mdc-ripple-fg-size, 100%); + height: var(--mdc-ripple-fg-size, 100%); } + .mdc-ripple-surface[data-mdc-ripple-is-unbounded] { + overflow: visible; } + .mdc-ripple-surface[data-mdc-ripple-is-unbounded]::before, .mdc-ripple-surface[data-mdc-ripple-is-unbounded]::after { + top: calc(50% - 50%); + /* @noflip */ + left: calc(50% - 50%); + width: 100%; + height: 100%; } + .mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::before, .mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::after { + top: var(--mdc-ripple-top, calc(50% - 50%)); + /* @noflip */ + left: var(--mdc-ripple-left, calc(50% - 50%)); + width: var(--mdc-ripple-fg-size, 100%); + height: var(--mdc-ripple-fg-size, 100%); } + .mdc-ripple-surface[data-mdc-ripple-is-unbounded].mdc-ripple-upgraded::after { + width: var(--mdc-ripple-fg-size, 100%); + height: var(--mdc-ripple-fg-size, 100%); } + .mdc-ripple-surface--primary::before, .mdc-ripple-surface--primary::after { + background-color: #6200ee; } + @supports not (-ms-ime-align: auto) { + .mdc-ripple-surface--primary::before, .mdc-ripple-surface--primary::after { + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } } + .mdc-ripple-surface--primary:hover::before { + opacity: 0.04; } + .mdc-ripple-surface--primary.mdc-ripple-upgraded--background-focused::before, .mdc-ripple-surface--primary:not(.mdc-ripple-upgraded):focus::before { + transition-duration: 75ms; + opacity: 0.12; } + .mdc-ripple-surface--primary:not(.mdc-ripple-upgraded)::after { + transition: opacity 150ms linear; } + .mdc-ripple-surface--primary:not(.mdc-ripple-upgraded):active::after { + transition-duration: 75ms; + opacity: 0.12; } + .mdc-ripple-surface--primary.mdc-ripple-upgraded { + --mdc-ripple-fg-opacity: 0.12; } + .mdc-ripple-surface--accent::before, .mdc-ripple-surface--accent::after { + background-color: #018786; } + @supports not (-ms-ime-align: auto) { + .mdc-ripple-surface--accent::before, .mdc-ripple-surface--accent::after { + /* @alternate */ + background-color: var(--mdc-theme-secondary, #018786); } } + .mdc-ripple-surface--accent:hover::before { + opacity: 0.04; } + .mdc-ripple-surface--accent.mdc-ripple-upgraded--background-focused::before, .mdc-ripple-surface--accent:not(.mdc-ripple-upgraded):focus::before { + transition-duration: 75ms; + opacity: 0.12; } + .mdc-ripple-surface--accent:not(.mdc-ripple-upgraded)::after { + transition: opacity 150ms linear; } + .mdc-ripple-surface--accent:not(.mdc-ripple-upgraded):active::after { + transition-duration: 75ms; + opacity: 0.12; } + .mdc-ripple-surface--accent.mdc-ripple-upgraded { + --mdc-ripple-fg-opacity: 0.12; } + +@media (max-width: 599px) { + .epi-table__header-cell.hide-sm { + display: none; } } + +.epi-table__header-cell.align-right .epi-table__header-title { + justify-content: flex-end; } + +.epi-table__header-cell:last-of-type { + padding-right: 30px !important; } + +.epi-table__header-title { + display: flex; + align-items: center; + justify-content: flex-start; + font-family: "Barlow", sans-serif; + text-transform: uppercase; } + +@media (max-width: 599px) { + .mdc-data-table__cell.hide-sm { + display: none; } } + +.mdc-data-table__cell.align-right { + text-align: right; } + +.epi-table__toolbar { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; } + .epi-table__toolbar .search-input { + display: flex; + align-items: center; + box-shadow: none; + border: 1px solid lightgrey; + border-radius: 5px; } + .epi-table__toolbar .search-input .search-icon { + padding: 5px 10px 2px; + fill: lightgrey; } + .epi-table__toolbar .action-buttons { + display: flex; } + .epi-table__toolbar .action-buttons > button { + margin-right: 10px; } + +.epi-table { + font-family: "Barlow", sans-serif; + overflow: unset; + min-width: 100%; + border: none; } + .epi-table .mdc-data-table__cell { + font-family: "Barlow", sans-serif; } + .epi-table table { + border: 1px solid rgba(0, 0, 0, 0.12); + position: relative; } + +.mdc-dialog .mdc-dialog__surface { + max-width: calc(100vw - 32px); } + +.epi-exposed-dropdown { + display: inline-flex; + align-items: center; } + .epi-exposed-dropdown.fullwidth { + width: 100%; } + .epi-exposed-dropdown .mdc-select__selected-text { + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + padding-right: 24px; } + .epi-exposed-dropdown .mdc-select__dropdown-icon { + height: 100%; + bottom: 0px; } + .epi-exposed-dropdown.mdc-select--focused .mdc-select__dropdown-icon { + bottom: 5px; } + .epi-exposed-dropdown:not(.mdc-select--disabled).mdc-select--focused .mdc-notched-outline .mdc-notched-outline__leading, + .epi-exposed-dropdown:not(.mdc-select--disabled).mdc-select--focused .mdc-notched-outline .mdc-notched-outline__trailing, + .epi-exposed-dropdown:not(.mdc-select--disabled).mdc-select--focused .mdc-notched-outline .mdc-notched-outline__notch { + border-color: #1456f1; } + .epi-exposed-dropdown:not(.mdc-select--disabled).mdc-select--focused .mdc-notched-outline .mdc-floating-label { + color: #1456f1; } + .epi-exposed-dropdown.dense { + height: 36px; } + .epi-exposed-dropdown.dense .mdc-select__selected-text { + font-size: 14px; + padding-left: 14px; + height: 36px; + line-height: 36px; + padding-top: 0; + padding-bottom: 0; } + .epi-exposed-dropdown.dense .mdc-notched-outline .mdc-floating-label { + line-height: 36px; + top: 0; } + .epi-exposed-dropdown.dense .mdc-notched-outline .mdc-floating-label--float-above { + line-height: inherit; + top: 17px; } + .epi-exposed-dropdown .mdc-notched-outline { + top: 0; } + +.action-dropdown__anchor-icon { + display: flex; + align-items: center; + justify-content: center; + width: 40px; + height: 40px; + cursor: pointer; } + +.epi-table-action-dropdown.mdc-menu-surface--open { + z-index: 100000; + min-width: 150px; } + +.mdc-list { + font-family: Roboto, sans-serif; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-size: 1rem; + line-height: 1.75rem; + font-weight: 400; + letter-spacing: 0.00937em; + text-decoration: inherit; + text-transform: inherit; + /* @alternate */ + line-height: 1.5rem; + margin: 0; + padding: 8px 0; + list-style-type: none; + color: rgba(0, 0, 0, 0.87); + /* @alternate */ + color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87)); } + +.mdc-list-item__secondary-text { + color: rgba(0, 0, 0, 0.54); + /* @alternate */ + color: var(--mdc-theme-text-secondary-on-background, rgba(0, 0, 0, 0.54)); } + +.mdc-list-item__graphic { + background-color: transparent; } + +.mdc-list-item__graphic { + color: rgba(0, 0, 0, 0.38); + /* @alternate */ + color: var(--mdc-theme-text-icon-on-background, rgba(0, 0, 0, 0.38)); } + +.mdc-list-item__meta { + color: rgba(0, 0, 0, 0.38); + /* @alternate */ + color: var(--mdc-theme-text-hint-on-background, rgba(0, 0, 0, 0.38)); } + +.mdc-list-group__subheader { + color: rgba(0, 0, 0, 0.87); + /* @alternate */ + color: var(--mdc-theme-text-primary-on-background, rgba(0, 0, 0, 0.87)); } + +.mdc-list--dense { + padding-top: 4px; + padding-bottom: 4px; + font-size: .812rem; } + +.mdc-list-item { + display: flex; + position: relative; + align-items: center; + justify-content: flex-start; + height: 48px; + padding: 0 16px; + overflow: hidden; } + .mdc-list-item:focus { + outline: none; } + +.mdc-list-item--selected, +.mdc-list-item--activated { + color: #6200ee; + /* @alternate */ + color: var(--mdc-theme-primary, #6200ee); } + .mdc-list-item--selected .mdc-list-item__graphic, + .mdc-list-item--activated .mdc-list-item__graphic { + color: #6200ee; + /* @alternate */ + color: var(--mdc-theme-primary, #6200ee); } + +.mdc-list-item--disabled { + color: rgba(0, 0, 0, 0.38); + /* @alternate */ + color: var(--mdc-theme-text-disabled-on-background, rgba(0, 0, 0, 0.38)); } + +.mdc-list-item__graphic { + /* @noflip */ + margin-left: 0; + /* @noflip */ + margin-right: 32px; + width: 24px; + height: 24px; + flex-shrink: 0; + align-items: center; + justify-content: center; + fill: currentColor; } + .mdc-list-item[dir="rtl"] .mdc-list-item__graphic, + [dir="rtl"] .mdc-list-item .mdc-list-item__graphic { + /* @noflip */ + margin-left: 32px; + /* @noflip */ + margin-right: 0; } + +.mdc-list .mdc-list-item__graphic { + display: inline-flex; } + +.mdc-list-item__meta { + /* @noflip */ + margin-left: auto; + /* @noflip */ + margin-right: 0; } + .mdc-list-item[dir="rtl"] .mdc-list-item__meta, + [dir="rtl"] .mdc-list-item .mdc-list-item__meta { + /* @noflip */ + margin-left: 0; + /* @noflip */ + margin-right: auto; } + +.mdc-list-item__text { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; } + +.mdc-list-item__text[for] { + pointer-events: none; } + +.mdc-list-item__primary-text { + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + display: block; + margin-top: 0; + /* @alternate */ + line-height: normal; + margin-bottom: -20px; + display: block; } + .mdc-list-item__primary-text::before { + display: inline-block; + width: 0; + height: 32px; + content: ""; + vertical-align: 0; } + .mdc-list-item__primary-text::after { + display: inline-block; + width: 0; + height: 20px; + content: ""; + vertical-align: -20px; } + .mdc-list--dense .mdc-list-item__primary-text { + display: block; + margin-top: 0; + /* @alternate */ + line-height: normal; + margin-bottom: -20px; } + .mdc-list--dense .mdc-list-item__primary-text::before { + display: inline-block; + width: 0; + height: 24px; + content: ""; + vertical-align: 0; } + .mdc-list--dense .mdc-list-item__primary-text::after { + display: inline-block; + width: 0; + height: 20px; + content: ""; + vertical-align: -20px; } + +.mdc-list-item__secondary-text { + font-family: Roboto, sans-serif; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-size: 0.875rem; + line-height: 1.25rem; + font-weight: 400; + letter-spacing: 0.01786em; + text-decoration: inherit; + text-transform: inherit; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + display: block; + margin-top: 0; + /* @alternate */ + line-height: normal; + display: block; } + .mdc-list-item__secondary-text::before { + display: inline-block; + width: 0; + height: 20px; + content: ""; + vertical-align: 0; } + .mdc-list--dense .mdc-list-item__secondary-text { + display: block; + margin-top: 0; + /* @alternate */ + line-height: normal; + font-size: inherit; } + .mdc-list--dense .mdc-list-item__secondary-text::before { + display: inline-block; + width: 0; + height: 20px; + content: ""; + vertical-align: 0; } + +.mdc-list--dense .mdc-list-item { + height: 40px; } + +.mdc-list--dense .mdc-list-item__graphic { + /* @noflip */ + margin-left: 0; + /* @noflip */ + margin-right: 36px; + width: 20px; + height: 20px; } + .mdc-list-item[dir="rtl"] .mdc-list--dense .mdc-list-item__graphic, + [dir="rtl"] .mdc-list-item .mdc-list--dense .mdc-list-item__graphic { + /* @noflip */ + margin-left: 36px; + /* @noflip */ + margin-right: 0; } + +.mdc-list--avatar-list .mdc-list-item { + height: 56px; } + +.mdc-list--avatar-list .mdc-list-item__graphic { + /* @noflip */ + margin-left: 0; + /* @noflip */ + margin-right: 16px; + width: 40px; + height: 40px; + border-radius: 50%; } + .mdc-list-item[dir="rtl"] .mdc-list--avatar-list .mdc-list-item__graphic, + [dir="rtl"] .mdc-list-item .mdc-list--avatar-list .mdc-list-item__graphic { + /* @noflip */ + margin-left: 16px; + /* @noflip */ + margin-right: 0; } + +.mdc-list--two-line .mdc-list-item__text { + align-self: flex-start; } + +.mdc-list--two-line .mdc-list-item { + height: 72px; } + +.mdc-list--two-line.mdc-list--dense .mdc-list-item, +.mdc-list--avatar-list.mdc-list--dense .mdc-list-item { + height: 60px; } + +.mdc-list--avatar-list.mdc-list--dense .mdc-list-item__graphic { + /* @noflip */ + margin-left: 0; + /* @noflip */ + margin-right: 20px; + width: 36px; + height: 36px; } + .mdc-list-item[dir="rtl"] .mdc-list--avatar-list.mdc-list--dense .mdc-list-item__graphic, + [dir="rtl"] .mdc-list-item .mdc-list--avatar-list.mdc-list--dense .mdc-list-item__graphic { + /* @noflip */ + margin-left: 20px; + /* @noflip */ + margin-right: 0; } + +:not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item { + cursor: pointer; } + +a.mdc-list-item { + color: inherit; + text-decoration: none; } + +.mdc-list-divider { + height: 0; + margin: 0; + border: none; + border-bottom-width: 1px; + border-bottom-style: solid; } + +.mdc-list-divider { + border-bottom-color: rgba(0, 0, 0, 0.12); } + +.mdc-list-divider--padded { + margin: 0 16px; } + +.mdc-list-divider--inset { + /* @noflip */ + margin-left: 72px; + /* @noflip */ + margin-right: 0; + width: calc(100% - 72px); } + .mdc-list-group[dir="rtl"] .mdc-list-divider--inset, + [dir="rtl"] .mdc-list-group .mdc-list-divider--inset { + /* @noflip */ + margin-left: 0; + /* @noflip */ + margin-right: 72px; } + +.mdc-list-divider--inset.mdc-list-divider--padded { + width: calc(100% - 72px - 16px); } + +.mdc-list-group .mdc-list { + padding: 0; } + +.mdc-list-group__subheader { + font-family: Roboto, sans-serif; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-size: 1rem; + line-height: 1.75rem; + font-weight: 400; + letter-spacing: 0.00937em; + text-decoration: inherit; + text-transform: inherit; + margin: 0.75rem 16px; } + +:not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item { + --mdc-ripple-fg-size: 0; + --mdc-ripple-left: 0; + --mdc-ripple-top: 0; + --mdc-ripple-fg-scale: 1; + --mdc-ripple-fg-translate-end: 0; + --mdc-ripple-fg-translate-start: 0; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item::after { + position: absolute; + border-radius: 50%; + opacity: 0; + pointer-events: none; + content: ""; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item::before { + transition: opacity 15ms linear, background-color 15ms linear; + z-index: 1; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item.mdc-ripple-upgraded::before { + transform: scale(var(--mdc-ripple-fg-scale, 1)); } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item.mdc-ripple-upgraded::after { + top: 0; + /* @noflip */ + left: 0; + transform: scale(0); + transform-origin: center center; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item.mdc-ripple-upgraded--unbounded::after { + top: var(--mdc-ripple-top, 0); + /* @noflip */ + left: var(--mdc-ripple-left, 0); } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item.mdc-ripple-upgraded--foreground-activation::after { + animation: mdc-ripple-fg-radius-in 225ms forwards, mdc-ripple-fg-opacity-in 75ms forwards; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item.mdc-ripple-upgraded--foreground-deactivation::after { + animation: mdc-ripple-fg-opacity-out 150ms; + transform: translate(var(--mdc-ripple-fg-translate-end, 0)) scale(var(--mdc-ripple-fg-scale, 1)); } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item::after { + top: calc(50% - 100%); + /* @noflip */ + left: calc(50% - 100%); + width: 200%; + height: 200%; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item.mdc-ripple-upgraded::after { + width: var(--mdc-ripple-fg-size, 100%); + height: var(--mdc-ripple-fg-size, 100%); } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item::after { + background-color: #000; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item:hover::before { + opacity: 0.04; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item.mdc-ripple-upgraded--background-focused::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item:not(.mdc-ripple-upgraded):focus::before { + transition-duration: 75ms; + opacity: 0.12; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item:not(.mdc-ripple-upgraded)::after { + transition: opacity 150ms linear; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item:not(.mdc-ripple-upgraded):active::after { + transition-duration: 75ms; + opacity: 0.12; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item.mdc-ripple-upgraded { + --mdc-ripple-fg-opacity: 0.12; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated::before { + opacity: 0.12; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated::after { + background-color: #6200ee; } + @supports not (-ms-ime-align: auto) { + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated::after { + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated:hover::before { + opacity: 0.16; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated.mdc-ripple-upgraded--background-focused::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated:not(.mdc-ripple-upgraded):focus::before { + transition-duration: 75ms; + opacity: 0.24; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated:not(.mdc-ripple-upgraded)::after { + transition: opacity 150ms linear; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated:not(.mdc-ripple-upgraded):active::after { + transition-duration: 75ms; + opacity: 0.24; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--activated.mdc-ripple-upgraded { + --mdc-ripple-fg-opacity: 0.24; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected::before { + opacity: 0.08; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected::after { + background-color: #6200ee; } + @supports not (-ms-ime-align: auto) { + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected::after { + /* @alternate */ + background-color: var(--mdc-theme-primary, #6200ee); } } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected:hover::before { + opacity: 0.12; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected.mdc-ripple-upgraded--background-focused::before, :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected:not(.mdc-ripple-upgraded):focus::before { + transition-duration: 75ms; + opacity: 0.2; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected:not(.mdc-ripple-upgraded)::after { + transition: opacity 150ms linear; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected:not(.mdc-ripple-upgraded):active::after { + transition-duration: 75ms; + opacity: 0.2; } + :not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item--selected.mdc-ripple-upgraded { + --mdc-ripple-fg-opacity: 0.2; } + +.mdc-menu-surface { + display: none; + position: absolute; + box-sizing: border-box; + max-width: calc(100vw - 32px); + max-height: calc(100vh - 32px); + margin: 0; + padding: 0; + transform: scale(1); + transform-origin: top left; + opacity: 0; + overflow: auto; + will-change: transform, opacity; + z-index: 8; + transition: opacity 0.03s linear, transform 0.12s cubic-bezier(0, 0, 0.2, 1); + box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12); + background-color: #fff; + /* @alternate */ + background-color: var(--mdc-theme-surface, #fff); + color: #000; + /* @alternate */ + color: var(--mdc-theme-on-surface, #000); + border-radius: 4px; + /* @noflip */ + transform-origin-left: top left; + /* @noflip */ + transform-origin-right: top right; } + .mdc-menu-surface:focus { + outline: none; } + .mdc-menu-surface--open { + display: inline-block; + transform: scale(1); + opacity: 1; } + .mdc-menu-surface--animating-open { + display: inline-block; + transform: scale(0.8); + opacity: 0; } + .mdc-menu-surface--animating-closed { + display: inline-block; + opacity: 0; + transition: opacity 0.075s linear; } + [dir="rtl"] .mdc-menu-surface, .mdc-menu-surface[dir="rtl"] { + /* @noflip */ + transform-origin-left: top right; + /* @noflip */ + transform-origin-right: top left; } + +.mdc-menu-surface--anchor { + position: relative; + overflow: visible; } + +.mdc-menu-surface--fixed { + position: fixed; } diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.esm.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.esm.js new file mode 100644 index 00000000..77d2f9be --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.esm.js @@ -0,0 +1,15 @@ +import e,{createElement as t,Fragment as r,Component as n,createRef as s,useState as i,useEffect as o,useCallback as a}from"react";import"@episerver/ui-framework/dist/main.css";import{connect as u,Provider as d}from"react-redux";import{createStyles as c,withStyles as p,Grid as l,TextField as h,Typography as m,Dialog as f,DialogTitle as g,DialogContent as y,DialogActions as v,FormControlLabel as C,Select as S,MenuItem as I,Card as b,CardHeader as A,CardContent as O,MenuList as w,ListItemText as T,Drawer as D,InputBase as P,FormControl as G,InputLabel as N,OutlinedInput as R,Collapse as E,CardActions as x,Divider as L,Paper as M,CircularProgress as F,Avatar as k,Radio as _,AppBar as V,InputAdornment as U,MuiThemeProvider as B}from"@material-ui/core";import{DatePicker as H,DateTimePicker as W,MuiPickersUtilsProvider as q}from"material-ui-pickers";import{combineReducers as j,createStore as Y}from"redux";import{withStyles as z,createStyles as Q,createMuiTheme as K}from"@material-ui/core/styles";import X from"@date-io/moment";import J from"@material-ui/core/Fab";import Z from"@material-ui/icons/FeedbackOutlined";import $ from"@material-ui/core/Grid";import ee from"@material-ui/icons/Warning";import te from"@material-ui/core/Dialog";import re from"@material-ui/core/DialogActions";import ne from"@material-ui/core/DialogContent";import{TextButton as se,IconButton as ie,EditIcon as oe,DeleteIcon as ae,Checkbox as ue,CloseIcon as de,MenuSurface as ce,List as pe,ListItem as le,ListItemText as he,ListDivider as me,TabBar as fe,Tab as ge}from"@episerver/ui-framework";import ye from"@material-ui/core/Typography/Typography";import ve from"@material-ui/core/Snackbar";import Ce from"@material-ui/core/CircularProgress";import Se from"axios";import{getStateNameByStateCode as Ie}from"us-state-codes";import{lookup as be}from"zipcodes";import{object as Ae,string as Oe,number as we,date as Te,boolean as De,bool as Pe,ref as Ge}from"yup";import Ne,{Option as Re}from"@material/react-select";import"@material/react-menu/index.scss";import"@material/react-select/index.scss";import{ValidatorForm as Ee,TextValidator as xe}from"react-material-ui-form-validator";import{BigNumber as Le}from"bignumber.js";import{countries as Me}from"countries-list";import{Link as Fe,Switch as ke,Route as _e,HashRouter as Ve}from"react-router-dom";import Ue from"@material-ui/core/Card";import Be from"@material-ui/core/CardHeader";import He from"@material-ui/core/CardContent";import We from"@material-ui/core/Typography";import qe from"@material-ui/icons/Mail";import je from"@material-ui/icons/Phone";import Ye from"@material-ui/icons/AddCircle";import ze from"@material-ui/core/CardActionArea";import Qe from"@material-ui/core/Slide";import Ke from"@material-ui/core/Hidden";import Xe from"@material-ui/core/AppBar";import Je from"@material-ui/core/Toolbar";import Ze from"@material-ui/icons/Menu";import $e from"@material-ui/core/Table";import et from"@material-ui/core/TableBody";import tt from"@material-ui/core/TableCell";import rt from"@material-ui/core/TableHead";import nt from"@material-ui/core/TablePagination";import st from"@material-ui/core/TableRow";import it from"@material-ui/core/Paper";import ot from"moment";import at from"@material-ui/core/Tooltip";import ut from"@material-ui/core/IconButton";import dt from"@material-ui/icons/Edit";import ct from"@material-ui/icons/Delete";import pt from"@material-ui/icons/Save";import lt from"@material-ui/icons/Close";import{MDCDataTable as ht,MDCDataTableFoundation as mt}from"@material/data-table";import ft from"@material-ui/core/RadioGroup";import gt from"@material-ui/core/FormControlLabel";import yt from"@material-ui/core/FormLabel";import vt from"@material-ui/core/Radio";import Ct from"@material-ui/core/DialogTitle";import St from"@material-ui/core/DialogContentText";import It from"@material-ui/core/Divider";import bt from"@material-ui/core/Chip";import At from"@material-ui/core/TextField";import Ot from"@material-ui/core/InputAdornment";import wt from"@material-ui/core/Avatar";import Tt from"@material-ui/icons/Done";import Dt from"@material-ui/icons/LocalOffer";import Pt from"@material-ui/icons/CardGiftcard";import Gt from"@material-ui/core/Badge";import{debounce as Nt,throttle as Rt}from"lodash-es";import Et from"react-autosuggest";import xt from"@material-ui/icons/ShoppingCart";import Lt,{Input as Mt}from"@material/react-text-field";import{Search as Ft,Clear as kt}from"@material-ui/icons"; +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */var _t=function(e,t){return(_t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function Vt(e,t){function r(){this.constructor=e}_t(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var Ut,Bt=function(){return(Bt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&s[s.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]0&&(r.searchValue=encodeURIComponent(e.searchText),r.searchField=e.searchType),[4,Se.get(t,{params:r})];case 1:return[2,{TotalOrderGroups:(n=s.sent()).data.TotalOrderGroups,Results:n.data.Results.map((function(e,t){return Wr(e)}))}]}}))}))},t.getReturns=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns",[4,Se.get(t)];case 1:return[2,{Totals:(r=n.sent()).data.Totals,Results:r.data.Results.map((function(e,t){return Wr(e)}))}]}}))}))},t.getReturn=function(e,r){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns/"+r,[4,Se.get(t)];case 1:return[2,n.sent().data]}}))}))},t.initPurchaseOrder=function(e,r){return Wt(t,void 0,void 0,(function(){var t,n,s;return qt(this,(function(i){switch(i.label){case 0:return t=""+this.baseApiUrl+Er+"/initorder/"+e+"/"+r,[4,Se.post(t)];case 1:return n=i.sent(),(s=Wr(n.data)).IsDraft=!0,[2,s]}}))}))},t.initExchangeOrder=function(e){return Wt(t,void 0,void 0,(function(){var t,r,n;return qt(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+Er+"/initexchange/"+e,[4,Se.post(t)];case 1:return r=s.sent(),(n=Wr(r.data)).IsDraft=!0,[2,n]}}))}))},t.createPurchaseOrder=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Er,[4,Se.post(t,e)];case 1:return r=n.sent(),[2,Wr(r.data)]}}))}))},t.calculateOrder=function(e){return Wt(t,void 0,void 0,(function(){var t,r,n;return qt(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+Er+"/calculate",[4,Se.post(t,e)];case 1:return r=s.sent(),(n=Wr(r.data)).IsDraft=!0,[2,n]}}))}))},t.createReturn=function(e,r){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns",[4,Se.post(t,r)];case 1:return[2,n.sent().data]}}))}))},t.cancelReturn=function(e,r){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns/"+r+"/cancel",[4,Se.post(t)];case 1:return[2,n.sent().data]}}))}))},t.acknowledgeReceiptItems=function(e,r){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns/"+r+"/acknowledgeReceiptItems",[4,Se.post(t)];case 1:return[2,n.sent()]}}))}))},t.getSingleOrderGroup=function(e,r){return Wt(t,void 0,void 0,(function(){var t,n;return qt(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r,[4,Se.get(t)];case 1:return n=s.sent(),[2,Wr(n.data)]}}))}))},t.addCoupon=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/coupons",[4,Se.post(t,s)];case 1:return[2,i.sent()]}}))}))},t.removeCoupon=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/coupons",[4,Se.delete(t,{params:{couponCode:s.Code}})];case 1:return[2,i.sent()]}}))}))},t.deleteLineItem=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+this.getOrderGroupRouting(e)+"/"+r+"/lineitems/"+n,[4,Se.delete(t)];case 1:return[2,s.sent()]}}))}))},t.deleteReturnLineItem=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns/"+r+"/lineitems/"+n,[4,Se.delete(t)];case 1:return[2,s.sent()]}}))}))},t.updateLineItem=function(e){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e.OrderGroupType)+"/"+e.OrderGroupId+"/lineitems/"+e.LineItemId,[4,Se.patch(t,e)];case 1:return[2,r.sent()]}}))}))},t.updateReturnLineItem=function(e,r,n,s,i){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(o){switch(o.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns/"+r+"/lineitems/"+n,[4,Se.patch(t,{returnQuantity:s,returnReason:i})];case 1:return[2,o.sent()]}}))}))},t.updateReturnForm=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns/"+r,[4,Se.patch(t,n)];case 1:return[2,s.sent()]}}))}))},t.updateExchangeOrderId=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/returns/"+r+"/"+n,[4,Se.patch(t)];case 1:return[2,s.sent()]}}))}))},t.addLineItemToOrderGroup=function(e,r,n,s,i){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(o){switch(o.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/shipments/"+s+"/lineitems",[4,Se.post(t,i)];case 1:return[2,o.sent()]}}))}))},t.initLineItem=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){switch(i.label){case 0:return t=""+this.baseApiUrl+Er+"/inititem?currencyCode="+e+"&marketId="+r+"&customerId="+n,[4,Se.post(t,s)];case 1:return[4,i.sent().data];case 2:return[2,i.sent()]}}))}))},t.getOrderStatuses=function(){return Wt(t,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/orderstatuses",[4,Se.get(e)];case 1:return[2,t.sent().data]}}))}))},t.updateOrderStatus=function(e,r){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Er+"/"+e+"/status/"+r,[4,Se.put(t)];case 1:return[2,n.sent()]}}))}))},t.getReturnReasons=function(){return Wt(t,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/returnorders/returnreasons/",[4,Se.get(e)];case 1:return[2,t.sent().data]}}))}))},t.addShippingAddress=function(e,r,n,s,i){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(o){switch(o.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/shipments/"+s+"/shippingAddress",[4,Se.post(t,i)];case 1:return[2,o.sent()]}}))}))},t.updateShippingAddress=function(e,r,n,s,i){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(o){switch(o.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/shipments/"+s+"/shippingaddress",[4,Se.put(t,i)];case 1:return[2,o.sent()]}}))}))},t.updateShippingMethod=function(e,r,n,s,i){return Wt(t,void 0,void 0,(function(){var t,o;return qt(this,(function(a){switch(a.label){case 0:return t={shippingMethodId:i},o=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/shipments/"+s+"/shippingmethod",[4,Se.patch(o,t)];case 1:return[2,a.sent()]}}))}))},t.getPaymentModel=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/payments/getmodel/"+s,[4,Se.get(t)];case 1:return[2,i.sent().data]}}))}))},t.addPayment=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+n+"/forms/"+s+"/payments",[4,Se.post(t,r)];case 1:return[2,i.sent()]}}))}))},t.createRefund=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/orders/"+e+"/forms/"+r+"/payments/refund",[4,Se.post(t,n)];case 1:return[2,s.sent()]}}))}))},t.updateCurrencyForOrder=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t,s;return qt(this,(function(i){switch(i.label){case 0:return t=this.getOrderGroupRouting(e),s=this.baseApiUrl+"/"+t+"/"+r+"/currency/"+n,[4,Se.patch(s)];case 1:return[2,i.sent()]}}))}))},t.getPlacedPrice=function(e,r,n,s,i){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(o){switch(o.label){case 0:return t=this.baseApiUrl+"/entries/placedprice",[4,Se.post(t,{entryCode:e,quantity:r,marketId:n,currency:s,customerId:i})];case 1:return[2,o.sent()]}}))}))},t.getRefundInfo=function(e,r){return Wt(t,void 0,void 0,(function(){return qt(this,(function(t){switch(t.label){case 0:return[4,Se.get(this.baseApiUrl+"/orders/"+e+"/returns/"+r+"/getRefundInfo")];case 1:return[2,t.sent()]}}))}))},t.completeReturn=function(e,r){return Wt(t,void 0,void 0,(function(){return qt(this,(function(t){switch(t.label){case 0:return[4,Se.post(this.baseApiUrl+"/orders/"+e+"/returns/"+r+"/completeReturn")];case 1:return[2,t.sent()]}}))}))},t.initPaymentPlan=function(e,r){return Wt(t,void 0,void 0,(function(){var t,n,s;return qt(this,(function(i){switch(i.label){case 0:return t=""+this.baseApiUrl+Lr+"/initPaymentPlan/"+e+"/"+r,[4,Se.post(t)];case 1:return n=i.sent(),(s=Wr(n.data)).IsDraft=!0,[2,s]}}))}))},t}return Vt(t,e),t}(Hr),jr=function(e){function t(){var t=e.call(this)||this;return t.getCustomerCart=function(e,r){return Wt(t,void 0,void 0,(function(){var t,n,s;return qt(this,(function(i){switch(i.label){case 0:return t=""+this.baseApiUrl+Tr+"/"+e+xr+"/Default/"+r,[4,Se.get(t)];case 1:return n=i.sent(),s=Wr(n.data),[2,204===n.status?null:s]}}))}))},t.createOrRefreshCart=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t,s,i;return qt(this,(function(o){switch(o.label){case 0:return t=this.baseApiUrl+"/carts",[4,Se.put(t,null,{params:{marketId:r,contactId:e,cartName:n}})];case 1:return s=o.sent(),i=Wr(s.data),[2,201===s.status?i:null]}}))}))},t.deleteCart=function(e){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/carts/"+e,[4,Se.delete(t)];case 1:return[2,r.sent()]}}))}))},t.convertToPurchaseOrder=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+xr+"/"+e+"/ConvertToPurchaseOrder",[4,Se.post(t)];case 1:return r=n.sent(),[2,Wr(r.data)]}}))}))},t.convertToPaymentPlan=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+xr+"/"+e+"/ConvertToPaymentPlan",[4,Se.post(t)];case 1:return r=n.sent(),[2,Wr(r.data)]}}))}))},t.updateMarketForCart=function(e,r){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+xr+"/"+e+"/market/"+r,[4,Se.patch(t)];case 1:return[2,n.sent()]}}))}))},t}return Vt(t,e),t}(Hr),Yr=function(e){function t(){var t=e.call(this)||this;return t.getPurchaseOrders=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t,s;return qt(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e+"/purchaseOrders",[4,Se.get(t,{params:{orderGroupId:e,startingIndex:r,numberOfRecords:n}})];case 1:return[2,{TotalOrderGroups:(s=i.sent()).data.TotalOrderGroups,Results:s.data.Results.map((function(e,t){return Wr(e)}))}]}}))}))},t.convertToPurchaseOrder=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e+"/convertToPurchaseOrder",[4,Se.post(t)];case 1:return r=n.sent(),[2,Wr(r.data)]}}))}))},t.cancelPaymentPlan=function(e){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e+"/cancel",[4,Se.post(t)];case 1:return[2,r.sent()]}}))}))},t.createPaymentPlan=function(e,r){return Wt(t,void 0,void 0,(function(){var t,n;return qt(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e,[4,Se.post(t,r)];case 1:return n=s.sent(),[2,Wr(n.data)]}}))}))},t.updatePaymentPlanSetting=function(e,r){return Wt(t,void 0,void 0,(function(){var t,n;return qt(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e,[4,Se.put(t,r)];case 1:return n=s.sent(),[2,Wr(n.data)]}}))}))},t}return Vt(t,e),t}(Hr),zr=function(e){this.firstName=e.FirstName||"",this.middleName=e.MiddleName||"",this.lastName=e.LastName||"",this.fullName=e.FullName||"",this.email=e.Email||"",this.customerGroup=e.CustomerGroup||""},Qr=function(e){function t(t){return e.call(this,t)||this}return Vt(t,e),t}(zr),Kr=function(e){function t(t){var r=e.call(this,t)||this;return r.id=t.Id,r}return Vt(t,e),t}(zr);!function(e){e[e.Name=128]="Name",e[e.FirstName=64]="FirstName",e[e.LastName=64]="LastName",e[e.Organization=64]="Organization",e[e.Line1=80]="Line1",e[e.Line2=80]="Line2",e[e.City=64]="City",e[e.State=64]="State",e[e.CountryCode=50]="CountryCode",e[e.CountryName=50]="CountryName",e[e.PostalCode=20]="PostalCode",e[e.RegionCode=50]="RegionCode",e[e.RegionName=64]="RegionName",e[e.DaytimePhoneNumber=32]="DaytimePhoneNumber",e[e.EveningPhoneNumber=32]="EveningPhoneNumber",e[e.Email=256]="Email"}(lr||(lr={}));var Xr=lr,Jr=function(t){var r=t.value.toString();return e.createElement(Ne,{key:t.refreshCounter||0,label:t.label,value:r,disabled:t.disabled,required:t.required,enhanced:!0,outlined:!0,onEnhancedChange:function(e,r){if(t.onChange){var n=r.getAttribute("data-value");"number"==typeof t.value?t.onChange(Number(n)):t.onChange(n)}},className:"epi-exposed-dropdown"+(t.fullWidth?" fullwidth":"")+(t.dense?" dense":"")},t.options.map((function(t){return e.createElement(Re,{key:t.value,value:t.value},t.label)})))},Zr=function(){function e(){}return e.Required="required",e.IsEmpty="isEmpty",e.IsNumber="isNumber",e.IsFloat="isFloat",e.IsPositive="isPositive",e.IsString="isString",e.IsEmail="isEmail",e.MaxStringLength="maxStringLength",e.MinStringLength="minStringLength",e.NotAllowPotentialXSSCharacters="notAllowPotentialXSSCharacters",e.IsURL="isURL",e.IsDate="isDate",e.IsDateTime="isDateTime",e.IsFloatRegex="matchRegexp:^[+-]?([0-9]+[.])?[0-9]+$",e.IsMoney="isMoney",e.IsInteger="isInteger",e.IsDecimal="isDecimal",e.isValidInteger=function(e){return!(isNaN(e)||e>2147483647||e<-2147483648)},e.isValidMoney=function(e){var t=new Le(e);return""===e||!(t.isNaN()||t.decimalPlaces()>4||t.isGreaterThan(new Le("922337203685477.5807"))||t.isLessThan(0))},e.isValidDecimal=function(e){var t=new Le(e);return""===e||!(t.isNaN()||t.decimalPlaces()>0||t.gt(new Le("9".repeat(18)))||t.lt(new Le("-"+"9".repeat(18))))},e.isValidUrl=function(e){return!e||/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/.test(e)},e.setMaxStringLength=function(e){return"maxStringLength:"+e.toString()},e.setMinStringLength=function(e){return"minStringLength:"+e.toString()},e.getValidationMessage=function(t,r){switch(void 0===r&&(r=null),t){case e.Required:return"This field is required";case e.IsEmail:return"E-mail is not valid";case e.NotAllowPotentialXSSCharacters:return"Field must not contain any of the \n following characters: '<\">*%&:?";case e.MaxStringLength:return"Field exceeds maximum of "+r.toString()+" characters allowed";case e.MinStringLength:return"Field must be at least "+r.toString()+" character(s)";case e.IsNumber:return"Number is not valid";case e.IsURL:return"URL is not valid";case e.IsDate:return"Date is not valid";case e.IsDateTime:return"DateTime is not valid";case e.IsFloatRegex:return"Number is not valid";case e.IsMoney:return"Money is not valid";case e.IsInteger:return"Integer is not valid";case e.IsDecimal:return"Decimal is not valid";default:return"Not yet defined validation message"}},e.initCustomValidator=function(){Ee.addValidationRule(e.NotAllowPotentialXSSCharacters,(function(e){return!new RegExp(/[\<\>\*\%\&\:\\\?\'\"]/).test(e)})),Ee.addValidationRule(e.Required,(function(e){return null!=e&&void 0!==e&&(e instanceof Array?e.length>0:"string"!=typeof e||""!==e.trim())}))},e}();Zr.initCustomValidator();var $r=Ae({Name:Oe().trim().required(Zr.getValidationMessage(Zr.Required)).max(Xr.Name,Zr.getValidationMessage(Zr.MaxStringLength,Xr.Name)).test("NotAllowPotentialXSSCharacters","Field must not contain any of the following characters: ''<\">*%&:?'",(function(e){return!new RegExp(/[\<\>\*\%\&\:\\\?\'\"]/).test(e)})),FirstName:Oe().trim().max(Xr.FirstName,Zr.getValidationMessage(Zr.MaxStringLength,Xr.FirstName)).nullable(),LastName:Oe().trim().required(Zr.getValidationMessage(Zr.Required)).max(Xr.LastName,Zr.getValidationMessage(Zr.MaxStringLength,Xr.LastName)),Line1:Oe().trim().required(Zr.getValidationMessage(Zr.Required)).max(Xr.Line1,Zr.getValidationMessage(Zr.MaxStringLength,Xr.Line1)),Line2:Oe().trim().max(Xr.Line2,Zr.getValidationMessage(Zr.MaxStringLength,Xr.Line2)).nullable(),City:Oe().trim().required(Zr.getValidationMessage(Zr.Required)).max(Xr.City,Zr.getValidationMessage(Zr.MaxStringLength,Xr.City)),PostalCode:Oe().trim().max(Xr.PostalCode,Zr.getValidationMessage(Zr.MaxStringLength,Xr.PostalCode)).nullable(),CountryCode:Oe().trim().required(Zr.getValidationMessage(Zr.Required)),RegionCode:Oe().trim().max(Xr.RegionCode,Zr.getValidationMessage(Zr.MaxStringLength,Xr.RegionCode)).nullable(),DaytimePhoneNumber:Oe().trim().max(Xr.DaytimePhoneNumber,Zr.getValidationMessage(Zr.MaxStringLength,Xr.DaytimePhoneNumber)).nullable(),Email:Oe().trim().max(Xr.Email,Zr.getValidationMessage(Zr.MaxStringLength,Xr.Email)).email(Zr.getValidationMessage(Zr.IsEmail)).nullable()}),en=function(e){function r(t){var r=e.call(this,t)||this;return r.state={errors:{},countryOptions:[]},r.setCurrentAddress=function(e){r.props.dispatch(fr.ContactActions.setCurrentAddress(e)),r.props.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!0))},r.handleCountryChanged=function(e){var t=Bt({},r.props.address),n=r.props.availableCountries.find((function(t){return t.Code===e}));if(t.DaytimePhoneNumber=n.CallingCode+" ",t.CountryCode=e,t.CountryName=n.Name,r.setCurrentAddress(t),"USA"===e&&t.PostalCode){var s=be(t.PostalCode);s&&(t.RegionCode=Ie(s.state))}r.setCurrentAddress(t)},r.handleFormChanges=function(e){return Wt(r,void 0,void 0,(function(){var t,r,n;return qt(this,(function(s){return t=e.target.name,r=Object.assign({},this.props.address),n="checkbox"===e.target.type?e.target.checked:e.target.value,r[t]=n,this.setCurrentAddress(r),[2]}))}))},r.validateForm=function(){try{return $r.validateSync(r.props.address,{abortEarly:!1})}catch(t){var e={};return t.inner.map((function(t){e[t.path]=t.message})),r.setState({errors:e}),null}},r.state.countryOptions=r.props.availableCountries.map((function(e){return{label:e.Name,value:e.Code}})),r.props.mode===Jt.Add&&(r.props.address.FirstName=r.props.currentAddress.FirstName,r.props.address.LastName=r.props.currentAddress.LastName),r.props.validator.validate=r.validateForm,r}return Vt(r,e),r.prototype.render=function(){var e=this;return t(l,{container:!0,spacing:16},t(l,{item:!0,sm:12},t(h,{fullWidth:!0,variant:"outlined",name:"Name",label:"Address Name",value:this.props.address.Name||"",onChange:this.handleFormChanges,required:!0,error:!!this.state.errors.Name,helperText:this.state.errors.Name})),t(l,{item:!0,sm:12,md:6},t(h,{fullWidth:!0,variant:"outlined",name:"FirstName",label:"First Name",value:this.props.address.FirstName||"",onChange:this.handleFormChanges,error:!!this.state.errors.FirstName,helperText:this.state.errors.FirstName})),t(l,{item:!0,sm:12,md:6},t(h,{fullWidth:!0,variant:"outlined",name:"LastName",label:"Last Name",value:this.props.address.LastName||"",onChange:this.handleFormChanges,required:!0,error:!!this.state.errors.LastName,helperText:this.state.errors.LastName})),t(l,{item:!0,sm:12},t(h,{fullWidth:!0,variant:"outlined",name:"Line1",label:"Address Line 1",value:this.props.address.Line1||"",onChange:this.handleFormChanges,required:!0,error:!!this.state.errors.Line1,helperText:this.state.errors.Line1})),t(l,{item:!0,sm:12},t(h,{fullWidth:!0,variant:"outlined",name:"Line2",label:"Address Line 2",value:this.props.address.Line2||"",onChange:this.handleFormChanges,error:!!this.state.errors.Line2,helperText:this.state.errors.Line2})),t(l,{item:!0,sm:12,md:6},t(h,{fullWidth:!0,variant:"outlined",name:"City",label:"City",value:this.props.address.City||"",onChange:this.handleFormChanges,required:!0,error:!!this.state.errors.City,helperText:this.state.errors.City})),t(l,{item:!0,sm:12,md:6},t(h,{fullWidth:!0,variant:"outlined",name:"PostalCode",label:"ZIP / PostalCode",value:this.props.address.PostalCode||"",onChange:this.handleFormChanges,error:!!this.state.errors.PostalCode,helperText:this.state.errors.PostalCode})),t(l,{item:!0,sm:12,md:6},t(Jr,{fullWidth:!0,required:!0,label:"Country",value:this.props.address.CountryCode||"",options:this.state.countryOptions,onChange:function(t){return e.handleCountryChanged(t)}}),t(m,{variant:"caption",color:"error"},this.state.errors.CountryCode)),t(l,{item:!0,sm:12,md:6},t(h,{fullWidth:!0,variant:"outlined",name:"RegionCode",label:"State / Province / Region",value:this.props.address.RegionCode||"",onChange:this.handleFormChanges,error:!!this.state.errors.RegionCode,helperText:this.state.errors.RegionCode})),t(l,{item:!0,sm:12,md:6},t(h,{fullWidth:!0,variant:"outlined",name:"DaytimePhoneNumber",label:"Phone Number",value:this.props.address.DaytimePhoneNumber||"",onChange:this.handleFormChanges,error:!!this.state.errors.DaytimePhoneNumber,helperText:this.state.errors.DaytimePhoneNumber})),t(l,{item:!0,sm:12,md:6},t(h,{fullWidth:!0,variant:"outlined",name:"Email",label:"E-mail",value:this.props.address.Email||"",onChange:this.handleFormChanges,error:!!this.state.errors.Email,helperText:this.state.errors.Email})))},r}(n),tn=function(e){function t(){var t=e.call(this)||this;return t.get=function(e){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/customers/"+e,[4,Se.get(t)];case 1:return[2,r.sent().data]}}))}))},t.list=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/customers",r={filter:e},[4,Se.get(t,{params:r})];case 1:return[2,n.sent().data]}}))}))},t.getCustomerGroups=function(){return Wt(t,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/customergroups",[4,Se.get(e)];case 1:return[2,t.sent().data]}}))}))},t.updatePersonalInformation=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/customers/"+e.Id,r=new Kr(e),[4,Se.put(t,r)];case 1:return[2,n.sent().data]}}))}))},t.createContact=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/customers",r=new Qr(e),[4,Se.post(t,r)];case 1:return[2,n.sent().data]}}))}))},t.addContactAddress=function(e,r){return Wt(t,void 0,void 0,(function(){var t,n;return qt(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=[Bt({},r)],[4,$r.validate(r)];case 1:return r=Bt.apply(void 0,t.concat([s.sent()])),[3,3];case 2:throw s.sent(),new Error("The address is invalid!");case 3:return n=this.baseApiUrl+"/customers/"+e+"/addresses",[4,Se.post(n,r)];case 4:return[2,s.sent()]}}))}))},t.updateContactAddress=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t,s;return qt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=[Bt({},n)],[4,$r.validate(n)];case 1:return n=Bt.apply(void 0,t.concat([i.sent()])),[3,3];case 2:throw i.sent(),new Error("The address is invalid!");case 3:return s=this.baseApiUrl+"/customers/"+e+"/addresses/"+encodeURIComponent(r),[4,Se.put(s,n)];case 4:return[2,i.sent()]}}))}))},t.deleteContactAddress=function(e,r){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/customers/"+e+"/addresses/"+encodeURIComponent(r),[4,Se.delete(t)];case 1:return[2,n.sent()]}}))}))},t}return Vt(t,e),t}(Hr),rn=function(e){function t(){var t=e.call(this)||this;return t.getMarkets=function(){return Wt(t,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/markets",[4,Se.get(e)];case 1:return[2,t.sent().data]}}))}))},t}return Vt(t,e),t}(Hr),nn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.updateOrderGroupMetaFields=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(r)+"/"+e+"/metaFields",[4,Se.patch(t,n)];case 1:return[2,s.sent().data]}}))}))},t.updateOrderShipmentMetaFields=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(r)+"/"+e+"/shipments/"+n+"/metaFields",[4,Se.patch(t,s)];case 1:return[2,i.sent().data]}}))}))},t.updateOrderLineItemMetaFields=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(r)+"/"+e+"/lineitems/"+n+"/metaFields",[4,Se.patch(t,s)];case 1:return[2,i.sent().data]}}))}))},t}return Vt(t,e),t}(Hr),sn=function(e){function t(){var t=e.call(this)||this;return t.getPaymentMethods=function(e){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/paymentmethods/"+(e||""),[4,Se.get(t)];case 1:return[2,r.sent().data]}}))}))},t}return Vt(t,e),t}(Hr),on=function(e){function t(){var t=e.call(this)||this;return t.getShippingMethods=function(e,r){return Wt(t,void 0,void 0,(function(){var t,n;return qt(this,(function(s){switch(s.label){case 0:return t={marketId:e,countryCode:r},n=this.baseApiUrl+"/shippingMethods",[4,Se.get(n,{params:t})];case 1:return[2,s.sent().data]}}))}))},t.getShipmentStatuses=function(){return Wt(t,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/shipmentstatuses/",[4,Se.get(e)];case 1:return[2,t.sent().data]}}))}))},t.updateShipmentStatus=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){return t=""+this.baseApiUrl+Er+"/"+e+"/forms/"+r+"/shipments/"+n+"/shipmentstatus/"+s,[2,Se.patch(t)]}))}))},t.addToPickList=function(e,r,n){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(s){return t=""+this.baseApiUrl+Er+"/"+e+"/forms/"+r+"/shipments/"+n+"/addToPickList",[2,Se.post(t)]}))}))},t.updateShipmentTrackingNumber=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){return t=""+this.baseApiUrl+Er+"/"+e+"/forms/"+r+"/shipments/"+n+"/trackingNumber",[2,Se.patch(t,null,{params:{trackingNumber:s}})]}))}))},t}return Vt(t,e),t}(Hr),an=function(e){function t(){var t=e.call(this)||this;return t.search=function(e){return Wt(t,void 0,void 0,(function(){var t,r,n,s,i,o;return qt(this,(function(a){switch(a.label){case 0:return t=gr.getState().orderGroup.currentOrderGroup,r=t.MarketId,n=t.Customer.Id,s=t.Total.Currency,i=this.baseApiUrl+"/entries",o={keyword:e,marketId:r,customerId:n,currencyCode:s},[4,Se.get(i,{params:o})];case 1:return[2,a.sent().data]}}))}))},t.getEntryDetail=function(e){return Wt(t,void 0,void 0,(function(){var t,r,n;return qt(this,(function(s){switch(s.label){case 0:return t=gr.getState().orderGroup.currentOrderGroup,r=this.baseApiUrl+"/entries/"+e,n={marketId:t.MarketId,currencyCode:t.Total.Currency,customerId:t.Customer.Id},[4,Se.get(r,{params:n})];case 1:return[2,s.sent().data]}}))}))},t}return Vt(t,e),t}(Hr),un=function(e){function t(){var t=e.call(this)||this;return t.getCurrencies=function(e){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/currencies/"+e,[4,Se.get(t)];case 1:return[2,r.sent().data]}}))}))},t}return Vt(t,e),t}(Hr),dn=[];Object.keys(Me).forEach((function(e){var t=Me[e.toString()];dn.push({countryCode:e,name:t.name,phoneCode:t.phone})}));var cn=function(e){function t(){var t=e.call(this)||this;return t.getCountries=function(){return Wt(t,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/countries",[4,Se.get(e)];case 1:return[2,t.sent().data.map((function(e){return function(e){var t=dn.find((function(t){return t.name===e.Name}));return t?Bt(Bt({},e),{CallingCode:t.phoneCode?"+"+t.phoneCode:"",FlagSvgImage:require("flag-icon-css/flags/4x3/"+t.countryCode.toLowerCase()+".svg")}):e}(e)}))]}}))}))},t}return Vt(t,e),t}(Hr),pn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.getOrdersByCustomerId=function(e,r,n,s){return Wt(t,void 0,void 0,(function(){var t;return qt(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/orderhistory?customerId="+e+"&startingIndex="+r+"&numberOfRecords="+n+"&returnTotalCount="+s,[4,Se.get(t)];case 1:return[2,i.sent().data]}}))}))},t}return Vt(t,e),t}(Hr),ln={Cart:new jr,OrderGroup:new qr,PaymentPlan:new Yr,Contact:new tn,MetaField:new nn,PaymentMethod:new sn,Shipment:new on,Catalog:new an,Market:new rn,Currency:new un,Geographics:new cn,OrderHistory:new pn},hn=function(e){var r=e.classes;return e.text?t("div",{className:r.optionalTypography},e.icon,t(We,{gutterBottom:!0},e.text)):null},mn={marginDefault:20,paddingDefault:20,addressBoxMinWidth:325,addressBoxMinHeight:256},fn={light:"#f8f8f8",hoveredList:"#ededed"},gn={paddingTop:4,paddingBottom:4},yn=z((function(e){e.palette;var t=e.spacing;e.breakpoints;return c({root:{minWidth:mn.addressBoxMinWidth,height:"100%"},header:{borderBottom:"solid 1px",borderBottomColor:fn.hoveredList},content:{padding:mn.paddingDefault},address:{marginTop:t.unit,marginBottom:2*t.unit},optionalTypography:{display:"flex"},optionalTypographyIcon:{marginRight:t.unit}})}))(u((function(e,t){return{address:t.address,classes:t.classes,isReadonly:t.isReadonly}}))((function(e){var r,n=e.classes,s=(r=e.address).IsPreferredBillingAddress&&r.IsPreferredShippingAddress?"Preferred Shipping & Billing Address":r.IsPreferredShippingAddress?"Preferred Shipping Address":r.IsPreferredBillingAddress?"Preferred Billing Address":void 0,i="";e.address.City&&(i+=e.address.City),e.address.RegionCode&&(i+=", "+e.address.RegionCode),e.address.PostalCode&&(i+=", "+e.address.PostalCode);return t(Ue,{className:n.root},t(Be,{className:n.header,title:s,titleTypographyProps:{variant:"body2"},action:!e.isReadonly&&t("div",null,t(ie,{"area-label":"Edit",onClick:function(){return function(t){e.dispatch(fr.ContactActions.setCurrentAddress(t)),e.dispatch(fr.AddressFormActions.initializeAddressForm(t)),e.dispatch(fr.ContactActions.setAddressDetailsViewMode(Jt.Edit))}(e.address)}},t(oe,null)),t(ie,{"aria-label":"Delete",onClick:function(){return function(t){e.dispatch(fr.ContactActions.setCurrentAddress(t)),e.dispatch(fr.ApplicationActions.setCurrentDialog(zt.DeleteAddress))}(e.address)}},t(ae,null)))}),t(He,{className:n.content},t(We,{variant:"body2",gutterBottom:!0},e.address.Name),t($,{container:!0,spacing:8},t($,{item:!0},t(hn,{text:e.address.FirstName,classes:n})),t($,{item:!0},t(hn,{text:e.address.LastName,classes:n}))),t("div",{className:n.address},t(We,{gutterBottom:!0},e.address.Line1),t(We,{gutterBottom:!0},e.address.Line2),t(hn,{text:i,classes:n}),t(We,{gutterBottom:!0},e.address.CountryName)),t(hn,{text:e.address.DaytimePhoneNumber,classes:n,icon:t(je,{fontSize:"small",className:n.optionalTypographyIcon})}),t(hn,{text:e.address.Email,classes:n,icon:t(qe,{fontSize:"small",className:n.optionalTypographyIcon})})))}))),vn=z((function(e){e.palette,e.spacing,e.breakpoints;return c({root:{height:"100%",minWidth:mn.addressBoxMinWidth},actionArea:{height:"100%"}})}))(u((function(e,t){return{classes:t.classes,customer:e.orderGroup.currentOrderGroup?e.orderGroup.currentOrderGroup.Customer:void 0}}))((function(e){var r=e.classes;return t(Ue,{className:r.root},t(ze,{className:r.actionArea,onClick:function(){var t,r={};e.customer&&(r.FirstName=e.customer.FirstName,r.LastName=e.customer.LastName),t=r,e.dispatch(fr.ContactActions.setCurrentAddress(t)),e.dispatch(fr.ContactActions.setAddressDetailsViewMode(Jt.Add))}},t($,{container:!0,direction:"column",alignItems:"center"},t($,{item:!0},t(Ye,{fontSize:"large"})),t($,{item:!0},t(We,{variant:"button"},"New Address")))))}))),Cn=function(e){return t(f,{open:e.open,onClose:e.onClose,style:{zIndex:1e4,margin:"0 auto"},maxWidth:e.large?"md":"sm",fullWidth:!0},t(g,null,e.title),t(y,{style:{paddingTop:"5px"}},e.children),t(v,null,t(se,{onClick:e.onClose},e.closeLabel),e.onOK&&t(se,{onClick:e.onOK},e.okLabel)))};Cn.defaultProps={okLabel:"OK",closeLabel:"Close"};var Sn=function(e){return t(Cn,{open:!0,title:e.title,onClose:e.onClose,closeLabel:e.closeButtonLabel,okLabel:e.confirmButtonLabel,onOK:e.onConfirm},e.children)},In=function(e){e.palette,e.spacing,e.breakpoints;return c({root:{},item:{minHeight:256}})},bn=z(In)((function(e){if(!e.address)return t(r,null);var n=e.address.DisplayName;return n||(n=e.address?[e.address.Line1,e.address.Line2,e.address.City,e.address.RegionCode,e.address.PostalCode,e.address.CountryName,e.address.CountryCode].filter((function(e){return e})).join(", "):""),t("div",null,t(We,{variant:"body2"},n))})),An=u((function(e,t){return{address:e.contact.currentAddress,contact:e.contact.currentContact}}))((function(e){var r=function(){e.dispatch(fr.ContactActions.setCurrentAddress(null)),e.dispatch(fr.ApplicationActions.setCurrentDialog(zt.None))};return null==e.address?null:t(Sn,{title:"Delete address?",closeButtonLabel:"Cancel",confirmButtonLabel:"Delete",onConfirm:function(){return Wt(void 0,void 0,void 0,(function(){var t,n;return qt(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,ln.Contact.deleteContactAddress(e.contact.Id,e.address.AddressId)];case 1:return s.sent(),[4,ln.Contact.get(e.contact.Id)];case 2:return t=s.sent(),e.dispatch(fr.ContactActions.setCurrentContact(t)),[3,4];case 3:return n=s.sent(),e.dispatch(fr.ApplicationActions.showNotification(n.message)),[3,4];case 4:return r(),[2]}}))}))},onClose:r},t(bn,{address:e.address}))})),On=z((function(e){e.palette,e.spacing,e.breakpoints;return c({root:{},container:{display:"flex",flexWrap:"wrap"}})}))(u((function(e,t){return{mode:e.contact.addressDetailsViewMode,address:t.address,classes:t.classes,country:e.geographics.countries.find((function(t){return t.Code===e.contact.currentAddress.CountryCode})),availableCountries:e.geographics.countries,currentAddress:e.contact.currentAddress,validator:t.validator}}))(en)),wn=function(e){function r(t){var r=e.call(this,t)||this;return r.state={loaded:!1},r.validator={validate:function(){return null}},r.closeView=function(){r.props.dispatch(fr.ContactActions.setAddressDetailsViewMode(Jt.Hide)),r.props.dispatch(fr.AddressFormActions.clearAddressForm()),r.props.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!1))},r.setCurrentAddress=function(e){r.props.dispatch(fr.ContactActions.setCurrentAddress(e)),r.props.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!0))},r.handleFormChanges=function(e){var t=Object.assign({},r.props.address),n="checkbox"===e.target.type?e.target.checked:e.target.value;t[e.target.name]=n,r.setCurrentAddress(t)},r.saveChanges=function(){return Wt(r,void 0,void 0,(function(){var e,t,r,n,s;return qt(this,(function(i){switch(i.label){case 0:if(null==(e=this.validator.validate()))return[2];t=Bt(Bt({},this.props.address),e),i.label=1;case 1:return i.trys.push([1,9,,10]),this.props.mode!==Jt.Add?[3,3]:[4,ln.Contact.addContactAddress(this.props.currentContactId,t)];case 2:return i.sent(),[3,5];case 3:return[4,ln.Contact.updateContactAddress(this.props.currentContactId,t.AddressId.trim(),t)];case 4:i.sent(),i.label=5;case 5:return(r=this.props.orderGroup.currentOrderGroup)?[4,this.updateOrderGroup(r)]:[3,7];case 6:i.sent(),i.label=7;case 7:return[4,ln.Contact.get(this.props.currentContactId)];case 8:return n=i.sent(),this.props.dispatch(fr.ContactActions.setCurrentContact(n)),this.closeView(),[3,10];case 9:return s=i.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(s.message)),[3,10];case 10:return[2]}}))}))},r}return Vt(r,e),r.prototype.componentDidMount=function(){this.setState({loaded:!0})},r.prototype.updateOrderGroup=function(e){return Wt(this,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return e.IsDraft?[3,2]:[4,ln.OrderGroup.getSingleOrderGroup(e.Type,e.OrderGroupId)];case 1:return t=n.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(t)),[3,4];case 2:return[4,ln.OrderGroup.calculateOrder(e)];case 3:r=n.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(r)),n.label=4;case 4:return[2]}}))}))},r.prototype.render=function(){return t(Cn,{open:!0,title:this.props.mode===Jt.Edit?"Edit Address":"Add New Address",okLabel:"Save",onOK:this.saveChanges,closeLabel:"Cancel",onClose:this.closeView},this.state.loaded&&t(l,{container:!0,spacing:16},t(l,{item:!0,sm:12},t(On,{address:this.props.address,validator:this.validator})),t(l,{item:!0,sm:12},t(C,{control:t(ue,{name:"IsPreferredShippingAddress",checked:this.props.address.IsPreferredShippingAddress,onChange:this.handleFormChanges}),label:"Preferred Shipping Address"})),t(l,{item:!0,sm:12},t(C,{control:t(ue,{name:"IsPreferredBillingAddress",checked:this.props.address.IsPreferredBillingAddress,onChange:this.handleFormChanges}),label:"Preferred Billing Address"}))))},r}(n),Tn=z((function(e){e.spacing;return c({actions:{marginTop:15}})}))(u((function(e,t){return{mode:e.contact.addressDetailsViewMode,address:e.contact.currentAddress,classes:t.classes,currentContactId:e.contact.currentContact.Id,orderGroup:e.orderGroup}}))(wn)),Dn=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Vt(r,e),r.prototype.componentWillMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.initData()];case 1:return e.sent(),[2]}}))}))},r.prototype.shouldComponentUpdate=function(e,t){var r=this;return e.contactId!==this.props.contactId&&setTimeout((function(){r.initData()}),200),!0},r.prototype.initData=function(){return Wt(this,void 0,void 0,(function(){var e,t,r,n,s,i,o;return qt(this,(function(a){switch(a.label){case 0:this.props.dispatch(fr.ContactActions.setAddressDetailsViewMode(Jt.Hide)),this.props.dispatch(fr.AddressFormActions.clearAddressForm()),this.props.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!1)),a.label=1;case 1:return a.trys.push([1,7,,8]),e=new URLSearchParams(this.props.location.search),t=parseInt(e.get("orderId"),10),r=e.get("orderType"),this.props.orderGroup||NaN===t||!r?[3,3]:[4,ln.OrderGroup.getSingleOrderGroup(r,t)];case 2:n=a.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(n)),a.label=3;case 3:return[4,ln.Contact.get(this.props.contactId)];case 4:return s=a.sent(),this.props.dispatch(fr.ContactActions.setCurrentContact(s)),0!==this.props.availableCountries.length?[3,6]:[4,(new cn).getCountries()];case 5:i=a.sent(),this.props.dispatch(fr.GeographicsActions.setCountries(i)),a.label=6;case 6:return[3,8];case 7:return o=a.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(o.message)),[3,8];case 8:return[2]}}))}))},r.prototype.render=function(){var e=this,r=this.props.classes;return this.props.contact&&t("div",null,t($,{container:!0,spacing:24,className:r.root},this.props.contact.Addresses.map((function(n,s){return t($,{item:!0,key:s,className:r.item},t(yn,{address:n,isReadonly:e.props.isReadonly}))})),!this.props.isReadonly&&t($,{item:!0,className:r.item},t(vn,null))),this.props.addressDetailsViewMode!==Jt.Hide&&t(Tn,null),this.props.addressDeleteDialogIsVisible&&t(An,null))},r}(n),Pn=z(In)(u((function(e,t){return Bt({contact:e.contact.currentContact,addressDeleteDialogIsVisible:e.application.currentDialog===zt.DeleteAddress,addressDetailsViewMode:e.contact.addressDetailsViewMode,orderGroup:e.orderGroup.currentOrderGroup,availableCountries:e.geographics.countries},t)}))(Dn)),Gn=function(e){return t(Qe,Bt({direction:"left"},e))},Nn=z((function(e){var t=e.palette,r=(e.spacing,e.breakpoints,e.zIndex);return c({root:{},content:{marginTop:20},title:{flexGrow:1},appBar:{position:"relative",zIndex:r.drawer+1},appBarIcon:{color:t.common.white}})}))(u((function(e,t){return{title:t.title,children:t.children,showDialogActions:t.showDialogActions,classes:t.classes,closeView:t.closeView,menuAction:t.menuAction}}))((function(e){var r=e.classes,n=e.children;return t(te,{className:r.root,open:!0,fullScreen:!0,onClose:e.closeView,TransitionComponent:Gn},t(Xe,{className:r.appBar},t(Je,null,t(ie,{onClick:e.closeView,"aria-label":"Close"},t(de,{className:r.appBarIcon})),t(We,{variant:"h6",color:"inherit",className:r.title},e.title),e.menuAction&&t(Ke,{smUp:!0,implementation:"js"},t(ie,{onClick:e.menuAction},t(Ze,{className:r.appBarIcon}))))),t(ne,{className:r.content},n),e.showDialogActions&&t(re,null,t(se,{unelevated:!0,onClick:e.closeView},"Close")))}))),Rn=u((function(e,t){return{discardChanges:t.discardChanges}}))((function(e){return t(Sn,{title:"Leave page?",closeButtonLabel:"Cancel",confirmButtonLabel:"Leave",onConfirm:function(){e.discardChanges(),e.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!1))},onClose:function(){e.dispatch(fr.ApplicationActions.setCurrentDialog(zt.None)),e.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!0))}},t(We,{variant:"body1"},"You have unsaved changes. Do you want to leave the page without saving?"))}));function En(){return(En=Object.assign||function(e){for(var t=1;t=0;c--){var p=s[c];"."===p?_n(s,c):".."===p?(_n(s,c),d++):d&&(_n(s,c),d--)}if(!a)for(;d--;d)s.unshift("..");!a||""===s[0]||s[0]&&kn(s[0])||s.unshift("");var l=s.join("/");return r&&"/"!==l.substr(-1)&&(l+="/"),l},Un=xn((function(e){"production"===process.env.NODE_ENV?e.exports=Fn:e.exports=Vn}));function Bn(e){return e.valueOf?e.valueOf():Object.prototype.valueOf.call(e)}var Hn=function e(t,r){if(t===r)return!0;if(null==t||null==r)return!1;if(Array.isArray(t))return Array.isArray(r)&&t.length===r.length&&t.every((function(t,n){return e(t,r[n])}));if("object"!=typeof t&&"object"!=typeof r)return!1;var n=Bn(t),s=Bn(r);return n!==t||s!==r?e(n,s):Object.keys(Object.assign({},t,r)).every((function(n){return e(t[n],r[n])}))};function Wn(e){return e.valueOf?e.valueOf():Object.prototype.valueOf.call(e)}var qn=function e(t,r){if(t===r)return!0;if(null==t||null==r)return!1;if(Array.isArray(t))return Array.isArray(r)&&t.length===r.length&&t.every((function(t,n){return e(t,r[n])}));if("object"==typeof t||"object"==typeof r){var n=Wn(t),s=Wn(r);return n!==t||s!==r?e(n,s):Object.keys(Object.assign({},t,r)).every((function(n){return e(t[n],r[n])}))}return!1},jn=(xn((function(e){"production"===process.env.NODE_ENV?e.exports=Hn:e.exports=qn})),"production"===process.env.NODE_ENV);function Yn(e,t){if(!jn){if(e)return;var r="Warning: "+t;"undefined"!=typeof console&&console.warn(r);try{throw Error(r)}catch(e){}}}var zn="production"===process.env.NODE_ENV;function Qn(e,t){if(!e){if(zn)throw new Error("Invariant failed");throw new Error("Invariant failed: "+(t||""))}}function Kn(e){return"/"===e.charAt(0)?e:"/"+e}function Xn(e){return"/"===e.charAt(0)?e.substr(1):e}function Jn(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}function Zn(e){var t=e.pathname,r=e.search,n=e.hash,s=t||"/";return r&&"?"!==r&&(s+="?"===r.charAt(0)?r:"?"+r),n&&"#"!==n&&(s+="#"===n.charAt(0)?n:"#"+n),s}function $n(e,t,r,n){var s;"string"==typeof e?(s=function(e){var t=e||"/",r="",n="",s=t.indexOf("#");-1!==s&&(n=t.substr(s),t=t.substr(0,s));var i=t.indexOf("?");return-1!==i&&(r=t.substr(i),t=t.substr(0,i)),{pathname:t,search:"?"===r?"":r,hash:"#"===n?"":n}}(e)).state=t:(void 0===(s=En({},e)).pathname&&(s.pathname=""),s.search?"?"!==s.search.charAt(0)&&(s.search="?"+s.search):s.search="",s.hash?"#"!==s.hash.charAt(0)&&(s.hash="#"+s.hash):s.hash="",void 0!==t&&void 0===s.state&&(s.state=t));try{s.pathname=decodeURI(s.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+s.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return r&&(s.key=r),n?s.pathname?"/"!==s.pathname.charAt(0)&&(s.pathname=Un(s.pathname,n.pathname)):s.pathname=n.pathname:s.pathname||(s.pathname="/"),s}var es=!("undefined"==typeof window||!window.document||!window.document.createElement);function ts(e,t){t(window.confirm(e))}var rs={hashbang:{encodePath:function(e){return"!"===e.charAt(0)?e:"!/"+Xn(e)},decodePath:function(e){return"!"===e.charAt(0)?e.substr(1):e}},noslash:{encodePath:Xn,decodePath:Kn},slash:{encodePath:Kn,decodePath:Kn}};function ns(e){var t=e.indexOf("#");return-1===t?e:e.slice(0,t)}function ss(){var e=window.location.href,t=e.indexOf("#");return-1===t?"":e.substring(t+1)}function is(e){window.location.replace(ns(window.location.href)+"#"+e)}var os,as=function(e){void 0===e&&(e={}),es||("production"!==process.env.NODE_ENV?Qn(!1,"Hash history needs a DOM"):Qn(!1));var t=window.history,r=-1===window.navigator.userAgent.indexOf("Firefox"),n=e,s=n.getUserConfirmation,i=void 0===s?ts:s,o=n.hashType,a=void 0===o?"slash":o,u=e.basename?function(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}(Kn(e.basename)):"",d=rs[a],c=d.encodePath,p=d.decodePath;function l(){var e=p(ss());return"production"!==process.env.NODE_ENV&&Yn(!u||Jn(e,u),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+e+'" to begin with "'+u+'".'),u&&(e=function(e,t){return Jn(e,t)?e.substr(t.length):e}(e,u)),$n(e)}var h,m,f=(h=null,m=[],{setPrompt:function(e){return"production"!==process.env.NODE_ENV&&Yn(null==h,"A history supports only one prompt at a time"),h=e,function(){h===e&&(h=null)}},confirmTransitionTo:function(e,t,r,n){if(null!=h){var s="function"==typeof h?h(e,t):h;"string"==typeof s?"function"==typeof r?r(s,n):("production"!==process.env.NODE_ENV&&Yn(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),n(!0)):n(!1!==s)}else n(!0)},appendListener:function(e){var t=!0;function r(){t&&e.apply(void 0,arguments)}return m.push(r),function(){t=!1,m=m.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,t=new Array(e),r=0;r0){for(t=e[0].DisplayName;t.length<120&&r1?"products":"product")}}return t},r.state.page<0&&(r.state.page=0),r}return Vt(r,e),r.prototype.getPageParam=function(){var e=parseInt(this.query.get("page"),10)-1||0;return e<0&&(e=0),e},r.prototype.getRowsPerPageParam=function(){var e=parseInt(this.query.get("rowsPerPage"),10)||10;return Cs.indexOf(e)>=0?e:10},r.prototype.shouldComponentUpdate=function(e,t){var r=this;this.query=new URLSearchParams(as.location.search);var n=this.getPageParam(),s=this.getRowsPerPageParam();return this.state.page===n&&this.state.rowsPerPage===s||this.setState({page:n,rowsPerPage:s},(function(){return Wt(r,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.getData()];case 1:return e.sent(),[2]}}))}))})),!0},r.prototype.componentWillMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.getData()];case 1:return e.sent(),[2]}}))}))},r.prototype.render=function(){var e=this,r=this.props.classes;return t("div",{className:r.root},t(it,{className:r.paper},t("div",{className:r.tableWrapper},t($e,{className:r.table},t(rt,null,t(st,null,vs.map((function(e){return t(tt,{className:r.headerLable,key:e.id,align:e.numeric?"right":"left",padding:e.disablePadding?"none":"default",style:{minWidth:e.minWidth}},e.label)})))),t(et,null,this.state.orderList.map((function(n,s){return t(st,{hover:!0,key:s},t(tt,null,t(Fe,{className:r.link,to:Er+"/"+n.OrderGroupId},n.OrderNumber)),t(tt,null,ot(n.Created).format("LLL")),t(tt,null," ",e.getItemDescriptions(n.LineItems)),t(tt,{align:"right"},n.Total.Amount.toFixed(n.Total.Fractions)+" "+n.Total.Currency),t(tt,null,n.OrderStatus))}))))),t(nt,{rowsPerPageOptions:Cs,component:"div",count:this.state.totalRecords,rowsPerPage:this.state.rowsPerPage,page:this.state.page,backIconButtonProps:{"aria-label":"previous page"},nextIconButtonProps:{"aria-label":"next page"},onChangePage:this.handleChangePage,onChangeRowsPerPage:this.handleChangeRowsPerPage})))},r}(n),Is=z((function(e){return Q({tableWrapper:{overflowX:"auto"},link:{textDecoration:"none",color:e.palette.primary.main+" !important"},headerLable:{fontWeight:"bold"}})}))(Ss);function bs(e){return t(Is,Bt({},e))}var As,Os=function(e){return t($,{item:!0,xs:12,style:{minHeight:50}},t($,{container:!0},t($,{item:!0,xs:12,sm:3},t(We,{variant:"body1"},e.label,":")),t($,{item:!0,xs:12,sm:9},t(We,{variant:"body1"},e.value))))},ws=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.classes=t.props.classes,t}return Vt(r,e),r.prototype.componentWillMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.getData(this.props.contactId)];case 1:return e.sent(),[2]}}))}))},r.prototype.shouldComponentUpdate=function(e,t){return e.contactId!==this.props.contactId&&this.getData(e.contactId),!0},r.prototype.getData=function(e){return Wt(this,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return[4,ln.Contact.get(e)];case 1:return t=r.sent(),this.props.dispatch(fr.ContactActions.setCurrentContact(t)),[2]}}))}))},r.prototype.openContactPersonalInformationEditView=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){try{this.props.dispatch(fr.ContactActions.showPersonalInformationEditView())}catch(e){this.props.dispatch(fr.ApplicationActions.showNotification(e.message))}return[2]}))}))},r.prototype.render=function(){return this.props.contact&&t(Ue,{className:this.classes.root},t(Be,{className:this.classes.header,action:!this.props.isReadonly&&t(Fe,{to:"./edit",className:this.classes.action,replace:!0},t(at,{title:"Edit the contact's personal information"},t(ie,null,t(oe,{className:this.classes.icon})))),title:"Personal Information",titleTypographyProps:{className:this.classes.title,variant:"subheading"}}),t(He,null,t($,{container:!0,direction:"column",spacing:8},t(Os,{label:"Full Name",value:this.props.contact.FullName}),t(Os,{label:"First Name",value:this.props.contact.FirstName}),t(Os,{label:"Middle Name",value:this.props.contact.MiddleName}),t(Os,{label:"Last Name",value:this.props.contact.LastName}),t(Os,{label:"E-mail",value:this.props.contact.Email}),t(Os,{label:"Customer Group",value:this.props.contact.CustomerGroup?this.props.contact.CustomerGroup:"None"}))))},r}(n),Ts=z((function(e){var t=e.palette;e.spacing,e.breakpoints;return c({root:{marginBottom:mn.marginDefault},header:Bt(Bt({},gn),{height:48,background:t.primary.main}),title:{color:t.common.white},action:{display:"block",marginTop:"8px"},icon:{fill:t.common.white}})}))(u((function(e,t){return{contactId:t.contactId,contact:e.contact.currentContact,isReadonly:t.isReadonly,classes:t.classes}}))(ws)),Ds=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Vt(r,e),r.prototype.render=function(){return t(Ts,Bt({},this.props))},r}(n),Ps=function(e){function r(t){var r=e.call(this,t)||this;r.state={discardDialogOpen:!1},r.classes=r.props.classes,r.addressListLink="/customers/"+r.props.currentContactId+"/addresses",r.personalInfoLink="/customers/"+r.props.currentContactId+"/info",r.PeronalInfoEditLink="/customers/"+r.props.currentContactId+"/edit",r.addressSearchQuery="",r.customerInfoLink="/customers/"+r.props.currentContactId+"/info",r.customerAddressLink="/customers/"+r.props.currentContactId+"/addresses",r.customerOrderLink="/customers/"+r.props.currentContactId+"/orders",r.unListenHistory=as.listen((function(e,t){r.forceUpdate()}));var n=new URLSearchParams(r.props.location.search);return null!==n.get("orderType")&&null!==n.get("orderId")&&(r.addressSearchQuery="?orderType="+n.get("orderType")+"&orderId="+n.get("orderId")),r}return Vt(r,e),r.prototype.componentWillUnmount=function(){this.unListenHistory()},r.prototype.discardChanges=function(){return Wt(this,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:this.props.dispatch(fr.ApplicationActions.setCurrentDialog(zt.None)),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,ln.Contact.get(this.props.currentContactId)];case 2:return e=r.sent(),this.props.dispatch(fr.ContactActions.setCurrentContact(e)),this.props.dispatch(fr.AddressFormActions.clearAddressForm()),this.props.drawerNextMenu!==Zt.None?this.displayMainContent(this.props.drawerNextMenu):this.props.dispatch(fr.ContactActions.setDrawerSelectedMenu(Zt.None)),[3,4];case 3:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,4];case 4:return[2]}}))}))},r.prototype.displayMainContent=function(e){e===Zt.PersonalInformation?this.props.dispatch(fr.ContactActions.showContactProfile()):e===Zt.AddressBook&&this.props.dispatch(fr.ContactActions.showAddressBook())},r.prototype.closeProfileOverview=function(){this.leavePage()},r.prototype.leavePage=function(){this.props.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!1));var e=ds(Dr);void 0!==e?as.push(e):as.push("/")},r.prototype.getMenuListItem=function(){var e=this;return t(w,null,t(Fe,{to:this.personalInfoLink,className:this.classes.menuItem+" "+(as.location.pathname===this.personalInfoLink||as.location.pathname===this.PeronalInfoEditLink?this.classes.menuItemActive:""),replace:!0},t(I,{button:!0,key:"Personal Information"},t(T,{classes:{primary:this.classes.primary},primary:"Personal Information"}))),t(Fe,{to:this.addressListLink+this.addressSearchQuery,className:this.classes.menuItem+" "+(as.location.pathname===this.addressListLink?this.classes.menuItemActive:""),replace:!0},t(I,{button:!0,key:"Address Book"},t(T,{classes:{primary:this.classes.primary},primary:"Address Book"}))),t(Fe,{to:this.customerOrderLink,className:this.classes.menuItem+" "+(as.location.pathname===this.customerOrderLink?this.classes.menuItemActive:""),replace:!0},t(I,{button:!0,key:"Orders"},t(T,{classes:{primary:this.classes.primary},primary:"Orders"}))),this.props.extraPages&&this.props.extraPages.map((function(r,n){var s="/customers/"+e.props.currentContactId+"/"+r.getLink({CustomerId:e.props.currentContactId});return t(Fe,{key:n,to:s,className:e.classes.menuItem+" "+(as.location.pathname===s?e.classes.menuItemActive:""),replace:!0},t(I,null,t(T,{classes:{primary:e.classes.primary},primary:r.title})))})))},r.prototype.render=function(){var e,r=this;return t(Nn,{title:"Contact Details",showDialogActions:this.props.showDialogActions,closeView:function(){return r.closeProfileOverview()}},t(Ke,{smUp:!0,implementation:"js"},t(D,{className:this.classes.drawer,variant:"temporary",classes:{paper:this.classes.drawerPaper},open:this.props.drawerIsExpanded,anchor:"right",onClose:function(){return r.props.dispatch(fr.ContactActions.setDrawerIsExpanded(!1))}},t("div",{className:this.classes.toolbar}),this.getMenuListItem())),t(Ke,{xsDown:!0,implementation:"js"},t(D,{className:this.classes.drawer,variant:"permanent",classes:{paper:this.classes.drawerPaper},open:!0,anchor:"left"},t("div",{className:this.classes.toolbar}),this.getMenuListItem())),t("main",{className:this.classes.content},t("div",{className:this.classes.childContent},t(ke,{location:as.location},t(_e,{exact:!0,path:Pr,render:function(e){return t(Ds,{contactId:e.match.params.id})}}),t(_e,{exact:!0,path:Gr,render:function(e){return t(ys,{contactId:e.match.params.id})}}),t(_e,{path:Nr,render:function(e){return t(Pn,Bt({contactId:e.match.params.id},e))}}),t(_e,{exact:!0,path:Rr,render:function(e){return t(bs,{customerId:e.match.params.id})}}),this.props.extraPages&&(null===(e=this.props.extraPages)||void 0===e?void 0:e.map((function(e){return t(_e,{path:"/customers/"+r.props.currentContactId+e.path,exact:e.exact,render:function(t){return e.render({CustomerId:r.props.currentContactId})}})})))),this.props.discardChangesDialogIsVisible&&t(Rn,{discardChanges:this.discardChanges}))),this.state.discardDialogOpen&&t(Sn,{title:"Leave page?",closeButtonLabel:"Cancel",confirmButtonLabel:"Leave",onConfirm:function(){return r.leavePage()},onClose:function(){return r.setState({discardDialogOpen:!1})}},t(m,{variant:"body1"},"You have unsaved changes. Do you want to leave the page without saving?")))},r}(n),Gs=z((function(e){var t,r,n=e.palette,s=e.spacing,i=e.zIndex,o=e.mixins,a=e.breakpoints;return c({root:{display:"flex"},appBar:{zIndex:i.drawer+1},drawer:{width:240,flexShrink:0},drawerPaper:{width:240,background:fn.light},content:(t={flexGrow:1,padding:3*s.unit},t[a.down("xs")]={padding:0},t),childContent:(r={marginLeft:240},r[a.down("xs")]={marginLeft:0},r),toolbar:o.toolbar,menuItem:{display:"block",borderLeftWidth:5,borderLeftStyle:"solid",borderLeftColor:fn.light,textDecoration:"none"},menuItemActive:{backgroundColor:n.common.white,borderLeftColor:n.primary.main},selected:{},primary:{}})}))(u((function(e,t){var r,n,s=e.setting.pageConfig.contactDetail;return Bt({isCurrentFormDirty:e.application.isCurrentFormDirty,showDialogActions:!e.contact.personalInformationEditViewIsVisible&&e.contact.addressDetailsViewMode===Jt.Hide,currentContactId:t.customerId,drawerSelectedMenu:e.contact.drawerSelectedMenu,drawerNextMenu:e.contact.drawerNextMenu,drawerIsExpanded:e.contact.drawerIsExpanded,discardChangesDialogIsVisible:e.application.currentDialog===zt.DiscardChanges,extraPages:null===(n=null===(r=s)||void 0===r?void 0:r.config)||void 0===n?void 0:n.extraPages},t)}))(Ps)),Ns=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Vt(r,e),r.prototype.render=function(){return t(Gs,Bt({},this.props))},r}(n),Rs=function(e){var r=e.amount;return t(We,Bt({variant:"body1",component:"span"},e),r.Amount.toFixed(r.Fractions)+" "+r.Currency)};!function(e){e[e.DateTime=4]="DateTime",e[e.Decimal=5]="Decimal",e[e.Float=6]="Float",e[e.Int=8]="Int",e[e.Money=9]="Money",e[e.Integer=26]="Integer",e[e.Boolean=27]="Boolean",e[e.Date=28]="Date",e[e.Email=29]="Email",e[e.URL=30]="URL",e[e.ShortString=31]="ShortString",e[e.LongString=32]="LongString",e[e.LongHtmlString=33]="LongHtmlString",e[e.DictionarySingleValue=34]="DictionarySingleValue",e[e.DictionaryMultiValue=35]="DictionaryMultiValue",e[e.EnumSingleValue=36]="EnumSingleValue",e[e.EnumMultiValue=37]="EnumMultiValue",e[e.StringDictionary=38]="StringDictionary",e[e.File=39]="File",e[e.ImageFile=40]="ImageFile"}(As||(As={}));var Es=As;Ee.addValidationRule(Zr.IsURL,Zr.isValidUrl),Ee.addValidationRule(Zr.IsInteger,Zr.isValidInteger),Ee.addValidationRule(Zr.IsMoney,Zr.isValidMoney);var xs,Ls=function(e){function r(t){var r=e.call(this,t)||this;r.state={value:null===r.props.property.Value?"":r.props.property.Value},r.validators=[],r.errorMessages=[],r.inputRef=s(),r.isMultiLine=!1,r.maxRows=4,r.onChangeHandler=function(e){r.setState({value:e.currentTarget.value})},r.onBlurHandler=function(e){if(!0===r.inputRef.current.isValid()){if(!(r.state.value&&""!==r.state.value||r.props.property.Value&&""!==r.props.property.Value))return;if(r.state.value!==r.props.property.Value){var t=Object.assign({},r.props.property);t.Value=r.state.value,r.props.onPropertyChanged(t)}}};var n=r.props.property.DataType;if(r.props.property.AllowNulls||r.addValidation(Zr.Required),n===Es.Integer||n===Es.Int)r.addValidation(Zr.IsInteger);else if(n===Es.Float)r.addValidation(Zr.IsFloatRegex);else if(n===Es.Decimal){var i=parseInt(r.props.property.Attributes.mdpprecision,10),o=parseInt(r.props.property.Attributes.mdpscale,10),a="Decimal"+i+","+o;Ee.addValidationRule(a,(function(e){var t=new Le(e);return""===e||!(t.isNaN()||t.decimalPlaces()>o||t.precision()>i)})),r.validators.push(a),r.errorMessages.push("Value is not valid decimal("+i+","+o+")")}else n===Es.Money?r.addValidation(Zr.IsMoney):n===Es.Email?r.addValidation(Zr.IsEmail):n===Es.URL?r.addValidation(Zr.IsURL):[Es.LongHtmlString,Es.LongString].indexOf(n)>=0&&(r.isMultiLine=!0);return r}return Vt(r,e),r.prototype.shouldComponentUpdate=function(e,t){return e.property.Value!==this.props.property.Value&&e.property.Value!==t.value&&(t.value=null===e.property.Value?"":e.property.Value),!0},r.prototype.addValidation=function(e){this.validators.push(e),this.errorMessages.push(Zr.getValidationMessage(e))},r.prototype.render=function(){return t(xe,{ref:this.inputRef,multiline:this.isMultiLine,rowsMax:this.maxRows,className:this.isMultiLine?"textarea-input-control":"",variant:"outlined",fullWidth:!0,name:this.props.property.Name,label:this.props.property.FriendlyName+(!0===this.props.property.AllowNulls?"":" *"),value:this.state.value,onChange:this.onChangeHandler,onBlur:this.onBlurHandler,validators:this.validators,errorMessages:this.errorMessages,withRequiredValidator:!0,disabled:this.props.isReadonly})},r}(n),Ms=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={value:null===t.props.property.Value?null:ot(t.props.property.Value)},t.onChangeHandler=function(e){var r=null!==t.props.property.Value?ot(t.props.property.Value).toISOString():null,n=e?e.toISOString():null;if(t.props.property.DataType===Es.Date&&(r&&(r=ot(r).startOf("day").toISOString()),n&&(n=ot(n).startOf("day").toISOString())),n!==r){var s=Bt({},t.props.property);s.Value=n,t.props.onPropertyChanged(s)}t.setState({value:e})},t}return Vt(r,e),r.prototype.shouldComponentUpdate=function(e,t){return e.property.Value!==this.props.property.Value&&e.property.Value!==t.value&&(t.value=null===e.property.Value?null:ot(e.property.Value)),!0},r.prototype.render=function(){var e=this;return t("div",null,t("div",{className:"picker"},this.props.property.DataType===Es.Date&&t(H,{fullWidth:!0,variant:"outlined",keyboard:!1,clearable:this.props.property.AllowNulls&&null!==this.state.value,label:this.props.property.FriendlyName,format:"DD MMM YYYY",required:!this.props.property.AllowNulls,disableOpenOnEnter:!0,animateYearScrolling:!0,disabled:this.props.isReadonly,value:this.state.value,onChange:function(t){return e.onChangeHandler(t)}}),this.props.property.DataType===Es.DateTime&&t(W,{fullWidth:!0,variant:"outlined",keyboard:!1,clearable:this.props.property.AllowNulls&&null!==this.state.value,label:this.props.property.FriendlyName,format:"DD MMM YYYY hh:mm",required:!this.props.property.AllowNulls,disableOpenOnEnter:!0,animateYearScrolling:!0,disabled:this.props.isReadonly,value:this.state.value,onChange:function(t){return e.onChangeHandler(t)}})))},r}(n),Fs=function(e){return t("tr",{className:"mdc-data-table__row"+(e.isRowSelected?" mdc-data-table__row--selected":"")},e.selectableRows&&t("td",{className:"mdc-data-table__cell mdc-data-table__cell--checkbox"},t(ue,{checked:e.isRowSelected,onChange:function(t){e.setRowSelected(e.rowIndex,!e.isRowSelected)}})),e.columns.map((function(r,n){if(r.hidden)return null;var s=r.selector?e.rowData[r.selector]:"";return r.render&&(s=r.render(e.rowData,e.rowIndex)),t("td",{className:"mdc-data-table__cell"+(r.hide?" hide-"+r.hide:"")+(r.right?" align-right":""),key:n,onClick:function(){e.onRowClicked()},onDoubleClick:function(){e.onRowDoubleClicked()}},t("div",{style:{whiteSpace:"pre-wrap"}},s))})))},ks=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Vt(r,e),r.prototype.render=function(){var e=this;return t("tr",{className:"mdc-data-table__header-row"},this.props.selectableRows&&t("th",{className:"mdc-data-table__header-cell mdc-data-table__header-cell--checkbox",role:"columnheader",scope:"col",style:{width:"60px"}},t(ue,{checked:this.props.isSelectedAll,indeterminate:this.props.indeterminate,onChange:function(t){e.props.setHeaderRowChecked(!e.props.isSelectedAll)}})),this.props.columns.map((function(e,r){if(e.hidden)return null;var n={};return e.width&&(n.width=e.width+"px"),e.minWidth&&(n.minWidth=e.minWidth+"px"),e.maxWidth&&(n.maxWidth=e.maxWidth+"px"),t("th",{className:"mdc-data-table__header-cell epi-table__header-cell"+(e.hide?" hide-"+e.hide:"")+(e.right?" align-right":""),role:"columnheader",scope:"col",key:r,style:n},t("div",{className:"epi-table__header-title"},t("span",{className:"header-title"},e.name)))})))},r}(n),_s=function(){return t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},t("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),t("path",{d:"M0 0h24v24H0z",fill:"none"}))},Vs=function(e){return t("div",{className:"epi-table__toolbar"},t("div",null,e.contextActions&&e.selectedCount>0?t("div",{className:"action-buttons"},e.contextActions.map((function(e,r){return t(se,{outlined:!0,key:r,onClick:function(){e.clickHandler&&e.clickHandler()}},e.title)}))):t("div",null,e.buttons&&e.buttons.map((function(e,r){return t(se,{key:r,outlined:!0,onClick:function(){e.clickHandler()}},e.title)})))),e.searchInput&&t("div",null,t("div",{className:"search-input"},t("div",{className:"search-icon"},t(_s,null)),t(P,{placeholder:e.searchInput.placeholder}))))},Us=function(e){function r(t){var r=e.call(this,t)||this;return r.foundation=new mt,r.rowElements=[],r.isSelectedAll=!1,r.isSelectedRows=new Array,r.selectedCount=0,r.tableInstance={getSelectedRows:function(){var e=new Array;return r.isSelectedRows.forEach((function(t,n){!0===t&&r.data[n]&&e.push(r.data[n])})),e},setRowSelected:function(e,t){r.isSelectedRows[e]!==t&&(!0===t?(r.selectedCount++,r.selectedCount===r.data.length&&(r.isSelectedAll=!0)):(r.selectedCount--,!0===r.isSelectedAll&&(r.isSelectedAll=!1))),r.isSelectedRows[e]=t,r.props.selectableRowsPreSelectedField&&(r.data[e][r.props.selectableRowsPreSelectedField]=t),r.props.onRowSelected&&r.props.onRowSelected(e,t),r.forceUpdate()},setHeaderRowChecked:function(e){r.isSelectedAll=e;for(var t=0;t0&&!this.isSelectedAll,setHeaderRowChecked:function(t){return e.tableInstance.setHeaderRowChecked(t)}})),t("tbody",{className:"mdc-data-table__content"},this.data.map((function(r,n){return t(Fs,{key:n,rowData:r,rowIndex:n,columns:e.props.columns,isRowSelected:!!e.isSelectedRows[n],selectableRows:e.props.selectableRows,setRowSelected:function(t,r){return e.tableInstance.setRowSelected(t,r)},onRowClicked:function(){e.props.onRowClicked&&e.props.onRowClicked(r,n)},onRowDoubleClicked:function(){e.props.onRowDoubleClicked&&e.props.onRowDoubleClicked(r,n)}})}))))))},r}(n),Bs=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.state={editingRowIndex:-1,currentEditingRowValue:""},n.onValueCellChange=function(e){n.setState({currentEditingRowValue:e.currentTarget.value})},n.renderValueCell=function(e,r){return e?t(xe,{name:"valueInput",variant:"outlined",defaultValue:r,value:n.state.currentEditingRowValue,onChange:n.onValueCellChange,validators:[Zr.Required],errorMessages:[Zr.getValidationMessage(Zr.Required)],withRequiredValidator:!0}):r},n.renderActionsCell=function(e,s,i,o){return e?t(r,null,t(at,{title:"Save"},t(ut,{onClick:function(){return n.saveItem(i)}},t(pt,null))),t(at,{title:"Cancel"},t(ut,{onClick:n.cancelEditing},t(lt,null)))):-1===n.state.editingRowIndex&&t(r,null,t(at,{title:"Edit item"},t(ut,{onClick:function(){return n.editRow(s,o)}},t(dt,null))),t(at,{title:"Delete item"},t(ut,{onClick:function(){return n.deleteRow(i)}},t(ct,null))))},n.saveItem=function(e){if(n.state.currentEditingRowValue){var t=Object.assign({},n.props.itemsObject);t[e]=n.state.currentEditingRowValue,n.props.onItemsUpdated(t),n.cancelEditing()}},n.cancelEditing=function(){n.setState({editingRowIndex:-1})},n.editRow=function(e,t){n.setState({editingRowIndex:e,currentEditingRowValue:t})},n.deleteRow=function(e){var t=Object.assign({},n.props.itemsObject);delete t[e],n.props.onItemsUpdated(t)},n}return Vt(n,e),n.prototype.render=function(){var e=this,r=Object.keys(this.props.itemsObject),n=[{name:"Key",width:300,render:function(e){return e.key}},{name:"Value",render:function(t,r){var n=e.state.editingRowIndex===r;return e.renderValueCell(n,e.props.itemsObject[t.key])}}];this.props.isReadonly||n.push({name:"Options",width:150,right:!0,render:function(t,r){var n=e.state.editingRowIndex===r;return e.renderActionsCell(n,r,t.key,t.value)}});var s=r.map((function(t){return{key:t,value:e.props.itemsObject[t]}}));return t(Us,{data:s,columns:n})},n}(n),Hs=function(e){function r(t){var r=e.call(this,t)||this;return r.validators=[],r.errorMessages=[],r.state={isDetailsDialogOpen:!1,itemsObject:Object.assign({},r.props.property.Value),inputKey:"",inputValue:"",loaded:!1},r.openDetailsDialog=function(){r.setState({isDetailsDialogOpen:!0}),setTimeout((function(){r.setState({loaded:!0})}),100)},r.closeDetailsDialog=function(){r.setState({isDetailsDialogOpen:!1})},r.updateItemsObject=function(e){r.setState({itemsObject:e})},r.addItem=function(e){var t=r.state.inputKey.toLowerCase().trim(),n=r.state.inputValue;if(!r.state.itemsObject[t]){var s=Object.assign({},r.state.itemsObject);s[t]=n,r.setState({itemsObject:s})}},r.onInputKeyChange=function(e){r.setState({inputKey:e.currentTarget.value})},r.onInputValueChange=function(e){r.setState({inputValue:e.currentTarget.value})},r.saveProperty=function(){var e=Object.assign({},r.props.property);e.Value=r.state.itemsObject,r.props.onPropertyChanged(e),r.closeDetailsDialog()},r.handleClosingDetailsDialog=function(){var e=Object.assign({},r.props.property.Value);r.setState({itemsObject:e}),r.closeDetailsDialog()},r.validators.push(Zr.Required),r.errorMessages.push(Zr.getValidationMessage(Zr.Required)),r}return Vt(r,e),r.prototype.shouldComponentUpdate=function(e,t){return e.property.Value!==this.props.property.Value&&e.property.Value!==t.itemsObject&&(t.itemsObject=Object.assign({},e.property.Value),t.inputKey="",t.inputValue=""),!0},r.prototype.render=function(){var e=this.props.isReadonly;return t("div",null,t(m,null,this.props.property.FriendlyName,this.props.property.AllowNulls?"":" *"),t(se,{outlined:!0,onClick:this.openDetailsDialog},"View Details"),t(Cn,{title:"Dictionary Items",open:this.state.isDetailsDialogOpen,okLabel:"Save",onOK:this.saveProperty,closeLabel:"Close",onClose:this.handleClosingDetailsDialog,large:!0},t(l,{container:!0,spacing:16},!e&&t(l,{item:!0,xs:12},this.state.loaded&&t(Ee,{onSubmit:this.addItem},t(l,{container:!0,spacing:24,alignItems:"center"},t(l,{item:!0,xs:12,sm:4},t(xe,{fullWidth:!0,variant:"outlined",label:"Key",name:"inputKey",value:this.state.inputKey,onChange:this.onInputKeyChange,validators:this.validators,errorMessages:this.errorMessages,withRequiredValidator:!0})),t(l,{item:!0,xs:12,sm:4},t(xe,{fullWidth:!0,variant:"outlined",label:"Value",name:"inputValue",value:this.state.inputValue,onChange:this.onInputValueChange,validators:this.validators,errorMessages:this.errorMessages,withRequiredValidator:!0})),t(l,{item:!0,xs:12,sm:4},t(se,{unelevated:!0,type:"submit"},"Add item"))))),t(l,{item:!0,xs:12},t(Bs,{isReadonly:e,itemsObject:this.state.itemsObject,onItemsUpdated:this.updateItemsObject})))))},r}(n),Ws=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={selectedIds:t.props.property.Value||[]},t.handleChange=function(e){return Wt(t,void 0,void 0,(function(){return qt(this,(function(t){return this.props.property.DataType===Es.DictionaryMultiValue||this.props.property.DataType===Es.EnumMultiValue?this.setState({selectedIds:e.target.value}):this.setState({selectedIds:[e.target.value]}),[2]}))}))},t.isSelectedItemsChanged=function(e,t){var r=!1;if(e.length!==t.length)r=!0;else for(var n=0,s=e;n=0?t(Ls,Bt({},r)):[Es.Date,Es.DateTime].indexOf(e.DataType)>=0?t(Ms,Bt({},r)):e.DataType===Es.DictionaryMultiValue||e.DataType===Es.EnumMultiValue||e.DataType===Es.DictionarySingleValue||e.DataType===Es.EnumSingleValue?t(Ws,Bt({},r)):e.DataType===Es.Boolean?t(qs,Bt({},r)):e.DataType===Es.StringDictionary?t(Hs,Bt({},r)):t(l,null,t(m,null,e.FriendlyName),t(m,null,e.Value))},n}return Vt(r,e),r.prototype.render=function(){return this.renderInput(this.props.property)},r}(n),Ys=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isExpanded:!t.props.isCollapsible,hasShowAll:!0,propertiesBody:s()},t.togglePanelHandler=function(e){return Wt(t,void 0,void 0,(function(){return qt(this,(function(e){return this.setState({isExpanded:!this.state.isExpanded}),[2]}))}))},t}return Vt(r,e),r.prototype.updateLayout=function(){this.state.propertiesBody.current&&(this.state.propertiesBody.current.clientHeight<140?this.setState({hasShowAll:!1}):this.setState({hasShowAll:!0}))},r.prototype.componentDidMount=function(){this.updateLayout(),window.addEventListener("resize",this.updateLayout.bind(this))},r.prototype.render=function(){var e=this;return t(Ee,{instantValidate:!0,onSubmit:function(){return null}},t(b,null,t(E,{in:this.state.isExpanded,collapsedHeight:"180px"},t("div",{ref:this.state.propertiesBody},t(O,null,t(l,{container:!0,className:this.props.classes.expandableContainer},this.props.properties.map((function(r){return t(l,{key:r.Id,item:!0,xs:12,sm:6,lg:4,className:e.props.classes.expandableItem},t(js,{property:r,isReadonly:e.props.isReadonly||!r.IsEditable,onPropertyChanged:e.props.onPropertyChanged}))})))))),this.props.isCollapsible&&this.state.hasShowAll&&t(x,null,t(se,{outlined:!0,className:this.props.classes.toggleButton,onClick:this.togglePanelHandler},"Show ",this.state.isExpanded?"Less":"All"))))},r}(n),zs=p((function(e){e.palette,e.spacing,e.breakpoints;return c({expandableContainer:{overflowY:"hidden",paddingTop:"8px"},expandableItem:{marginBottom:10,padding:"0 20px 20px 0px"},toggleButton:{margin:"0 auto",width:"100%",maxWidth:"250px"}})}))(u((function(e,t){return{isReadonly:void 0!==t.isReadonly&&t.isReadonly,isCollapsible:void 0===t.isCollapsible||t.isCollapsible,properties:t.properties,onPropertyChanged:t.onPropertyChanged,classes:t.classes}}))(Ys)),Qs=function(e){return e?e.replace(/([A-Z])/g," $1").trim():""},Ks=0,Xs=z((function(e){return c({root:{flexGrow:1},selectContainer:{display:"inline"},currency:{height:30}})}))(u((function(e,t){return{currencies:e.orderGroup.currencies,selectedCurrency:e.orderGroup.currentOrderGroup.Currency,classes:t.classes,updateInputValue:t.updateInputValue}}))((function(e){var n=e.currencies.map((function(e){return{label:e.Code,value:e.Code}}));return e.currencies.length>0?t(Jr,{label:"Currency","refresh-counter":Ks++,value:e.selectedCurrency,options:n,onChange:function(t){e.updateInputValue(t)}}):t(r,null)}))),Js=u((function(e,t){var r=e.orderGroup.currentOrderGroup;return{orderGroupType:r.Type,orderGroupId:r.OrderGroupId,newOrderCurrency:t.newOrderCurrency,close:t.onClose}}))((function(e){return t(Sn,{title:"Update Currency",closeButtonLabel:"Cancel",confirmButtonLabel:"Update",onConfirm:function(){return Wt(void 0,void 0,void 0,(function(){var t,r,n,s;return qt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),t=e.orderGroupId,r=e.orderGroupType,[4,ln.OrderGroup.updateCurrencyForOrder(r,t,e.newOrderCurrency)];case 1:return 200!==i.sent().status?[3,3]:[4,ln.OrderGroup.getSingleOrderGroup(r,t)];case 2:n=i.sent(),e.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(n)),n.ValidationMessages.length>0&&e.dispatch(fr.ApplicationActions.showNotification(n.ValidationMessages)),i.label=3;case 3:return[3,5];case 4:return s=i.sent(),e.dispatch(fr.ApplicationActions.showNotification(s.message)),[3,5];case 5:return e.close(!0),[2]}}))}))},onClose:function(){return e.close(!1)}},t(m,{variant:"body1"},t("div",null,t("b",null,"Are you sure you want to change the currency?")),"Changing currency could affect shipping and payment methods, prices or searched items."))})),Zs=u((function(e,t){return{orderGroupId:e.orderGroup.currentOrderGroup.OrderGroupId,newOrderMarket:t.newOrderMarket,close:t.onClose}}))((function(e){return t(Sn,{title:"Update Market",closeButtonLabel:"Cancel",confirmButtonLabel:"Update",onConfirm:function(){return Wt(void 0,void 0,void 0,(function(){var t,r,n;return qt(this,(function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),[4,ln.Cart.updateMarketForCart(e.orderGroupId,e.newOrderMarket)];case 1:return 200!==s.sent().status?[3,4]:[4,ln.OrderGroup.getSingleOrderGroup("Cart",e.orderGroupId)];case 2:return t=s.sent(),e.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(t)),t.ValidationMessages.length>0&&e.dispatch(fr.ApplicationActions.showNotification(t.ValidationMessages)),[4,ln.Currency.getCurrencies(e.newOrderMarket)];case 3:r=s.sent(),e.dispatch(fr.OrderGroupActions.setCurrencies(r)),s.label=4;case 4:return[3,6];case 5:return n=s.sent(),e.dispatch(fr.ApplicationActions.showNotification(n.message)),[3,6];case 6:return e.close(!0),[2]}}))}))},onClose:function(){return e.close(!1)}},t(m,{variant:"body1"},t("div",null,t("b",null,"Are you sure you want to change the market?")),"Changing market could affect shipping and payment methods, prices and items that can be added to the cart."))})),$s=z((function(e){return c({})}))(u((function(e,t){return{markets:e.market.markets,selectedMarket:t.selectedMarket,classes:t.classes,updateInputValue:t.updateInputValue}}))((function(e){var r=e.markets,n=e.selectedMarket,s=r.map((function(e){return{label:e.Name,value:e.Id}}));return t(Jr,{label:"Choose Market",fullWidth:!0,options:s,value:n,onChange:function(t){return e.updateInputValue(t)}})}))),ei=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={selectedCurrency:"",isUpdateCurrencyDialogOpen:!1,selectedMarket:"",isUpdateMarketDialogOpen:!1},t.customerEditLink="/customers/"+t.props.orderGroup.Customer.Id+"/info?orderType="+t.props.orderGroup.Type+"&orderId="+t.props.orderGroup.OrderGroupId,t.customPropertyChangedHandler=function(e){return Wt(t,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,ln.MetaField.updateOrderGroupMetaFields(this.props.orderGroup.OrderGroupId,this.props.orderGroup.Type,e)];case 1:return n.sent(),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 2:return t=n.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(t)),[3,4];case 3:return r=n.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(r.message)),[3,4];case 4:return[2]}}))}))},t.updateMarketForCart=function(e){return Wt(t,void 0,void 0,(function(){return qt(this,(function(t){return e===this.props.orderGroup.MarketId||this.setState({selectedMarket:e,isUpdateMarketDialogOpen:!0}),[2]}))}))},t.updateCurrencyForOrder=function(e){return Wt(t,void 0,void 0,(function(){return qt(this,(function(t){return e===this.props.orderGroup.Currency||this.setState({selectedCurrency:e,isUpdateCurrencyDialogOpen:!0}),[2]}))}))},t.closeOrderMarketUpdateDialogHandler=function(e){t.setState({isUpdateMarketDialogOpen:!1}),e||t.setState({selectedMarket:t.props.orderGroup.MarketId})},t.closeOrderCurrencyUpdateDialogHandler=function(e){t.setState({isUpdateCurrencyDialogOpen:!1}),e||t.setState({selectedCurrency:t.props.orderGroup.Currency})},t}return Vt(r,e),r.prototype.render=function(){return t($,{container:!0,direction:"column",spacing:16},!this.props.createMode&&t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Order Number"),t(m,{className:this.props.classes.itemData},this.props.orderGroup.OrderNumber?this.props.orderGroup.OrderNumber:this.props.orderGroup.OrderGroupId)),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Created Date"),t(m,{className:this.props.classes.itemData},ot(this.props.orderGroup.Created).format("LLL"))),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Status"),t(m,{className:this.props.classes.itemData},Qs(this.props.orderGroup.OrderStatus))),t($,{item:!0},t(L,null)),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Items"),t(Rs,{amount:this.props.orderGroup.ItemsTotal,className:this.props.classes.itemData})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Line Item Discounts"),t(Rs,{amount:this.props.orderGroup.LineItemDiscounts,className:this.props.classes.itemData})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Order Level Discounts"),t(Rs,{amount:this.props.orderGroup.OrderLevelDiscounts,className:this.props.classes.itemData})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Discount Total"),t(Rs,{amount:this.props.orderGroup.DiscountsTotal,className:this.props.classes.itemData})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Taxes Total"),t(Rs,{amount:this.props.orderGroup.TaxTotal,className:this.props.classes.itemData})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},this.props.orderGroup.PricesIncludeTax?"Total excluding shipping (includes tax)":"Total excluding shipping and tax"),t(Rs,{amount:this.props.orderGroup.TotalExcludingShippingAndTax,className:this.props.classes.itemData})),t($,{item:!0},t(L,null)),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Shipping Cost"),t(Rs,{amount:this.props.orderGroup.ShippingTotal,className:this.props.classes.itemData})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Shipping Discounts"),t(Rs,{amount:this.props.orderGroup.ShippingDiscount,className:this.props.classes.itemData})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Handling Total"),t(Rs,{amount:this.props.orderGroup.HandlingTotal,className:this.props.classes.itemData})),t($,{item:!0},t(L,null)),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Order Total"),t(Rs,{amount:this.props.orderGroup.Total,className:this.props.classes.itemData})),t($,{item:!0},t(L,null)),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Market"),!0===this.props.createMode&&"PaymentPlan"===this.props.orderGroup.Type?t("span",{className:this.props.classes.itemData},t($s,{selectedMarket:this.props.orderGroup.MarketId,updateInputValue:this.updateMarketForCart})):t(m,{className:this.props.classes.itemData},this.props.orderGroup.MarketName),this.state.isUpdateMarketDialogOpen&&t(Zs,{newOrderMarket:this.state.selectedMarket,onClose:this.closeOrderMarketUpdateDialogHandler})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel},"Currency"),this.props.isReadonly?t(m,{className:this.props.classes.itemData},this.props.orderGroup.Currency):t("span",{className:this.props.classes.itemData},t(Xs,{updateInputValue:this.updateCurrencyForOrder})),this.state.isUpdateCurrencyDialogOpen&&t(Js,{newOrderCurrency:this.state.selectedCurrency,onClose:this.closeOrderCurrencyUpdateDialogHandler})),!this.props.createMode&&this.props.orderGroup.Properties&&this.props.orderGroup.Properties.length>0&&t($,{item:!0},t(m,{variant:"subtitle1"},"Custom Properties"),t(zs,{properties:this.props.orderGroup.Properties,onPropertyChanged:this.customPropertyChangedHandler,isReadonly:this.props.isReadonly,isCollapsible:!1})))},r}(n),ti=p((function(){return c({itemLabel:{width:"200px",display:"inline-block",fontSize:14},itemData:{display:"inline-block",fontSize:14}})}))(u()(ei)),ri=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isUpdateMarketDialogOpen:!1,isUpdateCurrencyDialogOpen:!1,selectedMarket:"",selectedCurrency:""},t.updateMarketForCart=function(e){return Wt(t,void 0,void 0,(function(){return qt(this,(function(t){return e===this.props.orderGroup.MarketId||this.setState({selectedMarket:e,isUpdateMarketDialogOpen:!0}),[2]}))}))},t.updateCurrencyForOrder=function(e){return Wt(t,void 0,void 0,(function(){return qt(this,(function(t){return e===this.props.orderGroup.Currency||this.setState({selectedCurrency:e,isUpdateCurrencyDialogOpen:!0}),[2]}))}))},t.closeOrderMarketUpdateDialogHandler=function(e){t.setState({isUpdateMarketDialogOpen:!1}),e||t.setState({selectedMarket:t.props.orderGroup.MarketId})},t.closeOrderCurrencyUpdateDialogHandler=function(e){t.setState({isUpdateCurrencyDialogOpen:!1}),e||t.setState({selectedCurrency:t.props.orderGroup.Currency})},t}return Vt(r,e),r.prototype.render=function(){return t($,{container:!0,direction:"column",spacing:16},t($,{item:!0},t(m,{className:this.props.classes.itemLabel,variant:"caption"},"Cart Number"),t(m,{className:this.props.classes.itemData,variant:"caption"},this.props.orderGroup.OrderGroupId)),t($,{item:!0},t(m,{className:this.props.classes.itemLabel,variant:"caption"},"Created Date"),t(m,{className:this.props.classes.itemData,variant:"caption"},ot(this.props.orderGroup.Created).format("LLL"))),t($,{item:!0},t(m,{className:this.props.classes.itemLabel,variant:"caption"},"Order Level Discounts"),t(Rs,{className:this.props.classes.itemData,amount:this.props.orderGroup.OrderLevelDiscounts,align:"left",variant:"caption"})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel,variant:"caption"},"Cart Total"),t(Rs,{className:this.props.classes.itemData,amount:this.props.orderGroup.Total,align:"left",variant:"caption"})),t($,{item:!0},t(L,null)),t($,{item:!0},t(m,{className:this.props.classes.itemLabel,variant:"caption"},"Market"),t("span",{className:this.props.classes.itemData},t($s,{selectedMarket:this.props.orderGroup.MarketId,updateInputValue:this.updateMarketForCart})),this.state.isUpdateMarketDialogOpen&&t(Zs,{newOrderMarket:this.state.selectedMarket,onClose:this.closeOrderMarketUpdateDialogHandler})),t($,{item:!0},t(m,{className:this.props.classes.itemLabel,variant:"caption"},"Currency"),t("span",{className:this.props.classes.itemData},t(Xs,{updateInputValue:this.updateCurrencyForOrder})),this.state.isUpdateCurrencyDialogOpen&&t(Js,{newOrderCurrency:this.state.selectedCurrency,onClose:this.closeOrderCurrencyUpdateDialogHandler})))},r}(n),ni=p((function(e){e.spacing;return c({itemLabel:{width:"200px",display:"inline-block",fontSize:14},itemData:{display:"inline-block",fontSize:14}})}))(ri),si=function(e){var r="/customers/"+e.orderGroup.Customer.Id+"/info?orderType="+e.orderGroup.Type+"&orderId="+e.orderGroup.OrderGroupId;return t($,{container:!0,direction:"column"},t($,{item:!0},t($,{container:!0,alignItems:"center"},t($,{item:!0},t(m,{variant:"h6"},"Customer Information")),null!=e.orderGroup.Customer.Email&&t($,{item:!0},t(at,{title:"Edit Customer Information"},t(Fe,{to:r,onClick:function(){us(Dr)}},t(ie,null,t(oe,{style:{width:"16px"}}))))))),t($,{item:!0},t(b,null,t(O,null,t($,{container:!0,spacing:24},t($,{item:!0},t(m,{variant:"subtitle1"},"Customer: ",e.orderGroup.Customer.FullName)),t($,{item:!0},t(m,{variant:"subtitle1"},"Email Address: ",e.orderGroup.Customer.Email)))))))};!function(e){e.OnHold="OnHold",e.PartiallyShipped="PartiallyShipped",e.InProgress="InProgress",e.Completed="Completed",e.Cancelled="Cancelled",e.AwaitingExchange="AwaitingExchange"}(xs||(xs={}));var ii,oi=xs,ai=[{label:"None",value:"None"},{label:"Days",value:"Days"},{label:"Weeks",value:"Weeks"},{label:"Months",value:"Months"},{label:"Years",value:"Years"},{label:"Custom1",value:"Custom1"},{label:"Custom2",value:"Custom2"}],ui=Ae().shape({CycleMode:Oe().required(Zr.getValidationMessage(Zr.Required)),CycleLength:we().required(Zr.getValidationMessage(Zr.Required)).integer(Zr.getValidationMessage(Zr.IsInteger)).min(0),MaxCyclesCount:we().required(Zr.getValidationMessage(Zr.Required)).integer(Zr.getValidationMessage(Zr.IsInteger)).min(0),CompletedCyclesCount:we().required(Zr.getValidationMessage(Zr.Required)).integer(Zr.getValidationMessage(Zr.IsInteger)).min(0),StartDate:Te().nullable(),EndDate:Te().nullable().when("StartDate",(function(e,t){return e?t.min(e,"The End Date must greater than or equal to the Start Date."):t})),LastTransactionDate:Te().nullable(),IsActive:De()}),di=function(e){function n(t){var r=e.call(this,t)||this;r.datetimeFormat="MMM DD, YYYY hh:mm A",r.initPaymentPlanSetting=function(){var e={CycleMode:"None",StartDate:null,EndDate:null,LastTransactionDate:null,IsActive:!1};return r.props.createMode?Object.assign(e,r.props.paymentPlanSetting):e={CycleMode:null==r.props.paymentPlan.CycleMode?"None":r.props.paymentPlan.CycleMode,CycleLength:r.props.paymentPlan.CycleLength,MaxCyclesCount:r.props.paymentPlan.MaxCyclesCount,CompletedCyclesCount:r.props.paymentPlan.CompletedCyclesCount,StartDate:r.props.paymentPlan.StartDate,EndDate:r.props.paymentPlan.EndDate,LastTransactionDate:r.props.paymentPlan.LastTransactionDate,IsActive:null!=r.props.paymentPlan.IsActive&&r.props.paymentPlan.IsActive},r.props.dispatch(fr.OrderGroupActions.setPaymentPlanSetting(e)),e},r.isEditable=function(){return r.props.paymentPlan.OrderStatus!==oi.Cancelled&&!r.props.createMode},r.isValid=function(){return r.validatePaymentPlanSetting(r.state.paymentPlanSetting,!0)},r.validatePaymentPlanSetting=function(e,t){var n={};try{return ui.validateSync(e,{abortEarly:!1}),r.setState({errors:n}),!0}catch(s){return s.inner.map((function(r){(!t||null!==e[r.path]&&void 0!==e[r.path])&&(n[r.path]=r.message)})),r.setState({errors:n}),!1}},r.updatePaymentPlanSetting=function(e,t){return Wt(r,void 0,void 0,(function(){var r;return qt(this,(function(n){switch(n.label){case 0:return(r=Bt({},this.state.paymentPlanSetting))[e]=t,[4,this.validatePaymentPlanSetting(r,!0)];case 1:return n.sent(),this.setState({paymentPlanSetting:r}),this.props.dispatch(fr.OrderGroupActions.setPaymentPlanSetting(r)),[2]}}))}))},r.saveChange=function(){return Wt(r,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return this.validatePaymentPlanSetting(this.state.paymentPlanSetting)?[4,ln.PaymentPlan.updatePaymentPlanSetting(this.props.paymentPlan.OrderGroupId,this.state.paymentPlanSetting)]:[3,2];case 1:e.sent(),this.setState({editMode:!1}),e.label=2;case 2:return[2]}}))}))},r.cancelEdit=function(){r.setState({editMode:!1,errors:{},paymentPlanSetting:r.initPaymentPlanSetting()})},r.props.validator&&(r.props.validator.validate=r.isValid);var n=r.initPaymentPlanSetting();return r.state={paymentPlanSetting:n,errors:{},editMode:r.props.editMode},r}return Vt(n,e),n.prototype.render=function(){var e=this;return t(r,null,t($,{container:!0,direction:"column",className:this.props.classes.pageItem,spacing:16},t($,{item:!0,className:this.props.classes.rowData},t(m,{className:this.props.classes.itemLabel},"Last Transaction Date"),t("div",{className:this.props.classes.itemData},t(W,{fullWidth:!0,clearable:!0,variant:"outlined",disabled:!this.state.editMode,format:this.datetimeFormat,value:null==this.state.paymentPlanSetting.LastTransactionDate?null:ot(this.state.paymentPlanSetting.LastTransactionDate),onChange:function(t){return e.updatePaymentPlanSetting("LastTransactionDate",null==t?null:t.toDate())}}),t(m,{variant:"caption"},"The date of last transaction"),t(m,{variant:"caption",color:"error"},this.state.errors.LastTransactionDate))),t($,{item:!0,className:this.props.classes.rowData},t(m,{className:this.props.classes.itemLabel},"Completed Cycles*"),t("div",{className:this.props.classes.itemData},t(h,{fullWidth:!0,variant:"outlined",disabled:!this.state.editMode,required:!0,type:"number",className:this.props.classes.itemData,value:this.state.paymentPlanSetting.CompletedCyclesCount,onChange:function(t){var r=Number(t.target.value);isNaN(r)||e.updatePaymentPlanSetting("CompletedCyclesCount",r)}}),t(m,{variant:"caption"},"Number of completed cycles"),t(m,{variant:"caption",color:"error"},this.state.errors.CompletedCyclesCount))),t($,{item:!0,className:this.props.classes.rowData},t(m,{className:this.props.classes.itemLabel},"Cycle Length*"),t("div",{className:this.props.classes.itemData},t(h,{fullWidth:!0,variant:"outlined",disabled:!this.state.editMode,required:!0,type:"number",value:this.state.paymentPlanSetting.CycleLength,onChange:function(t){var r=Number(t.target.value);isNaN(r)||e.updatePaymentPlanSetting("CycleLength",r)}}),t(m,{variant:"caption"},"Cycle length in units of cycle mode"),t(m,{variant:"caption",color:"error"},this.state.errors.CycleLength))),t($,{item:!0,className:this.props.classes.rowData},t(m,{className:this.props.classes.itemLabel},"Plan Cycle"),t("div",{className:this.props.classes.itemData},t(Jr,{fullWidth:!0,disabled:!this.state.editMode,value:this.state.paymentPlanSetting.CycleMode,options:ai,onChange:function(t){return e.updatePaymentPlanSetting("CycleMode",t)}}),t(m,{variant:"caption"},"Cycles mode is used to define period of recurring payments. Can be day, week, month or custom"))),t($,{item:!0,className:this.props.classes.rowData},t(m,{className:this.props.classes.itemLabel},"Max Cycles*"),t("div",{className:this.props.classes.itemData},t(h,{fullWidth:!0,variant:"outlined",disabled:!this.state.editMode,required:!0,type:"number",value:this.state.paymentPlanSetting.MaxCyclesCount,onChange:function(t){var r=Number(t.target.value);isNaN(r)||e.updatePaymentPlanSetting("MaxCyclesCount",r)}}),t(m,{variant:"caption"},"Number of maximum cycles to process"),t(m,{variant:"caption",color:"error"},this.state.errors.MaxCyclesCount))),t($,{item:!0,className:this.props.classes.rowData},t(m,{className:this.props.classes.itemLabel},"Start Date"),t("div",{className:this.props.classes.itemData},t(W,{clearable:!0,fullWidth:!0,variant:"outlined",format:this.datetimeFormat,disabled:!this.state.editMode,value:null==this.state.paymentPlanSetting.StartDate?null:ot(this.state.paymentPlanSetting.StartDate),onChange:function(t){return e.updatePaymentPlanSetting("StartDate",null==t?null:t.toDate())},className:this.props.classes.itemData}),t(m,{variant:"caption"},"Plan start date"),t(m,{variant:"caption",color:"error"},this.state.errors.StartDate))),t($,{item:!0,className:this.props.classes.rowData},t(m,{className:this.props.classes.itemLabel},"End Date"),t("div",{className:this.props.classes.itemData},t(W,{clearable:!0,fullWidth:!0,variant:"outlined",format:this.datetimeFormat,disabled:!this.state.editMode,value:null==this.state.paymentPlanSetting.EndDate?null:ot(this.state.paymentPlanSetting.EndDate),onChange:function(t){return e.updatePaymentPlanSetting("EndDate",null==t?null:t.toDate())}}),t(m,{variant:"caption"},"Plan end date"),t(m,{variant:"caption",color:"error"},this.state.errors.EndDate))),t($,{item:!0,className:this.props.classes.rowData},t(m,{className:this.props.classes.itemLabel},"Is Active"),t(ue,{disabled:!this.state.editMode,checked:this.state.paymentPlanSetting.IsActive,onChange:function(t){return e.updatePaymentPlanSetting("IsActive",t.target.checked)}}))),this.isEditable()&&t($,{container:!0,spacing:8},!this.state.editMode&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.setState({editMode:!0})}},"Edit")),this.state.editMode&&t($,{item:!0},t(se,{outlined:!0,onClick:this.cancelEdit},"Cancel")),this.state.editMode&&t($,{item:!0},t(se,{outlined:!0,onClick:this.saveChange},"Save"))))},n}(n),ci=p((function(e){var t=e.spacing;return c({pageItem:{padding:1*t.unit},rowData:{width:"100%",cellPadding:1*t.unit,display:"flex",alignItems:"flex-start"},itemLabel:{padding:1*t.unit,width:"200px",display:"inline-block",fontSize:14},itemData:{width:"400px",display:"inline-block",fontSize:14}})}))(u((function(e,t){return{paymentPlan:t.paymentPlan,editMode:t.editMode,createMode:t.createMode,validator:t.validator,paymentPlanSetting:e.orderGroup.paymentPlanSetting,classes:t.classes}}))(di)),pi=z((function(e){e.palette,e.spacing,e.breakpoints;return c({})}))(u((function(e,t){var r=e.orderGroup.currentOrderGroup;return{lineItemDeleteConfirmationIsVisible:e.application.lineItemDeleteConfirmationIsVisible,currentLineItemId:e.orderGroup.currentLineItemId,currentOrderGroupId:r.OrderGroupId,orderGroupType:r.Type,listedOrderGroups:e.orderGroup.listedOrderGroups,classes:t.classes}}))((function(e){var r=function(){e.dispatch(fr.ApplicationActions.closeDeleteLineItemConfirmationView())};return t("div",null,t(te,{open:e.lineItemDeleteConfirmationIsVisible,maxWidth:"sm",fullWidth:!0,onClose:r},t(Ct,null,"Remove line item"),t(ne,null,t(St,null,"This will remove the line item from the cart. This operation cannot be undone."),t(re,null,t(se,{onClick:r},"Cancel"),t(se,{unelevated:!0,onClick:function(){return Wt(void 0,void 0,void 0,(function(){var t,n,s;return qt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,ln.OrderGroup.deleteLineItem(e.orderGroupType,e.currentOrderGroupId,e.currentLineItemId)];case 1:return(t=i.sent())&&t.data&&Array.isArray(t.data)&&t.data.length>0&&e.dispatch(fr.ApplicationActions.showNotification(t.data)),[4,ln.OrderGroup.getSingleOrderGroup(e.orderGroupType,e.currentOrderGroupId)];case 2:return n=i.sent(),e.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(n)),r(),[3,4];case 3:return s=i.sent(),e.dispatch(fr.ApplicationActions.showNotification(s.message)),[3,4];case 4:return[2]}}))}))}},"Remove")))))})));function li(e){return!!e&&(e.OrderStatus===oi.Cancelled||e.OrderStatus===oi.Completed||e.OrderStatus===oi.OnHold)}function hi(e){var t=!1;if(e&&Array.isArray(e.Forms)&&e.Forms.length>0){var r=e.Forms[0];if(Array.isArray(r.Shipments)&&r.Shipments.length>0)for(var n=0;n0){t=!0;break}}return t}function mi(e){if(!(e&&Array.isArray(e.Forms)&&e.Forms.length>0))return!1;var t=e.Forms[0];if(!(Array.isArray(t.Shipments)&&t.Shipments.length>0))return!1;var r=t.Shipments[0];return!!(Array.isArray(r.LineItems)&&r.LineItems.length>0)&&(!!r.ShippingAddress&&!(!r.ShippingMethodId||"00000000-0000-0000-0000-000000000000"===r.ShippingMethodId))}!function(e){e.OrderNumber="OrderNumber",e.CustomerName="CustomerName",e.Email="Email"}(ii||(ii={}));var fi,gi=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={orderDialog:{isOpen:!1,title:"",message:"",closeButtonLabel:"",confirmButtonLabel:"",onConfirm:function(){return null}}},t.goToOriginalOrder=function(){return Wt(t,void 0,void 0,(function(){return qt(this,(function(e){return as.push(Er+"/"+this.props.orderGroup.ParentOrderId),[2]}))}))},t}return Vt(r,e),r.prototype.updateOrderStatus=function(e){return Wt(this,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,ln.OrderGroup.updateOrderStatus(this.props.orderGroup.OrderGroupId,e)];case 1:return n.sent(),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 2:return t=n.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(t)),[3,4];case 3:return r=n.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(r.message)),[3,4];case 4:return this.closeOrderDialog(),[2]}}))}))},r.prototype.closeOrderDialog=function(){this.setState({orderDialog:{isOpen:!1}})},r.prototype.showCancelConfirmDialog=function(){var e=this;this.setState({orderDialog:{isOpen:!0,title:"Cancel Order",message:"Are you sure you want to cancel this order?",closeButtonLabel:"Close",confirmButtonLabel:"Cancel Order",onConfirm:function(){return e.updateOrderStatus(oi.Cancelled)}}})},r.prototype.canShowHoldButton=function(){return this.props.orderGroup.OrderStatus===oi.InProgress||this.props.orderGroup.OrderStatus===oi.PartiallyShipped},r.prototype.canShowCancelButton=function(){return this.props.orderGroup.OrderStatus===oi.InProgress},r.prototype.canShowReleaseHoldButton=function(){return this.props.orderGroup.OrderStatus===oi.OnHold},r.prototype.render=function(){var e=this;return t("div",null,t($,{container:!0,justify:"flex-end",spacing:8},this.props.orderGroup.IsExchangeOrder&&t($,{item:!0},t(se,{outlined:!0,onClick:this.goToOriginalOrder},"Go to original order")),this.canShowHoldButton()&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.updateOrderStatus(oi.OnHold)}},"Hold")),this.canShowReleaseHoldButton()&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.updateOrderStatus(oi.InProgress)}},"Release OnHold")),this.canShowCancelButton()&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.showCancelConfirmDialog()}},"Cancel Order"))),this.state.orderDialog.isOpen&&t(Sn,{title:this.state.orderDialog.title,closeButtonLabel:this.state.orderDialog.closeButtonLabel,confirmButtonLabel:this.state.orderDialog.confirmButtonLabel,onConfirm:this.state.orderDialog.onConfirm,onClose:function(){return e.setState({orderDialog:{isOpen:!1}})}},t(m,{variant:"body1"},this.state.orderDialog.message)))},r}(n),yi=u((function(e){return{orderGroup:e.orderGroup.currentOrderGroup}}))(gi),vi=function(){return t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},t("path",{d:"M0 0h24v24H0z",fill:"none"}),t("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"}))},Ci=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.dropdownMenuAnchor=s(),t.dropdownOpen=!1,t.openActionDropdown=function(){t.dropdownOpen=!0,t.forceUpdate()},t.handleClose=function(){t.dropdownOpen=!1,t.forceUpdate()},t}return Vt(r,e),r.prototype.render=function(){var e=this;return t("div",{className:"action-dropdown__container"},t("div",{className:"action-dropdown__anchor-icon mdc-ripple-surface",onClick:function(t){window.document.getElementsByTagName("body")[0].click(),t.stopPropagation(),e.openActionDropdown()},ref:this.dropdownMenuAnchor,"data-mdc-ripple-is-unbounded":!0},t(vi,null)),t(ce,{anchorElement:this.dropdownMenuAnchor.current,anchorCorner:1,open:this.dropdownOpen,onClose:function(){return e.handleClose()},className:"epi-table-action-dropdown"},t(pe,null,this.props.actions.map((function(r,n){return t(le,{style:{cursor:"pointer"},key:n,onClick:function(t){t.stopPropagation(),e.handleClose(),r.clickHandler&&r.clickHandler(e.props.rowData,e.props.rowIndex)}},r.title)})))))},r}(n);!function(e){e.Complete="Complete",e.Canceled="Canceled",e.AwaitingStockReturn="AwaitingStockReturn",e.AwaitingCompletion="AwaitingCompletion"}(fi||(fi={}));var Si,Ii=fi,bi=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={isLoadingResource:!0,returnForms:[],confirmDialog:{isOpen:!1,title:"",message:"",closeButtonLabel:"",confirmButtonLabel:"",onConfirm:function(){return null}},contextActionItems:Array()},r.tableInstance={},r.columns=[{name:"RETURN NO.",selector:"RMANumber"},{name:"CREATED DATE",selector:"Created",render:function(e){return ot(e.Created).format("LLL")}},{name:"CREATED BY",selector:"Customer",render:function(e){return e.Customer.FullName}},{name:"STATUS",selector:"Status",render:function(e){return e.Status.Name}},{name:"RETURN TOTAL",selector:"Total",right:!0,render:function(e){return t(Rs,{amount:e.Total})}},{name:"",width:10,render:function(e,n){var s=[];return s.push({title:r.isReturnEditable(e)?"Edit":"View",clickHandler:function(t){r.goToDetail(e)}}),e.Status.Code!==Ii.AwaitingStockReturn&&e.Status.Code!==Ii.AwaitingCompletion||s.push({title:"Cancel",clickHandler:function(t){r.showCancelConfirmDialog(e.FormId)}}),e.Status.Code===Ii.AwaitingStockReturn&&s.push({title:"Acknowledge Receipt Items",clickHandler:function(t){r.showAcknowledgeReceiptItemsConfirmDialog(e.FormId)}}),t(Ci,{actions:s,rowData:e,rowIndex:n})}}],r}return Vt(r,e),r.prototype.componentWillMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.loadReturns()];case 1:return e.sent(),[2]}}))}))},r.prototype.loadReturns=function(){return Wt(this,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:this.setState({isLoadingResource:!0}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,ln.OrderGroup.getReturns(this.props.orderGroupId)];case 2:return e=r.sent(),this.setState({returnForms:e.Results}),[3,4];case 3:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,4];case 4:return this.setState({isLoadingResource:!1}),[2]}}))}))},r.prototype.goToDetail=function(e){as.push(Er+"/"+this.props.orderGroupId+"/returns/"+e.FormId)},r.prototype.closeDialog=function(){this.setState({confirmDialog:{isOpen:!1}})},r.prototype.cancelReturn=function(e){return Wt(this,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,ln.OrderGroup.cancelReturn(this.props.orderGroupId,e)];case 1:return r.sent(),[4,this.loadReturns()];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,4];case 4:return this.closeDialog(),[2]}}))}))},r.prototype.showCancelConfirmDialog=function(e){var t=this;this.setState({confirmDialog:{isOpen:!0,title:"Cancel Return",message:"Are you sure you want to cancel this return?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return t.cancelReturn(e)}}})},r.prototype.updateAcknowledgeReceiptItems=function(e){return Wt(this,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,ln.OrderGroup.acknowledgeReceiptItems(this.props.orderGroupId,e)];case 1:return r.sent(),[4,this.loadReturns()];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,4];case 4:return this.closeDialog(),[2]}}))}))},r.prototype.showAcknowledgeReceiptItemsConfirmDialog=function(e){var t=this;this.setState({confirmDialog:{isOpen:!0,title:"Acknowledge Receipt Items",message:"Are you sure you want to acknowledge receipt items?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return t.updateAcknowledgeReceiptItems(e)}}})},r.prototype.isReturnEditable=function(e){return e.Status.Code===Ii.AwaitingStockReturn},r.prototype.showConfirmReturnBatch=function(e){var t=this;this.setState({confirmDialog:{isOpen:!0,title:"Cancel Return(s)",message:"Are you sure you want to cancel return(s)?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return Wt(t,void 0,void 0,(function(){return qt(this,(function(t){switch(t.label){case 0:return[4,this.cancelReturnBatch(e)];case 1:return t.sent(),[2]}}))}))}}})},r.prototype.cancelReturnBatch=function(e){return Wt(this,void 0,void 0,(function(){var t,r,n,s;return qt(this,(function(i){switch(i.label){case 0:i.trys.push([0,6,,7]),t=0,r=e,i.label=1;case 1:return t0&&(r=!1),s.filter((function(e){return e.Status.Code!==Ii.AwaitingStockReturn})).length>0&&(n=!1),r&&t.push({title:"Cancel Return(s)",clickHandler:function(){e.showConfirmReturnBatch(s)}}),n&&t.push({title:"Acknowledge Receipt Items",clickHandler:function(){e.showBatchAcknowledgeReceiptItemsConfirmDialog(s)}}),this.setState({contextActionItems:t})},r.prototype.render=function(){var e=this;return t("div",null,!this.state.isLoadingResource&&t(Us,{columns:this.columns,selectableRows:!0,onRowSelected:function(){return e.onRowSelected()},onHeaderRowSelected:function(){return e.onRowSelected()},contextActions:this.state.contextActionItems,data:this.state.returnForms,toolbar:{},tableInstance:this.tableInstance}),t(Cn,{open:this.state.confirmDialog.isOpen,title:this.state.confirmDialog.title,closeLabel:this.state.confirmDialog.closeButtonLabel,okLabel:this.state.confirmDialog.confirmButtonLabel,onOK:this.state.confirmDialog.onConfirm,onClose:function(){return e.closeDialog()}},t(We,{variant:"body1"},this.state.confirmDialog.message)))},r}(n),Ai=u((function(e,t){return Bt({},t)}))(bi),Oi=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={listedOrderGroups:Array()},r.columns=[{name:"No.",render:function(e){return t(We,null,"Order"===e.Type?e.OrderNumber:"# "+e.OrderGroupId)}},{name:"Created Date",render:function(e){return t(We,null,e.Created&&ot(e.Created).format("LLL"))}},{name:"Amount",right:!0,render:function(e){return t(Rs,{amount:e.Total})}},{name:"Status",render:function(e){return t(We,null,Qs(e.OrderStatus))}},{width:50,render:function(e,n){return t(Ci,{actions:[{title:"View",clickHandler:function(t){r.goToDetail(e.OrderGroupId)}}],rowData:e,rowIndex:n})}}],r}return Vt(r,e),r.prototype.componentDidMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){return this.loadOrderGroups(),[2]}))}))},r.prototype.loadOrderGroups=function(){return Wt(this,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return e=this.props.paymentPlan.OrderGroupId,[4,ln.PaymentPlan.getPurchaseOrders(e,0,500)];case 1:return t=r.sent(),this.setState({listedOrderGroups:t.Results}),[2]}}))}))},r.prototype.goToDetail=function(e){as.push(Er+"/"+e+"?returnUrl="+cs())},r.prototype.render=function(){return t("div",null,t(We,{variant:"h6"},"Orders History"),t("br",null),t(Us,{columns:this.columns,data:this.state.listedOrderGroups}))},r}(n);!function(e){e.AwaitingInventory="AwaitingInventory",e.Cancelled="Cancelled",e.InventoryAssigned="InventoryAssigned",e.OnHold="OnHold",e.Packing="Packing",e.Released="Released",e.Shipped="Shipped"}(Si||(Si={}));var wi,Ti=Si,Di=function(e){function r(t){var r=e.call(this,t)||this;r.state={updateCustomerAddress:!1,loaded:!1,existCustomerAddress:!1,addToAddressBook:!1,customerAddressId:""},r.validator={validate:function(){return null}},r.setCurrentAddress=function(e){r.props.dispatch(fr.ContactActions.setCurrentAddress(e)),r.props.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!0))},r.handleFormChanges=function(e){var t=Object.assign({},r.props.address),n="checkbox"===e.target.type?e.target.checked:e.target.value;t[e.target.name]=n,r.setCurrentAddress(t)},r.saveChanges=function(){return Wt(r,void 0,void 0,(function(){var e,t,r,n,s,i,o,a,u,d=this;return qt(this,(function(c){switch(c.label){case 0:if(null==(e=this.validator.validate()))return[2];t=Bt(Bt({},this.props.address),e),c.label=1;case 1:return c.trys.push([1,20,,21]),(r=this.props.orderGroup).IsDraft?(r.Forms[0].Shipments[0].ShippingAddress=Bt({},t),[4,ln.OrderGroup.calculateOrder(r)]):[3,9];case 2:return n=c.sent(),i=n.Forms[0].Shipments[0].ShippingAddress,this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(n)),this.props.editMode?this.state.updateCustomerAddress?[4,this.updateContactAddress()]:[3,4]:[3,5];case 3:c.sent(),c.label=4;case 4:return this.props.onAddressChanged(i),[3,8];case 5:return this.state.addToAddressBook?[4,this.addContactAddress()]:[3,7];case 6:c.sent(),c.label=7;case 7:this.props.onAddressCreated(i),c.label=8;case 8:return[3,19];case 9:return this.props.editMode?this.state.updateCustomerAddress?[4,this.updateContactAddress()]:[3,11]:[3,14];case 10:c.sent(),c.label=11;case 11:return[4,ln.OrderGroup.updateShippingAddress(r.Type,r.OrderGroupId,r.Forms[0].OrderFormId,this.props.shipment.ShipmentId,t)];case 12:return c.sent(),[4,ln.OrderGroup.getSingleOrderGroup(r.Type,r.OrderGroupId)];case 13:return o=c.sent(),s=o.Forms[0].Shipments.findIndex((function(e){return e.ShipmentId===d.props.shipment.ShipmentId})),i=o.Forms[0].Shipments[s].ShippingAddress,this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(o)),this.props.onAddressChanged(i),[3,19];case 14:return this.state.addToAddressBook?[4,this.addContactAddress()]:[3,16];case 15:c.sent(),c.label=16;case 16:return[4,ln.OrderGroup.addShippingAddress(r.Type,r.OrderGroupId,r.Forms[0].OrderFormId,this.props.shipment.ShipmentId,t)];case 17:return c.sent(),[4,ln.OrderGroup.getSingleOrderGroup(r.Type,r.OrderGroupId)];case 18:o=c.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(o)),(a=o.Forms[0].Shipments.find((function(e){return d.props.shipment.ShipmentId===e.ShipmentId})))&&this.props.onAddressCreated(a.ShippingAddress),c.label=19;case 19:return this.props.onClose(),[3,21];case 20:return u=c.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(u.message)),[3,21];case 21:return[2]}}))}))},r.updateContactAddress=function(){return Wt(r,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return e=Bt({},this.props.address),this.state.customerAddressId&&(e.AddressId=this.state.customerAddressId),[4,ln.Contact.updateContactAddress(this.props.orderGroup.Customer.Id,e.AddressId,e)];case 1:return t.sent(),[2]}}))}))},r.addContactAddress=function(){return Wt(r,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,ln.Contact.addContactAddress(this.props.orderGroup.Customer.Id,this.props.address)];case 1:return e.sent(),[2]}}))}))};var n=r.props.orderGroup.Customer.Addresses.find((function(e){return e.Name+e.DisplayName===r.props.address.Name+r.props.address.DisplayName}));return n&&(r.state.customerAddressId=n.AddressId,r.state.existCustomerAddress=!0,r.state.updateCustomerAddress=!0),r}return Vt(r,e),r.prototype.componentDidMount=function(){this.setState({loaded:!0})},r.prototype.render=function(){var e=this;return t(Cn,{open:!0,title:this.props.editMode?"Edit Address":"Add New Address",okLabel:"Save",onOK:this.saveChanges,closeLabel:"Cancel",onClose:this.props.onClose},this.state.loaded&&t(l,{container:!0,spacing:16},t(l,{item:!0,sm:12},t(On,{address:this.props.address,validator:this.validator})),!this.props.orderGroup.Customer.IsAnonymous&&t(l,{item:!0,sm:12},this.props.editMode&&this.state.existCustomerAddress&&t(C,{control:t(ue,{name:"UpdateCustomerAddress",checked:this.state.updateCustomerAddress,onChange:function(t){e.setState({updateCustomerAddress:t.target.checked})}}),label:"Also update customer's address"}),!this.props.editMode&&t(C,{control:t(ue,{name:"AddToAddressBook",checked:this.state.addToAddressBook,onChange:function(t){e.setState({addToAddressBook:t.target.checked})}}),label:"Add to customer's address book"}))))},r}(n),Pi=u((function(e,t){return{address:e.contact.currentAddress,orderGroup:e.orderGroup.currentOrderGroup,editMode:t.editMode,shipment:t.shipment,onClose:t.onClose,onAddressChanged:t.onAddressChanged,onAddressCreated:t.onAddressCreated}}))(Di),Gi=function(e){function r(t){var r,n=e.call(this,t)||this;return n.shipmentForm={},n.shippingMethodRefreshCount=0,n.loadShippingMethods=function(e){return Wt(n,void 0,Promise,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return[4,ln.Shipment.getShippingMethods(this.props.orderGroup.MarketId,e)];case 1:return t=r.sent(),this.setState({shippingMethods:t}),[2,t]}}))}))},n.customPropertyChangedHandler=function(e){return Wt(n,void 0,void 0,(function(){var t;return qt(this,(function(r){return(t=this.state.properties.findIndex((function(t){return t.Name===e.Name})))>=0&&(this.state.properties[t]=Bt({},e),this.setState({properties:jt(this.state.properties)}),this.forceUpdate()),[2]}))}))},n.handleAddressChange=function(e){return Wt(n,void 0,void 0,(function(){var t,r,n=this;return qt(this,(function(s){switch(s.label){case 0:return this.setState({addressId:e}),(t=this.props.orderGroup.OrderAddresses.find((function(t){return t.AddressId===e})))?[4,this.loadShippingMethods(t.CountryCode)]:(this.props.dispatch(fr.ApplicationActions.showNotification("AddressData not found")),[2]);case 1:return(r=s.sent()).length>0&&void 0===r.find((function(e){return e.ShippingMethodId===n.state.shippingMethodId}))&&this.setState({shippingMethodId:r[0].ShippingMethodId}),0===r.length&&this.setState({shippingMethodId:""}),[2]}}))}))},n.openEditAddressDialog=function(){var e=n.props.orderGroup.OrderAddresses.find((function(e){return e.AddressId===n.state.addressId}));e&&(n.props.dispatch(fr.ContactActions.setCurrentAddress(e)),n.setState({isShowAddressForm:!0,orderAddressEditMode:!0}))},n.openAddAddressDialog=function(){n.props.dispatch(fr.ContactActions.setCurrentAddress({})),n.setState({isShowAddressForm:!0,orderAddressEditMode:!1})},n.onAddressChanged=function(e){return Wt(n,void 0,void 0,(function(){return qt(this,(function(t){return this.props.orderGroup.IsDraft&&this.setState({shipment:Bt(Bt({},this.state.shipment),{ShippingAddress:e})}),this.setState({addressId:e.AddressId}),[2]}))}))},n.onAddressCreated=function(e){return Wt(n,void 0,void 0,(function(){return qt(this,(function(t){switch(t.label){case 0:return this.props.orderGroup.IsDraft&&this.setState({shipment:Bt(Bt({},this.state.shipment),{ShippingAddress:e})}),[4,this.handleAddressChange(e.AddressId)];case 1:return t.sent(),[2]}}))}))},n.state={shippingAddressDropdownIsExpanded:!1,shippingAddressFormVisible:!1,shippingMethodId:n.props.shipment.ShippingMethodId,addressId:(null===(r=n.props.shipment.ShippingAddress)||void 0===r?void 0:r.AddressId)||"",trackingNumber:n.props.shipment.ShipmentTrackingNumber,loaded:!1,errorMessage:"",shipment:JSON.parse(JSON.stringify(n.props.shipment)),selectedAddress:t.shipment.ShippingAddress,properties:jt(t.shipment.Properties),shippingMethods:[],isShowAddressForm:!1,orderAddressEditMode:!0},n}return Vt(r,e),r.prototype.componentWillReceiveProps=function(e){var t,r,n,s;return Wt(this,void 0,void 0,(function(){return qt(this,(function(i){return(null===(t=e.shipment.ShippingAddress)||void 0===t?void 0:t.AddressId)===(null===(r=this.props.shipment.ShippingAddress)||void 0===r?void 0:r.AddressId)&&(null===(n=e.shipment.ShippingAddress)||void 0===n?void 0:n.AddressId)!==this.state.addressId&&this.setState({addressId:(null===(s=e.shipment.ShippingAddress)||void 0===s?void 0:s.AddressId)||""}),[2]}))}))},r.prototype.componentDidMount=function(){var e;return Wt(this,void 0,void 0,(function(){return qt(this,(function(t){switch(t.label){case 0:return this.setState({loaded:!0}),[4,this.loadShippingMethods(null===(e=this.state.selectedAddress)||void 0===e?void 0:e.CountryCode)];case 1:return t.sent(),[2]}}))}))},r.prototype.updateShipmentTrackingNumber=function(e){return Wt(this,void 0,void 0,(function(){var t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,ln.Shipment.updateShipmentTrackingNumber(this.props.orderGroup.OrderGroupId,this.props.orderFormId,this.props.shipment.ShipmentId,e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.prototype.setDropdownIsExpanded=function(){this.setState({shippingAddressDropdownIsExpanded:!this.state.shippingAddressDropdownIsExpanded})},r.prototype.changeShippingMethodHandler=function(e){this.setState({shippingMethodId:e})},r.prototype.changeTrackingNumber=function(e){this.setState({trackingNumber:e})},r.prototype.validateForm=function(){var e="";return this.state.shippingMethodId&&"00000000-0000-0000-0000-000000000000"!==this.state.shippingMethodId||(e="Shipping Method is required."),this.state.addressId||(e="Shipping Address is required."),this.setState({errorMessage:e}),e},r.prototype.updateShipmentProperties=function(){return Wt(this,void 0,void 0,(function(){var e,t,r;return qt(this,(function(n){switch(n.label){case 0:if(this.props.orderGroup.IsDraft)return this.setState({shipment:Bt(Bt({},this.state.shipment),{Properties:this.state.properties})}),[2];e=0,n.label=1;case 1:if(!(e=0},r.prototype.render=function(){var e,r,n=this,s={title:this.isEditable()?"Edit Shipment":"View Shipment",open:!0,onClose:function(){n.props.onClose()}};this.isEditable()&&(s.onOK=function(){return Wt(n,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.saveForm()];case 1:return e.sent(),[2]}}))}))},s.okLabel="Save");var i=this.props.orderGroup.OrderAddresses.map((function(e,t){return{label:e.DisplayName,value:e.AddressId}})),o=this.state.shippingMethods.map((function(e){return{label:e.DisplayName,value:e.ShippingMethodId}})),a=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,u=null===(r=this.props.extendUI)||void 0===r?void 0:r.bottomPlaceHolder;return t(Cn,Bt({},s),this.state.loaded&&t("div",null,a&&t(a,null),t(Ee,{instantValidate:!0,onSubmit:function(){return null},ref:function(e){return n.shipmentForm=e}},t(l,{container:!0,spacing:16,direction:"row"},t(l,{item:!0,sm:12},t("span",{style:{color:"red"}},this.state.errorMessage)),t(l,{item:!0,sm:12},t(Jr,{label:"Choose Shipping Address *",fullWidth:!0,value:this.state.addressId,onChange:function(e){return n.handleAddressChange(e)},disabled:!this.isEditable(),options:i}),this.isEditable()&&t(l,{container:!0,spacing:16,justify:"flex-end"},t(l,{item:!0},t(m,{variant:"subtitle1",color:"primary",onClick:this.openAddAddressDialog,style:{cursor:"pointer",fontSize:"13px"}},"Add Address")),this.state.addressId&&t(l,{item:!0},t(m,{variant:"subtitle1",color:"primary",onClick:this.openEditAddressDialog,style:{cursor:"pointer",fontSize:"13px"}},"Edit Address")))),t(l,{item:!0,sm:12},t(Jr,{fullWidth:!0,key:this.shippingMethodRefreshCount++,disabled:!this.isEditable(),label:"Choose Shipping Method *",value:this.state.shippingMethodId,onChange:function(e){return n.changeShippingMethodHandler(e)},options:o})),t(l,{item:!0,sm:12},"Order"===this.props.orderGroup.Type&&t(h,{label:"Tracking number",variant:"outlined",value:this.state.trackingNumber,fullWidth:!0,onChange:function(e){return n.changeTrackingNumber(e.currentTarget.value)},disabled:this.props.shipment.OrderShipmentStatus.Name!==Ti.Packing})),this.props.properties&&this.props.properties.map((function(e,r){return t(l,{item:!0,sm:12,key:r},t(js,{key:r,property:e,isReadonly:!e.IsEditable,onPropertyChanged:n.customPropertyChangedHandler}))})))),u&&t(u,null)),this.state.isShowAddressForm&&t(Pi,{onClose:function(){return n.setState({isShowAddressForm:!1})},editMode:this.state.orderAddressEditMode,shipment:this.state.shipment,onAddressChanged:this.onAddressChanged,onAddressCreated:this.onAddressCreated}))},r}(n),Ni=u((function(e,t){var r,n,s=t.shipment,i=e.orderGroup.currentOrderGroup;return{shipment:s,orderFormId:i.Forms[e.orderGroup.selectedFormIndex].OrderFormId,orderGroup:i,createOrderAddressFormIsVisible:e.createOrderAddressForm.isVisible,properties:s.Properties,shipmentStatusUpdateDialogVisible:e.application.currentDialog===zt.UpdateShipmentStatus,customerAddresses:jt(i.Customer.Addresses),onClose:t.onClose,extendUI:null===(n=null===(r=e.setting.general)||void 0===r?void 0:r.editShipmentDialog)||void 0===n?void 0:n.extendUI}}))(Gi),Ri=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={shipmentDialogOpen:!1,currentShipmentIndex:0,shipmentDialog:{isOpen:!1,title:"",message:"",closeButtonLabel:"",confirmButtonLabel:"",onConfirm:function(){return null}}},r.columns=[{name:"No",right:!0,render:function(e,t){return t+1}},{name:"Recipient Name",render:function(e){var t="";return e.ShippingAddress&&(t=[e.ShippingAddress.FirstName,e.ShippingAddress.LastName].filter((function(e){return e})).join(" ")),t}},{name:"Shipping Address",render:function(e){return e.ShippingAddress?e.ShippingAddress.DisplayName:null}},{name:"Shipping Method",render:function(e){return r.getShippingMethodName(e.ShippingMethodId)}},{name:"Tracking No",selector:"ShipmentTrackingNumber"},{name:"Shipment Status",render:function(e){return Qs(e.OrderShipmentStatus.Name)}},{name:"Shipping Cost",right:!0,render:function(e){return e.ShippingCost.Amount.toFixed(e.ShippingCost.Fractions)}},{name:"Shipping Tax",right:!0,render:function(e){return e.ShippingTax.Amount.toFixed(e.ShippingTax.Fractions)}},{name:"Total (Incl tax)",right:!0,render:function(e){return e.ShipmentTotal.Amount.toFixed(e.ShipmentTotal.Fractions)+" "+e.ShipmentTotal.Currency}},{name:"",width:50,hideOnColumnsSelection:!0,render:function(e,n){var s=[{title:r.isEditableShipment(e)?"Edit":"View",clickHandler:function(e){r.openEditShipmentDialog(n)}}];return r.props.orderGroup.IsDraft||"Order"!==r.props.orderGroup.Type||(r.canReleaseShipment(e)&&s.push({title:"Release",clickHandler:function(e){r.showReleaseShipmentConfirmDialog(e.ShipmentId)}}),r.canShowAddToPickListButton(e)&&s.push({title:"Add to Picklist",clickHandler:function(e){r.showAddToPickListConfirmDialog(e.ShipmentId)}}),r.canShowCompleteButton(e)&&s.push({title:"Complete",clickHandler:function(e){r.showCompleteShipmentConfirmDialog(e.ShipmentId)}}),!r.props.orderGroup.IsDraft&&r.canShowCancelButton(e)&&s.push({title:"Cancel",clickHandler:function(e){r.showCancelShipmentConfirmDialog(e.ShipmentId)}})),t(Ci,{actions:s,rowData:e,rowIndex:n})}}],r}return Vt(r,e),r.prototype.canReleaseShipment=function(e){return!(this.props.orderGroup.OrderStatus===oi.AwaitingExchange||!e.ShippingAddress||"00000000-0000-0000-0000-000000000000"===e.ShippingMethodId)&&this.canShowReleaseButton(e)},r.prototype.canShowReleaseButton=function(e){return e.OrderShipmentStatus.Name===Ti.AwaitingInventory||e.OrderShipmentStatus.Name===Ti.InventoryAssigned},r.prototype.canShowCompleteButton=function(e){return this.props.orderGroup.OrderStatus!==oi.AwaitingExchange&&e.OrderShipmentStatus.Name===Ti.Packing},r.prototype.canShowCancelButton=function(e){return this.props.orderGroup.OrderStatus!==oi.AwaitingExchange&&e.OrderShipmentStatus.Name!==Ti.Shipped&&e.OrderShipmentStatus.Name!==Ti.OnHold&&e.OrderShipmentStatus.Name!==Ti.Cancelled},r.prototype.canShowAddToPickListButton=function(e){return e.OrderShipmentStatus.Name===Ti.Released},r.prototype.showCancelShipmentConfirmDialog=function(e){var t=this;this.setState({shipmentDialog:{isOpen:!0,title:"Cancel Shipment",message:"Are you sure you want to cancel this shipment?",closeButtonLabel:"Close",confirmButtonLabel:"Cancel Shipment",onConfirm:function(){return t.updateShipmentStatus(e,Ti.Cancelled)}}})},r.prototype.showReleaseShipmentConfirmDialog=function(e){var t=this;this.setState({shipmentDialog:{isOpen:!0,title:"Release Shipment",message:"Are you sure you want to release this shipment?",closeButtonLabel:"Close",confirmButtonLabel:"Release Shipment",onConfirm:function(){return t.updateShipmentStatus(e,Ti.Released)}}})},r.prototype.showAddToPickListConfirmDialog=function(e){var t=this;this.setState({shipmentDialog:{isOpen:!0,title:"Add to PickList",message:"Are you sure you want to add this shipment to a new picklist?",closeButtonLabel:"Close",confirmButtonLabel:"Add to PickList",onConfirm:function(){return t.addShipmentToPickList(e)}}})},r.prototype.closeShipmentDialog=function(){this.setState({shipmentDialog:{isOpen:!1}})},r.prototype.addShipmentToPickList=function(e){return Wt(this,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:this.closeShipmentDialog(),this.props.dispatch(fr.ApplicationActions.setLoadingOverlayState(!0)),n.label=1;case 1:return n.trys.push([1,4,,5]),[4,ln.Shipment.addToPickList(this.props.orderGroup.OrderGroupId,this.props.orderFormId,e)];case 2:return n.sent(),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 3:return t=n.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(t)),this.props.dispatch(fr.ApplicationActions.setLoadingOverlayState(!1)),[3,5];case 4:return r=n.sent(),this.props.dispatch(fr.ApplicationActions.setLoadingOverlayState(!1)),this.props.dispatch(fr.ApplicationActions.showNotification(r.message)),[3,5];case 5:return[2]}}))}))},r.prototype.showCompleteShipmentConfirmDialog=function(e){var t=this;this.setState({shipmentDialog:{isOpen:!0,title:"Complete Shipment",message:"Are you sure you want to complete this shipment?",closeButtonLabel:"Close",confirmButtonLabel:"Complete Shipment",onConfirm:function(){return t.updateShipmentStatus(e,Ti.Shipped)}}})},r.prototype.updateShipmentStatus=function(e,t){return Wt(this,void 0,void 0,(function(){var r,n;return qt(this,(function(s){switch(s.label){case 0:this.closeShipmentDialog(),this.props.dispatch(fr.ApplicationActions.setLoadingOverlayState(!0)),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,ln.Shipment.updateShipmentStatus(this.props.orderGroup.OrderGroupId,this.props.orderFormId,e,t)];case 2:return s.sent(),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 3:return r=s.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(r)),this.props.dispatch(fr.ApplicationActions.setLoadingOverlayState(!1)),[3,5];case 4:return n=s.sent(),this.props.dispatch(fr.ApplicationActions.setLoadingOverlayState(!1)),this.props.dispatch(fr.ApplicationActions.showNotification(n.message)),[3,5];case 5:return[2]}}))}))},r.prototype.openEditShipmentDialog=function(e){this.setState({shipmentDialogOpen:!0,currentShipmentIndex:e})},r.prototype.isEditableShipment=function(e){var t=e.OrderShipmentStatus.Name;return!(t===Ti.Cancelled||t===Ti.OnHold||t===Ti.Shipped)},r.prototype.getShippingMethodName=function(e){var t;return null===(t=this.props.shippingMethods.filter((function(t){return t.ShippingMethodId===e}))[0])||void 0===t?void 0:t.DisplayName},r.prototype.render=function(){var e=this;return t("div",null,t(m,{variant:"h6"},"Shipments"),t("br",null),t(Us,{columns:this.columns,data:this.props.shipments}),this.state.shipmentDialogOpen&&t(Ni,{shipment:this.props.shipments[this.state.currentShipmentIndex],isShipmentReadonly:this.isEditableShipment(this.props.shipments[this.state.currentShipmentIndex]),onClose:function(){e.setState({shipmentDialogOpen:!1})}}),this.state.shipmentDialog.isOpen&&t(Sn,{title:this.state.shipmentDialog.title,closeButtonLabel:this.state.shipmentDialog.closeButtonLabel,confirmButtonLabel:this.state.shipmentDialog.confirmButtonLabel,onConfirm:this.state.shipmentDialog.onConfirm,onClose:function(){e.setState({shipmentDialog:{isOpen:!1}})}},t(m,{variant:"body1"},this.state.shipmentDialog.message)))},r}(n),Ei=z((function(e){e.palette;var t,r=e.spacing,n=e.breakpoints;return c({root:{},paper:(t={padding:2*r.unit,marginBottom:2*r.unit},t[n.down("xs")]={padding:10},t)})}))(u((function(e,t){var r=e.orderGroup.currentOrderGroup,n=r.Forms[e.orderGroup.selectedFormIndex];return{shipments:t.shipments,orderGroup:r,shippingMethods:e.shipment.shippingMethods,orderFormId:n.OrderFormId,classes:t.classes}}))(Ri)),xi=z((function(e){e.palette,e.spacing,e.breakpoints;return c({root:{"&-inline":{display:"inline-block"}}})}))((function(e){var r=e.classes;return t("div",{className:r.root+" "+(e.renderInline?r.root+"-inline":"")},t(We,{variant:"body1",color:"textSecondary"},e.message))})),Li=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={AddToAddressBook:!0},t.validator={validate:function(){return null}},t.handleCheckboxChange=function(e){t.setState({AddToAddressBook:e.target.checked})},t.saveChanges=function(){return Wt(t,void 0,void 0,(function(){var e,t,r,n,s;return qt(this,(function(i){switch(i.label){case 0:if(null==(e=this.validator.validate()))return[2];t=Bt(Bt({},this.props.address),e),i.label=1;case 1:return i.trys.push([1,8,,9]),this.state.AddToAddressBook?[4,this.props.addContactAddress(this.props.currentContactId,t)]:[3,5];case 2:return i.sent(),[4,this.props.getContact(this.props.currentContactId)];case 3:return r=i.sent(),this.props.dispatch(fr.ContactActions.setCurrentContact(r)),[4,ln.OrderGroup.getSingleOrderGroup(this.props.currentOrderGroup.Type,this.props.currentOrderGroup.OrderGroupId)];case 4:(n=i.sent()).Customer=r,this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(n)),i.label=5;case 5:return this.props.processOnAddressCreation?[4,this.props.processOnAddressCreation(t,this.props.addressType)]:[3,7];case 6:i.sent(),i.label=7;case 7:return this.props.addressType===Kt.BillingAddress&&this.props.dispatch(fr.PaymentActions.setBillingAddress(t)),this.closeDialog(),[3,9];case 8:return s=i.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(s.message)),[3,9];case 9:return[2]}}))}))},t.closeView=function(){t.props.dispatch(fr.CreateOrderAddressFormAction.hideCreateOrderAddressForm()),t.props.dispatch(fr.AddressFormActions.clearAddressForm()),t.props.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!1))},t}return Vt(r,e),r.prototype.closeDialog=function(){this.closeView(),this.props.onClose()},r.prototype.render=function(){var e=this;return t(f,{open:!0,"aria-describedby":"alert-dialog-description",className:this.props.classes.root,fullWidth:!0},t(Ct,null,"Add New Address"),t(ne,{id:"alert-dialog-description"},t(On,{address:this.props.address,validator:this.validator}),"Order"===this.props.currentOrderGroup.Type&&t(C,{control:t(ue,{name:"AddToAddressBook",checked:this.state.AddToAddressBook,onChange:this.handleCheckboxChange}),label:"Add to customer's address book"})),t(re,null,t(se,{onClick:function(){return e.closeDialog()}},"Cancel"),t(se,{unelevated:!0,type:"submit",onClick:this.saveChanges},"Add as ",this.props.addressType)))},r}(n),Mi=z((function(e){e.palette,e.spacing,e.breakpoints;return c({root:{}})}))(u((function(e,t){var r=e.orderGroup.currentOrderGroup;return{addContactAddress:ln.Contact.addContactAddress,address:e.contact.currentAddress,currentContactId:e.contact.currentContact.Id,currentOrderGroup:r,addressType:e.createOrderAddressForm.addressType,classes:t.classes,getContact:ln.Contact.get,onClose:t.onClose,processOnAddressCreation:t.processOnAddressCreation}}))(Li)),Fi=function(e){function r(t){var r=e.call(this,t)||this;r.state={updateCustomerAddress:!1,loaded:!1,existCustomerAddress:!1,addToAddressBook:!1,customerAddressId:""},r.validator={validate:function(){return null}},r.setCurrentAddress=function(e){r.props.dispatch(fr.ContactActions.setCurrentAddress(e)),r.props.dispatch(fr.ApplicationActions.setIsCurrentFormDirty(!0))},r.handleFormChanges=function(e){var t=Object.assign({},r.props.address),n="checkbox"===e.target.type?e.target.checked:e.target.value;t[e.target.name]=n,r.setCurrentAddress(t)},r.saveChanges=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:if(null==this.validator.validate())return[2];r.label=1;case 1:return r.trys.push([1,10,,11]),this.props.editMode?this.state.updateCustomerAddress?[4,this.updateContactAddress()]:[3,3]:[3,5];case 2:r.sent(),r.label=3;case 3:return[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 4:return e=r.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(e)),this.props.onAddressChanged(Bt({},this.props.address)),[3,9];case 5:return this.state.addToAddressBook?[4,this.addContactAddress()]:[3,7];case 6:r.sent(),r.label=7;case 7:return[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 8:e=r.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(e)),this.props.onAddressCreated(this.props.address),r.label=9;case 9:return this.props.onClose(),[3,11];case 10:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,11];case 11:return[2]}}))}))},r.updateContactAddress=function(){return Wt(r,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return e=Bt({},this.props.address),this.state.customerAddressId&&(e.AddressId=this.state.customerAddressId),[4,ln.Contact.updateContactAddress(this.props.orderGroup.Customer.Id,e.AddressId,e)];case 1:return t.sent(),[2]}}))}))},r.addContactAddress=function(){return Wt(r,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,ln.Contact.addContactAddress(this.props.orderGroup.Customer.Id,this.props.address)];case 1:return e.sent(),[2]}}))}))};var n=r.props.orderGroup.Customer.Addresses.find((function(e){return e.Name+e.DisplayName===r.props.address.Name+r.props.address.DisplayName}));return n&&(r.state.customerAddressId=n.AddressId,r.state.existCustomerAddress=!0,r.state.updateCustomerAddress=!0),r}return Vt(r,e),r.prototype.componentDidMount=function(){this.setState({loaded:!0})},r.prototype.render=function(){var e=this;return t(Cn,{open:!0,title:this.props.editMode?"Edit Address":"Add New Address",okLabel:"Save",onOK:this.saveChanges,closeLabel:"Cancel",onClose:this.props.onClose},this.state.loaded&&t(l,{container:!0,spacing:16},t(l,{item:!0,sm:12},t(On,{address:this.props.address,validator:this.validator})),!this.props.orderGroup.Customer.IsAnonymous&&t(l,{item:!0,sm:12},this.props.editMode&&this.state.existCustomerAddress&&t(C,{control:t(ue,{name:"UpdateCustomerAddress",checked:this.state.updateCustomerAddress,onChange:function(t){e.setState({updateCustomerAddress:t.target.checked})}}),label:"Also update customer's address"}),!this.props.editMode&&t(C,{control:t(ue,{name:"AddToAddressBook",checked:this.state.addToAddressBook,onChange:function(t){e.setState({addToAddressBook:t.target.checked})}}),label:"Add to customer's address book"}))))},r}(n),ki=u((function(e,t){return{address:e.contact.currentAddress,orderGroup:e.orderGroup.currentOrderGroup,editMode:t.editMode,onClose:t.onClose,onAddressChanged:t.onAddressChanged,onAddressCreated:t.onAddressCreated}}))(Fi),_i=function(e){function r(t){var r=e.call(this,t)||this;return r.state={paymentInProcess:!1,paymentAddressFormVisible:!1,billingAddressId:"",paymentMethodId:"",selectedPayment:{},billingAddress:{},loaded:!1,errors:{BillingAddressId:"",PaymentMethodId:"",TransactionAmount:""},isShowAddressForm:!1,billingAddressEditMode:!0},r.validationSchema=Ae({BillingAddressId:Oe().required("Billing Address is required."),PaymentMethodId:Oe().required("Payment Method is required."),TransactionAmount:we().required("Transaction Amount is required.").min(0).lessThan(Number.MAX_SAFE_INTEGER,"This value is out of range.")}),r.validateForm=function(){return Wt(r,void 0,void 0,(function(){var e,t,r;return qt(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.validationSchema.validate({BillingAddressId:this.state.billingAddressId,TransactionAmount:Number(null===(r=this.state.selectedPayment.Amount)||void 0===r?void 0:r.Amount)||void 0,PaymentMethodId:this.state.paymentMethodId},{abortEarly:!1})];case 1:return n.sent(),[2,!0];case 2:return e=n.sent(),t={},e.inner.map((function(e){t[e.path]=e.message})),this.setState({errors:t}),[2,!1];case 3:return[2]}}))}))},r.addPayment=function(){return Wt(r,void 0,void 0,(function(){var e,t,r,n,s=this;return qt(this,(function(i){switch(i.label){case 0:return[4,this.validateForm()];case 1:if(!i.sent())return[2];if(this.setState({paymentInProcess:!0}),(e=this.props.orderGroup.OrderAddresses.find((function(e){return e.AddressId===s.state.billingAddressId})))||(e=this.state.billingAddress),!this.state.billingAddress)return[3,7];this.state.selectedPayment.BillingAddress=e,i.label=2;case 2:return i.trys.push([2,5,,6]),[4,ln.OrderGroup.addPayment(this.props.orderGroup.Type,this.state.selectedPayment,this.props.orderGroup.OrderGroupId,this.props.orderForm.OrderFormId)];case 3:return t=i.sent(),this.props.orderForm.Payments.push(t.data),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 4:return r=i.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(r)),this.props.onClose(),[3,6];case 5:return n=i.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(n.message)),[3,6];case 6:return[3,8];case 7:this.props.dispatch(fr.ApplicationActions.showNotification("You need to choose a billing address.")),i.label=8;case 8:return this.setState({paymentInProcess:!1}),[2]}}))}))},r.changeTransactionAmountHandler=function(e){return Wt(r,void 0,void 0,(function(){return qt(this,(function(t){return this.updatePayment(this.state.selectedPayment,"Amount",{Currency:this.state.selectedPayment.Amount.Currency,Amount:e}),[2]}))}))},r.customPropertyChangedHandler=function(e){return Wt(r,void 0,void 0,(function(){var t,r;return qt(this,(function(n){for(t=this.state.selectedPayment.Properties,r=0;r=1&&(e=this.props.paymentMethods.find((function(e){return!0===e.IsDefault}))),void 0===e?[3,2]:[4,ln.OrderGroup.getPaymentModel(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId,this.props.orderForm.OrderFormId,e.PaymentMethodId)];case 1:t=r.sent(),this.setState({paymentMethodId:e.PaymentMethodId,selectedPayment:t}),r.label=2;case 2:return[2]}}))}))},r.prototype.setDefaultBillingAddress=function(){return Wt(this,void 0,void 0,(function(){var e,t;return qt(this,(function(r){return null!==(e=this.props.orderGroup.OrderAddresses)&&(t=void 0,e.length>=1&&(t=e.find((function(e){return!0===e.IsPreferredBillingAddress}))),void 0!==t&&this.setState({billingAddress:t})),[2]}))}))},r.prototype.updatePayment=function(e,t,r){var n=Object.assign({},e);n[t]=r,this.setState({selectedPayment:n})},r.prototype.changePaymentMethod=function(e){return Wt(this,void 0,void 0,(function(){var t,r=this;return qt(this,(function(n){switch(n.label){case 0:return[4,ln.OrderGroup.getPaymentModel(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId,this.props.orderForm.OrderFormId,e)];case 1:return t=n.sent(),this.setState({paymentMethodId:e,selectedPayment:t},(function(){var e=r.getRemainTransactionAmount();r.changeTransactionAmountHandler(e)})),[2]}}))}))},r.prototype.getRemainTransactionAmount=function(){return(this.props.orderGroup.Total.Amount-(this.props.orderForm.AuthorizedPaymentTotal.Amount+this.props.orderForm.CapturedPaymentTotal.Amount)).toFixed(this.props.orderGroup.Total.Fractions)},r.prototype.render=function(){var e=this,r=this.props.paymentMethods.map((function(e){return{label:e.Name+" "+e.LanguageId,value:e.PaymentMethodId}})),n=jt(this.props.orderGroup.OrderAddresses);this.state.billingAddress.AddressId&&void 0===n.find((function(t){return t.DisplayName===e.state.billingAddress.DisplayName}))&&(n=jt([this.state.billingAddress],this.props.orderGroup.OrderAddresses));var s=n.map((function(e){return{label:e.DisplayName,value:e.AddressId}}));return t(Cn,{open:!0,title:"Add Payment",onClose:this.props.onClose,okLabel:"Save",closeLabel:"Cancel",onOK:this.addPayment},this.state.paymentAddressFormVisible&&t(Mi,{onClose:function(){e.setState({paymentAddressFormVisible:!1})}}),this.state.loaded&&t(l,{container:!0,spacing:16},t(l,{item:!0,xs:12},t(l,{container:!0,spacing:16},t(l,{item:!0,xs:12},t(Jr,{label:"Billing Address",fullWidth:!0,options:s,value:this.state.billingAddressId,onChange:function(t){return e.billingAddressChange(t)}}),t(m,{variant:"caption",color:"error"},this.state.errors.BillingAddressId),t(l,{container:!0,spacing:16,justify:"flex-end"},t(l,{item:!0},t(m,{variant:"subtitle1",color:"primary",onClick:this.openAddAddressDialog,style:{cursor:"pointer",fontSize:"13px"}},"Add Address")),this.state.billingAddressId&&t(l,{item:!0},t(m,{variant:"subtitle1",color:"primary",onClick:this.openEditAddressDialog,style:{cursor:"pointer",fontSize:"13px"}},"Edit Address")))),t(l,{item:!0,xs:12},t(Jr,{label:"Payment Method",fullWidth:!0,options:r,value:this.state.paymentMethodId,onChange:function(t){return e.changePaymentMethod(t)}}),t(m,{variant:"caption",color:"error"},this.state.errors.PaymentMethodId)),this.state.paymentMethodId&&t(l,{item:!0,xs:12},t(h,{id:"transactionAmount",name:"TransactionAmount",type:"number",label:"Transaction Amount",fullWidth:!0,variant:"outlined",defaultValue:this.getRemainTransactionAmount(),onChange:function(t){return e.changeTransactionAmountHandler(t.target.value)},error:!!this.state.errors.TransactionAmount,helperText:this.state.errors.TransactionAmount,inputProps:{step:.1,min:0}})))),this.state.paymentMethodId&&this.state.selectedPayment.Properties&&this.state.selectedPayment.Properties.length>0&&t(l,{item:!0,xs:12},t(zs,{isCollapsible:!1,properties:this.state.selectedPayment.Properties,onPropertyChanged:this.customPropertyChangedHandler}))),this.state.isShowAddressForm&&t(ki,{onClose:function(){return e.setState({isShowAddressForm:!1})},editMode:this.state.billingAddressEditMode,onAddressChanged:this.updateBillingAddress,onAddressCreated:this.updateBillingAddress}))},r}(n),Vi=u((function(e,t){var r=e.orderGroup.currentOrderGroup;return{paymentMethods:e.payment.paymentMethods,orderGroup:r,orderForm:r.Forms[e.orderGroup.selectedFormIndex],onClose:t.onClose}}))(_i),Ui=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={isAddPaymentFormVisible:!1},r.columns=[{name:"Payment Method",render:function(e){return t(We,null,e.PaymentMethodName)}},{name:"Billing Address",render:function(e){return t(bn,{address:e.BillingAddress})}},{name:"Status",render:function(e){return t(We,null,Qs(e.Status))}},{name:"Transaction Amount",render:function(e){return t(Rs,{amount:e.Amount,variant:"body2"})}},{name:"Transaction Type",render:function(e){return t(We,null,Qs(e.TransactionType))}},{name:"Transaction ID",render:function(e){return t(We,null,Qs(e.TransactionID))}},{name:"Provider Transaction ID",render:function(e){return t(We,null,Qs(e.ProviderTransactionID))}}],r}return Vt(r,e),r.prototype.render=function(){var e=this;return t(l,{container:!0,direction:"column",spacing:16},t(l,{item:!0},t(We,{variant:"h6"},"Transactions")),t(l,{item:!0},t(It,null)),!this.state.isAddPaymentFormVisible&&this.props.canAcceptPayment&&t(l,{item:!0},t(se,{unelevated:!0,onClick:function(){return e.setState({isAddPaymentFormVisible:!0})}},"Add Payment")),t(l,{item:!0},this.props.payments.length>0?t(Us,{columns:this.columns,data:this.props.payments}):t(xi,{message:"No payments found."})),this.state.isAddPaymentFormVisible&&t(Vi,{onClose:function(){e.setState({isAddPaymentFormVisible:!1})}}))},r}(n),Bi=function(e){var t=e.orderGroup.currentOrderGroup,r=!1;if("Cart"!==t.Type){var n=t.Forms[e.orderGroup.selectedFormIndex],s=n.AuthorizedPaymentTotal.Amount+n.CapturedPaymentTotal.Amount0&&qi(e.orderGroupType,e.orderGroupId,e.orderForm.OrderFormId,e.couponTextFieldValue,n,s)},inputProps:{className:r.couponTextFieldFocus},InputProps:{className:r.couponTextFieldInput,endAdornment:t(Ot,{position:"end"},t(at,{title:"Add "+e.couponTextFieldValue+" as a coupon code"},t("div",null,t(ie,{disabled:0===e.couponTextFieldValue.length,onClick:function(){return qi(e.orderGroupType,e.orderGroupId,e.orderForm.OrderFormId,e.couponTextFieldValue,n,s)}},t(Ye,null)))))}})),e.coupons.length>0?e.coupons.map((function(i,o){return t($,{item:!0,key:o},t(bt,{avatar:i.Applied?t(wt,{className:r.chipAvatar},t(Tt,null)):void 0,className:r.chip,label:i.Code,variant:i.Applied?"default":"outlined",onDelete:e.isReadonly?void 0:function(){return function(e,t,r,n,s,i){return Wt(void 0,void 0,void 0,(function(){var o;return qt(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,ln.OrderGroup.removeCoupon(e,t,r,i)];case 1:return a.sent(),Wi(e,t,n,s),[3,3];case 2:return o=a.sent(),s(o.message),[3,3];case 3:return[2]}}))}))}(e.orderGroupType,e.orderGroupId,e.orderForm.OrderFormId,n,s,i)}}))})):t($,{item:!0},t(xi,{message:Qs(e.orderGroupType)+" contains no coupons.",renderInline:!0}))))})));!function(e){e[e.None=0]="None",e[e.Money=1]="Money",e[e.Percentage=2]="Percentage",e[e.Free=3]="Free",e[e.FixedPrice=4]="FixedPrice",e[e.Gift=5]="Gift"}(wi||(wi={}));var Yi,zi=wi,Qi=function(e){return e.promotionInformation.RewardType===zi.Gift?t(We,Bt({},e),"Gift"):t(Rs,Bt({},e.typographyProps,{amount:e.promotionInformation.SavedAmount}))},Ki=z((function(e){e.palette,e.spacing,e.breakpoints;return c({})}))((function(e){var r=[{name:"Discount",selector:"Name"},{name:"Description",selector:"Description"},{name:"Coupon Code",selector:"CouponCode"},{name:"Saved Amount",right:!0,render:function(e){return t(Qi,{promotionInformation:e,typographyProps:{variant:"body1"}})}}];return t($,{direction:"column",spacing:16,container:!0},t($,{item:!0},t(We,{variant:"h6",gutterBottom:!0},"Discounts")),t($,{item:!0},t(L,null)),!e.isCreateNewOrder&&t($,{item:!0},t(ji,{isReadonly:e.isReadonly})),t($,{item:!0},e.promotionInformation.length>0?t(Us,{columns:r,data:e.promotionInformation}):t(xi,{message:"There are currently no discounts applied."})))})),Xi=z((function(e){e.palette,e.spacing,e.breakpoints;return c({root:{width:48,height:48,display:"inline-flex",justifyContent:"center",alignItems:"center"},tooltip:{postition:"relative",height:"100%",width:"100%"}})}))((function(e){var r=e.classes,n=e.children;return t("div",{className:r.root},t(at,{classes:{tooltip:r.tooltip},title:e.tooltipMessage},t(Gt,{badgeContent:e.badgeContent,color:"primary"},n)))})),Ji=function(e){var r=e.ThumbnailUrl?t(wt,{src:e.ThumbnailUrl}):t(Dt,null);return e.IsGift?t(Xi,{tooltipMessage:"Gift",badgeContent:t(Pt,{style:{width:"0.75em"}})},r):r},Zi=function(e){return t(l,{container:!0,direction:"row",justify:"flex-start",spacing:8},e.properties&&Object.keys(e.properties).map((function(r){return t(l,{item:!0,key:r},t(We,{color:"textSecondary",variant:"body2"},r,": ",t("strong",null,e.properties[r])))})))},$i=require("autosuggest-highlight/match"),eo=require("autosuggest-highlight/parse"),to=function(e){e.classes;var r=Ht(e,["classes"]);return t(h,Bt({fullWidth:!0,label:"Product Variant",placeholder:"Search by catalog SKU code or name",variant:"outlined"},r))},ro=function(e){return e.Code},no=function(e){function r(r){var n=e.call(this,r)||this;return n.classes=n.props.classes,n.state={searchFieldValue:"",suggestions:[],isWaitingSuggestions:!1},n.requiredSearchStringLength=3,n.SuggestionsContainer=function(e){var r=e.containerProps,s=e.children;return t(M,Bt({},r,{className:n.classes.suggestionsContainerOpen,square:!0}),n.state.isWaitingSuggestions&&t("div",{className:n.classes.progressContainer},t(F,{className:n.classes.progressIndicator})),s)},n.selectSuggestion=function(e,t){return Wt(n,void 0,void 0,(function(){return qt(this,(function(e){return this.props.onSelected(t.suggestion),[2]}))}))},n.getSuggestions=function(e){var t=e.value;return Wt(n,void 0,void 0,(function(){var e,r,n;return qt(this,(function(s){switch(s.label){case 0:return e=t.trim().toLowerCase(),r=[],this.props.dispatch(fr.ApplicationActions.setIsLoadingResource(!0)),e.length0&&(r=r.map((function(e){return e})),this.setState({suggestions:r})),[3,4];case 3:return n=s.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(n.message)),[3,4];case 4:return this.props.dispatch(fr.ApplicationActions.setIsLoadingResource(!1)),[2,r]}}))}))},n.clearSuggestions=function(){n.setState({suggestions:[]})},n.updateSearchFieldValue=function(e,t){t&&(n.setState({searchFieldValue:t.newValue}),n.props.onSearchFieldChanged&&n.props.onSearchFieldChanged(t.newValue))},n.renderEntrySuggestion=function(e,r){return function(e,r){var n=$i(e.DisplayName,r.query),s=eo(e.DisplayName,n),i=$i(e.Code,r.query),o=eo(e.Code,i),a=r.isHighlighted?fn.hoveredList:"#fff";return t(pe,{style:{backgroundColor:a,paddingTop:0,paddingBottom:0}},t(le,{style:{height:"auto"}},""!==e.ThumbnailUrl?t(k,{src:e.ThumbnailUrl}):t(k,null,t(Dt,null)),t(he,{primaryText:t("div",{style:{textAlign:"left",minHeight:"50px",paddingLeft:"16px",width:"100%"}},t(m,{variant:"subtitle1"},s.map((function(e,r){return e.highlight?t("span",{key:String(r),style:{fontWeight:500}},e.text):t("strong",{key:String(r),style:{fontWeight:300}},e.text)}))),t($,{container:!0,spacing:16,justify:"space-between"},t($,{item:!0,xs:12,sm:6},t(m,{variant:"body1",color:"textSecondary"},o.map((function(e,r){return e.highlight?t("span",{key:String(r),style:{fontWeight:500}},e.text):t("strong",{key:String(r),style:{fontWeight:300}},e.text)})))),t($,{item:!0,xs:12,sm:3},t(m,{variant:"body1",color:"textSecondary",style:{fontWeight:300}},"In Stock: ",e.InStock)),t($,{item:!0,xs:12,sm:3},e.ProductUrl&&t("a",{href:e.ProductUrl,target:"_blank",rel:"noopener noreferrer",onClick:function(e){e.stopPropagation()}},t(m,null,"More Details"))),t($,{item:!0,xs:12},t(Zi,{properties:e.CustomProperties}))))}),e.QuantityInShipment>0&&t("div",{style:{marginLeft:"-40px"}},t(Xi,{badgeContent:e.QuantityInShipment,tooltipMessage:"The shipment already contains "+e.QuantityInShipment+" of this item."},t(xt,null)))),t(me,null))}(e,r)},n.getSuggestionsDebounce=Nt(n.getSuggestions,1e3,{trailing:!0}),n}return Vt(r,e),r.prototype.render=function(){return t("div",{className:this.classes.root},t(Et,{suggestions:this.state.suggestions.slice(0,20),renderInputComponent:to,onSuggestionsFetchRequested:this.getSuggestionsDebounce,onSuggestionsClearRequested:this.clearSuggestions,renderSuggestionsContainer:this.SuggestionsContainer,getSuggestionValue:ro,renderSuggestion:this.renderEntrySuggestion,onSuggestionSelected:this.selectSuggestion,theme:{container:this.classes.container,suggestionsContainerOpen:this.classes.suggestionsContainerOpen,suggestionsList:this.classes.suggestionsList,suggestion:this.classes.suggestion},inputProps:{classes:this.classes,value:this.state.searchFieldValue,onChange:this.updateSearchFieldValue,type:"search"}}))},r}(n),so=z((function(e){var t=e.palette,r=e.spacing;e.breakpoints;return c({root:{flexGrow:1},container:{position:"relative",textAlign:"center",minHeight:56},suggestionsContainerOpen:{position:"absolute",zIndex:2,marginTop:r.unit,left:0,right:0,width:"100%"},suggestion:{display:"block",cursor:"pointer"},suggestionsList:{margin:0,padding:0,listStyleType:"none"},divider:{height:2*r.unit},progressContainer:{marginTop:8},progressIndicator:{color:t.secondary.light,margin:8},noResultsFound:{fontStyle:"italic",textAlign:"center",padding:6,marginTop:8}})}))(u((function(e,t){return{classes:t.classes,onSelected:t.onSelected,onSearchFieldChanged:t.onSearchFieldChanged}}))(no));!function(e){e[e.Percentage=1]="Percentage",e[e.Value=2]="Value"}(Yi||(Yi={}));var io=Yi,oo=function(e){function n(t){var r=e.call(this,t)||this;if(r.state={lineItem:r.props.lineItem,openEntrySelectionView:!1,shipmentId:-1,quantity:1,placedPrice:r.props.lineItem.PlacedPrice?r.props.lineItem.PlacedPrice.Amount:0,defaultPlacedPrice:-1,entrySelectedSuggestion:{},editMode:!1,errorMessage:"",discountType:io.Value,discountValue:0,discountDescription:"",showDialog:!1,properties:new Array,shipmentOptions:[],isBundle:!1,isReadonly:r.props.isReadonly,originalLineItem:{},errors:{Quantity:"",PlacedPrice:"",DiscountValue:"",DiscountType:"",ShipmentId:"",LineItemCode:""}},r.customPropertiesForm={},r.validationSchema=Ae().shape({Quantity:we().required().positive().lessThan(Number.MAX_SAFE_INTEGER,"This value is out of range."),EditMode:Pe(),PlacedPrice:we().min(0).lessThan(Number.MAX_SAFE_INTEGER,"This value is out of range."),ShipmentId:we().required("Please select a Shipment."),LineItemCode:Oe().when("EditMode",{is:!1,then:Oe().required("Product variant is required.")}),DiscountType:we(),DiscountValue:we().min(0).when("DiscountType",{is:1,then:we().max(100,"DiscountValue must be between 0-100."),otherwise:we().max(Ge("PlacedPrice"),"DiscountValue can not exceed PlacedPrice.")})}),r.submitForm=function(){return Wt(r,void 0,void 0,(function(){var e,t,r,n,s,i,o,a,u,d,c,p,l,h,m;return qt(this,(function(f){switch(f.label){case 0:return this.customPropertiesForm.isFormValid()?[4,this.validateForm()]:[2];case 1:return f.sent()?(e=this.getExistedLineItem(this.state.entrySelectedSuggestion.Code),this.state.editMode||e?(t=e?e.LineItemId:this.props.lineItem.LineItemId,r=e?e.Quantity:0,n=r+this.state.quantity,s={OrderGroupId:this.props.orderGroup.OrderGroupId,OrderGroupType:this.props.orderGroup.Type,LineItemId:t,Quantity:n,PlacedPrice:this.state.placedPrice},this.state.discountValue>0&&(s.DiscountType=this.state.discountType,s.DiscountValue=this.state.discountValue,s.DiscountDescription=this.state.discountDescription),this.state.editMode?[4,this.updateLineItemProperties()]:[3,3]):[3,10]):[2];case 2:f.sent(),f.label=3;case 3:return this.props.orderGroup.IsDraft?((i=e?JSON.parse(JSON.stringify(e)):this.state.lineItem).Quantity=s.Quantity,s.PlacedPrice&&(i.PlacedPrice.Amount=s.PlacedPrice),(o=s.DiscountValue?{ManualDiscountType:s.DiscountType,DiscountValue:s.DiscountValue,Description:s.DiscountDescription}:void 0)&&(i.ManualDiscount=o),a=JSON.parse(JSON.stringify(this.props.orderGroup)),u=a.Forms[0].Shipments[0].LineItems,d=u.findIndex((function(e){return e.LineItemId===t})),u[d]=i,[4,ln.OrderGroup.calculateOrder(a)]):[3,5];case 4:return a=f.sent(),l=a.ValidationMessages,this.lineItemHasChangedPrice(e||this.state.originalLineItem,a)&&(h="The price for product "+i.Code+" has changed since it was added to your cart.",l.push(h)),l.length>0?this.props.dispatch(fr.ApplicationActions.showNotification(l.join("\n"))):this.props.dispatch(fr.ApplicationActions.showNotification("The line item was successfully updated.")),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(a)),[3,9];case 5:return f.trys.push([5,8,,9]),[4,ln.OrderGroup.updateLineItem(s)];case 6:return c=f.sent(),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 7:return p=f.sent(),l=[],this.isValidationMessagesReturned(c)&&(l=c.data),this.lineItemHasChangedPrice(e||this.state.originalLineItem,p)&&(h="The price for product "+(e?e.Code:this.state.originalLineItem.Code)+" has changed since it was added to your cart.",l.push(h)),l.length>0?this.props.dispatch(fr.ApplicationActions.showNotification(l.join("\n"))):this.props.dispatch(fr.ApplicationActions.showNotification("The line item was successfully updated.")),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(p)),[3,9];case 8:return m=f.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(m.message)),[3,9];case 9:return this.props.onClose(),[3,12];case 10:return[4,this.addLineItemToOrderGroup()];case 11:f.sent()&&this.props.onClose(),f.label=12;case 12:return[2]}}))}))},r.lineItemHasChangedPrice=function(e,t){var r=t.Forms[0];if(t.IsDraft)for(var n=0;n=0&&this.setState({placedPrice:t},this.validateForm),[2]}))}))},r.updateDiscountPrice=function(e){return Wt(r,void 0,void 0,(function(){var t;return qt(this,(function(r){return t=Number(e.target.value),!isNaN(t)&&t>=0&&this.setState({discountValue:t},this.validateForm),[2]}))}))},r.updateDiscountDescription=function(e){return Wt(r,void 0,void 0,(function(){return qt(this,(function(t){return this.setState({discountDescription:e.target.value}),[2]}))}))},r.quantityChangeHandler=function(e){return Wt(r,void 0,void 0,(function(){var t;return qt(this,(function(r){return t=Number(e.target.value),isNaN(t)||this.setState({quantity:t},this.validateForm),[2]}))}))},r.quantityBluredHandler=function(){return Wt(r,void 0,void 0,(function(){var e,t,r;return qt(this,(function(n){switch(n.label){case 0:return[4,this.validateForm()];case 1:if(!n.sent())return[2];e=this.state.editMode?this.props.lineItem.Code:this.state.entrySelectedSuggestion.Code,n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.getPlacedPrice(e,this.state.quantity)];case 3:return(t=n.sent())&&t.Amount!==this.state.defaultPlacedPrice&&this.setState({defaultPlacedPrice:t.Amount,placedPrice:t.Amount},this.validateForm),[3,5];case 4:return r=n.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(r.message)),[3,5];case 5:return[2]}}))}))},r.getPlacedPrice=function(e,t){return Wt(r,void 0,void 0,(function(){var r;return qt(this,(function(n){switch(n.label){case 0:if(!e)return[2,null];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,ln.OrderGroup.getPlacedPrice(e,t,this.props.orderGroup.MarketId,this.props.orderGroup.Currency,this.props.orderGroup.Customer.Id)];case 2:return[2,n.sent().data];case 3:return r=n.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(r.message)),404===r.response.status&&this.setState({isReadonly:!0}),[2,null];case 4:return[2]}}))}))},r.customPropertyChangedHandler=function(e){return Wt(r,void 0,void 0,(function(){var t;return qt(this,(function(r){return(t=this.state.properties.findIndex((function(t){return t.Name===e.Name})))>=0&&(this.state.properties[t]=Bt({},e),this.setState({properties:jt(this.state.properties)}),this.forceUpdate()),[2]}))}))},void 0!==r.props.lineItem.LineItemId){if(r.state.editMode=!0,r.state.quantity=r.props.lineItem.Quantity,r.state.placedPrice=r.props.lineItem.PlacedPrice.Amount,r.state.shipmentId=r.props.orderForm.Shipments[r.props.lineItem.ShipmentNo-1].ShipmentId,r.props.lineItem.ManualDiscount){var n=r.props.lineItem.ManualDiscount;r.state.discountType=n.ManualDiscountType,r.state.discountValue=n.DiscountValue,r.state.discountDescription=n.Description}r.state.properties=jt(r.props.lineItem.Properties),r.state.originalLineItem=JSON.parse(JSON.stringify(r.props.lineItem))}else r.state.shipmentId=r.props.orderForm.Shipments[0].ShipmentId;return r}return Vt(n,e),n.prototype.componentDidMount=function(){var e=this;this.props.lineItem.Code&&this.props.lineItem.IsEntryAvailable?this.getPlacedPrice(this.props.lineItem.Code,this.state.quantity).then((function(t){t?e.setState({defaultPlacedPrice:t.Amount,showDialog:!0}):e.setState({showDialog:!0})})):this.setState({showDialog:!0}),this.initData()},n.prototype.addLineItemToOrderGroup=function(){return Wt(this,void 0,void 0,(function(){var e,t,r,n,s,i;return qt(this,(function(o){switch(o.label){case 0:e=this.createLineItemPostData(this.state.entrySelectedSuggestion,this.state.quantity,this.state.placedPrice),o.label=1;case 1:return o.trys.push([1,8,,9]),this.props.orderGroup.IsDraft?[4,ln.OrderGroup.initLineItem(this.props.orderGroup.Currency,this.props.orderGroup.MarketId,this.props.orderGroup.Customer.Id,e)]:[3,4];case 2:return t=o.sent(),r=JSON.parse(JSON.stringify(this.props.orderGroup)),t.forEach((function(e){var t=r.Forms[0].Shipments[0].LineItems.find((function(t){return t.Code===e.Code}));t?t.Quantity+=e.Quantity:r.Forms[0].Shipments[0].LineItems.push(e)})),[4,ln.OrderGroup.calculateOrder(r)];case 3:return(r=o.sent()).ValidationMessages.length>0&&this.props.dispatch(fr.ApplicationActions.showNotification(r.ValidationMessages.join("\n"))),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(r)),[3,7];case 4:return[4,ln.OrderGroup.addLineItemToOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId,this.props.orderForm.OrderFormId,this.state.shipmentId,e)];case 5:return n=o.sent(),this.isValidationMessagesReturned(n)&&this.props.dispatch(fr.ApplicationActions.showNotification(n.data.join("\n"))),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 6:s=o.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(s)),o.label=7;case 7:return[3,9];case 8:return i=o.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(i.message)),[2,!1];case 9:return[2,!0]}}))}))},n.prototype.getExistedLineItem=function(e){var t,r=this,n=this.props.orderForm.Shipments.find((function(e){return e.ShipmentId===r.state.shipmentId}));return n&&(t=n.LineItems.find((function(t){return!t.IsGift&&t.Code===e}))),t},n.prototype.isValidationMessagesReturned=function(e){return e&&e.data&&Array.isArray(e.data)&&e.data.length>0},n.prototype.createLineItemPostData=function(e,t,r){return{code:e.Code,displayName:e.DisplayName,quantity:t,placedPrice:r}},n.prototype.validateForm=function(){return Wt(this,void 0,void 0,(function(){var e,t,r;return qt(this,(function(n){switch(n.label){case 0:e=!0,t={},n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.validationSchema.validate({Quantity:this.state.quantity,PlacedPrice:this.state.placedPrice,DiscountValue:this.state.discountValue,DiscountType:this.state.discountType,ShipmentId:this.state.shipmentId,EditMode:this.state.editMode,LineItemCode:this.state.entrySelectedSuggestion.Code},{strict:!0,abortEarly:!1})];case 2:return n.sent(),[3,4];case 3:return r=n.sent(),e=!1,r.inner.map((function(e){t[e.path]=e.message})),[3,4];case 4:return this.setState({errors:t}),[2,e]}}))}))},n.prototype.updateLineItemProperties=function(){return Wt(this,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:if(this.props.orderGroup.IsDraft)return this.setState({lineItem:Bt(Bt({},this.state.lineItem),{Properties:this.state.properties})}),[2];e=0,r.label=1;case 1:if(!(e0?r[0].shipmentId:-1;e=this.state.editMode?t:r,this.setState({shipmentOptions:e}),this.state.editMode||n===this.state.shipmentId||this.setState({shipmentId:n})},n.prototype.render=function(){var e=this,n={title:this.state.isReadonly?"Line Item Details":this.state.editMode?"Edit Line Item":"Add Line Item",open:!0,onClose:function(){e.props.onClose()},closeLabel:this.state.isReadonly?"Close":"Cancel"};return this.state.isReadonly||(n.okLabel=this.state.editMode?"Save":"Add Line Item",n.onOK=function(){return Wt(e,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.submitForm()];case 1:return e.sent(),[2]}}))}))}),t(Cn,Bt({},n),this.state.showDialog&&t(Ee,{instantValidate:!0,onSubmit:function(){return null},ref:function(t){return e.customPropertiesForm=t}},t(l,{container:!0,spacing:16,style:{marginTop:"5px"}},t(l,{item:!0,xs:12},this.state.editMode?t(h,{label:"Product variant",name:"productName",variant:"outlined",value:this.props.lineItem.DisplayName,fullWidth:!0,disabled:!0}):t(so,{onSelected:function(t){e.handleEntrySearchSelected(t)},onSearchFieldChanged:function(t){e.handleEntrySearchChanged(t)}}),t(m,{variant:"caption",color:"error"},this.state.errors.LineItemCode)),this.props.orderForm.Shipments.length>1&&t(l,{item:!0,xs:12},t(Jr,{label:"Shipment",fullWidth:!0,value:this.state.shipmentId,options:this.state.shipmentOptions,disabled:this.state.editMode,required:!0,onChange:function(t){e.setState({shipmentId:t})}}),t(m,{variant:"caption",color:"error"},this.state.errors.ShipmentId)),t(l,{item:!0,xs:12},t(h,{label:"Quantity",name:"Quantity",type:"number",variant:"outlined",value:this.state.quantity,onChange:this.quantityChangeHandler,onBlur:this.quantityBluredHandler,fullWidth:!0,error:!!this.state.errors.Quantity,helperText:this.state.errors.Quantity,required:!0,disabled:this.state.isReadonly,inputProps:{step:.1,min:0}})),this.state.editMode&&t(r,null,t(l,{item:!0,xs:6},t(h,{label:"Discount",name:"DiscountValue",type:"number",variant:"outlined",value:this.state.discountValue,onChange:this.updateDiscountPrice,fullWidth:!0,disabled:this.state.isReadonly||"Cart"===this.props.orderGroup.Type,inputProps:{min:0},error:!!this.state.errors.DiscountValue,helperText:this.state.errors.DiscountValue})),t(l,{item:!0,xs:6},t(Jr,{label:"Discount Type",value:this.state.discountType.toString(),options:[{label:"Percentage",value:"1"},{label:"Value",value:"2"}],onChange:function(t){e.setState({discountType:Number(t)},(function(){e.validateForm()}))},fullWidth:!0,disabled:this.state.isReadonly||"Cart"===this.props.orderGroup.Type})),t(l,{item:!0,xs:12},t(h,{label:"Discount Description",variant:"outlined",value:this.state.discountDescription,onChange:this.updateDiscountDescription,fullWidth:!0,disabled:this.state.isReadonly||"Cart"===this.props.orderGroup.Type}))),t(l,{item:!0,xs:12},t(h,{label:"Placed Price"+(this.props.orderGroup.Currency?"("+this.props.orderGroup.Currency+")":""),type:"number",name:"PlacedPrice",fullWidth:!0,variant:"outlined",value:this.state.placedPrice,onChange:this.updatePlacedPrice,error:!!this.state.errors.PlacedPrice,helperText:this.state.errors.PlacedPrice,inputProps:{min:0,step:.1},InputLabelProps:{shrink:!0},required:!0,disabled:this.state.isReadonly||"Cart"===this.props.orderGroup.Type||this.state.isBundle}),this.state.defaultPlacedPrice>=0&&this.state.defaultPlacedPrice!==this.state.placedPrice&&t(m,{variant:"caption",component:"h6"},"Default PlacedPrice is ",t("b",null,this.state.defaultPlacedPrice))),this.props.lineItem.Properties&&this.props.lineItem.Properties.map((function(r,n){return t(l,{item:!0,xs:12,key:n},t(js,{key:n,property:r,isReadonly:e.state.isReadonly||!r.IsEditable,onPropertyChanged:e.customPropertyChangedHandler}))})))))},n}(n),ao=u((function(e,t){var r=e.orderGroup.currentOrderGroup,n=r.Forms[e.orderGroup.selectedFormIndex];return Bt({orderGroup:r,orderForm:n},t)}))(oo),uo=function(){},co=function(e){function r(t){var r=e.call(this,t)||this;return r.handleReturnCommentChange=function(e){r.setState({returnComment:e.target.value})},r.state={isLoadingResource:!1,returnReasons:Array(),returnLineItems:Array(),returnComment:""},r}return Vt(r,e),r.prototype.componentWillMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return this.initReturnLineItem(),[4,this.getData()];case 1:return e.sent(),[2]}}))}))},r.prototype.initReturnLineItem=function(){var e=this.props.lineItems.map((function(e){return Bt(Bt({},e),{OriginalLineItemId:e.LineItemId,ReturnQuantity:e.ReturnableQuantity,ReturnReason:""})}));this.setState({returnLineItems:e})},r.prototype.getData=function(){return Wt(this,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return this.setState({isLoadingResource:!0}),[4,ln.OrderGroup.getReturnReasons()];case 1:return e=r.sent(),t=e.map((function(e){return{label:e.Label,value:e.Label}})),this.setState({returnReasons:t,isLoadingResource:!1}),[2]}}))}))},r.prototype.onCloseDialog=function(){this.props.closeView()},r.prototype.onCreateReturn=function(){return Wt(this,void 0,void 0,(function(){var e,t,r;return qt(this,(function(n){switch(n.label){case 0:if(!this.validate())return this.props.dispatch(fr.ApplicationActions.showNotification("Please input valid return information!")),[2];(e=new uo).LineItems=this.state.returnLineItems,e.ReturnComment=this.state.returnComment,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,ln.OrderGroup.createReturn(this.props.orderGroupId,e)];case 2:return(t=n.sent()).ReturnFormId&&as.push(Er+"/"+this.props.orderGroupId+"/returns/"+t.ReturnFormId),this.props.closeView(),[3,4];case 3:return r=n.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(r.message)),[3,4];case 4:return[2]}}))}))},r.prototype.validate=function(){return!!this.state.returnLineItems.every((function(e){return e.ReturnQuantity>0&&""!==e.ReturnReason}))},r.prototype.render=function(){var e=this;return t(Cn,{title:"Create Return",open:!0,large:!0,onClose:function(){e.props.closeView()},onOK:function(){return Wt(e,void 0,void 0,(function(){return qt(this,(function(e){return this.onCreateReturn(),[2]}))}))},okLabel:"Create",closeLabel:"Cancel"},t($,{container:!0,spacing:16,direction:"column"},!this.state.isLoadingResource&&this.state.returnLineItems.map((function(r,n){return t($,{item:!0,key:n},t($,{container:!0,direction:"row",key:n,spacing:8},t($,{item:!0,xs:7},t($,{container:!0,direction:"row"},t($,{item:!0,xs:2},t(Ji,Bt({},r))),t($,{item:!0,xs:10},t(m,{variant:"body1",color:"inherit"},r.DisplayName),t($,{container:!0,direction:"row"},t($,{item:!0,xs:6},t(m,{variant:"body2",color:"inherit",align:"left"},r.Code)),t($,{item:!0,xs:6},t(m,{variant:"body2",color:"inherit",align:"right"},"Shipment No: ",r.ShipmentNo)))))),t($,{item:!0,xs:2},t(Lt,{outlined:!0,style:{width:"100%"},label:"Return Quantity"},t(Mt,{type:"number",step:"0.01",max:r.ReturnableQuantity,min:0,value:r.ReturnQuantity.toString(),onChange:function(t){r.ReturnQuantity=Number.parseFloat(t.currentTarget.value),e.setState({returnLineItems:e.state.returnLineItems})}}))),t($,{item:!0,xs:3},t(Jr,{label:"Return Reason",fullWidth:!0,value:r.ReturnReason,options:e.state.returnReasons,required:!0,onChange:function(t){r.ReturnReason=t,e.setState({returnLineItems:e.state.returnLineItems})}}))))}))),t($,{container:!0,direction:"column",spacing:8},t($,{item:!0},t(m,null,"Comment")),t($,{item:!0},t(Lt,{textarea:!0,label:"Comment",size:5,fullWidth:!0},t(Mt,{style:{height:"100px"},maxLength:1024,value:this.state.returnComment,onChange:this.handleReturnCommentChange})))))},r}(n),po=p((function(e){e.spacing;return c({})}))(u((function(e,t){return Bt({},t)}))(co)),lo={productRemoved:{textDecorationLine:"line-through"}},ho=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={isReturnDialogOpen:!1,selectedLineItems:[],isAddDialogOpen:!1,currentLineItem:{},contextAction:{isDeleteButtonVisible:!0,isCreateReturnButtonVisible:!1},delConfirmDialog:{isOpen:!1,onConfirm:function(){return null}}},r.tableInstance={},r.columns=[{name:"NAME",render:function(e,r){return t(l,{container:!0,direction:"row",alignItems:"center",wrap:"nowrap",spacing:8},t(l,{item:!0},t(Ji,Bt({},e))),t(l,{item:!0,style:e.IsEntryAvailable?void 0:lo.productRemoved},t(We,{variant:"body2",color:"inherit"},e.DisplayName),t(We,null,e.Code)))}},{name:"PLACED PRICE",right:!0,render:function(e,r){return t(We,null,e.PlacedPrice.Amount," ",e.PlacedPrice.Currency)}},{name:"SHIPMENT NO",selector:"ShipmentNo",right:!0},{name:"SHIPMENT STATUS",selector:"ShipmentStatus",render:function(e,t){return Qs(e.ShipmentStatus)}},{name:"TOTAL DISCOUNT",right:!0,render:function(e,r){var n,s,i;return t(We,null,null===(n=e.DiscountTotal)||void 0===n?void 0:n.Amount.toFixed(null===(s=e.DiscountTotal)||void 0===s?void 0:s.Fractions)," ",null===(i=e.DiscountTotal)||void 0===i?void 0:i.Currency)}},{name:"QUANTITY",selector:"Quantity",right:!0},{name:"TOTAL",right:!0,render:function(e,r){var n,s,i;return t(We,null,null===(n=e.DiscountedPrice)||void 0===n?void 0:n.Amount.toFixed(null===(s=e.DiscountedPrice)||void 0===s?void 0:s.Fractions)," ",null===(i=e.DiscountedPrice)||void 0===i?void 0:i.Currency)}},{width:50,render:function(e,n){var s=new Array;return r.isEditableLineItem(e)&&!e.IsGift&&e.IsEntryAvailable?(s.push({title:"Edit",clickHandler:function(t){r.setState({isAddDialogOpen:!0,currentLineItem:e})}}),s.push({title:"Delete",clickHandler:function(e){var t={isOpen:!0,onConfirm:function(){r.deleteLineItems([r.state.currentLineItem])}};r.setState({currentLineItem:e,delConfirmDialog:t})}})):s.push({title:"View",clickHandler:function(t){r.setState({isAddDialogOpen:!0,currentLineItem:e})}}),e.ReturnableQuantity>0&&s.push({title:"Create Return",clickHandler:function(e){r.openReturnDialog([e])}}),0===s.length?null:t(Ci,{actions:s,rowData:e,rowIndex:n})}}],r.deleteLineItems=function(e){return Wt(r,void 0,void 0,(function(){var t,r,n,s,i,o;return qt(this,(function(a){switch(a.label){case 0:return this.setState({delConfirmDialog:{isOpen:!1}}),this.props.orderGroup.IsDraft?(t=JSON.parse(JSON.stringify(this.props.orderGroup)),r=e.map((function(e){return e.Code})),t.Forms[0].Shipments[0].LineItems=t.Forms[0].Shipments[0].LineItems.filter((function(e){return-1===r.indexOf(e.Code)})),[4,ln.OrderGroup.calculateOrder(t)]):[3,2];case 1:return t=a.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(t)),[3,11];case 2:n=0,a.label=3;case 3:if(!(n '+s.message)),[3,8];case 7:return n++,[3,3];case 8:return a.trys.push([8,10,,11]),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 9:return i=a.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(i)),[3,11];case 10:return o=a.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(o.message)),[3,11];case 11:return[2]}}))}))},r.openReturnDialog=function(e){r.setState({isReturnDialogOpen:!0,selectedLineItems:e})},r.handleOnRowSelected=function(e,t){return Wt(r,void 0,void 0,(function(){var e,t,r,n,s;return qt(this,(function(i){for(e=!0,t=!0,r=this.tableInstance.getSelectedRows(),n=0;n0&&t.buttons&&t.buttons.push({title:"Add Line Items",clickHandler:function(e){r.setState({isAddDialogOpen:!0,currentLineItem:{}})}});e.toolbar=t;var n=new Array;return!r.props.isReadonly&&r.state.contextAction.isDeleteButtonVisible&&n.push({title:"Delete",clickHandler:function(e){var t={isOpen:!0,onConfirm:function(){var e=r.tableInstance.getSelectedRows();r.deleteLineItems(e),r.tableInstance.setHeaderRowChecked(!1)}};r.setState({delConfirmDialog:t})}}),r.state.contextAction.isCreateReturnButtonVisible&&n.push({title:"Create Return",clickHandler:function(e){var t=r.tableInstance.getSelectedRows();r.openReturnDialog(t),r.tableInstance.setHeaderRowChecked(!1)}}),n.length>0&&(e.contextActions=n),e},r}return Vt(r,e),r.prototype.componentDidMount=function(){var e=this.props.lineItems.filter((function(e){return!e.IsEntryAvailable})).map((function(e){return e.Code}));if(e.length>0){var t="You can not edit line items "+e.join(", ")+" because their entries have been removed or their code have been changed.";this.props.dispatch(fr.ApplicationActions.showNotification(t))}},r.prototype.isEditableLineItem=function(e){return!e.Code||!!e.IsEntryAvailable&&(!e.IsGift&&this.isShipmentEditable(e.ShipmentStatus))},r.prototype.render=function(){var e=this,r=this.buildTableProps();return t("div",null,t(We,{variant:"h6",gutterBottom:!0},"Line Items"),t(Us,Bt({},r)),this.state.isAddDialogOpen&&t(ao,{onClose:function(){return e.setState({isAddDialogOpen:!1})},lineItem:this.state.currentLineItem,isReadonly:!this.isEditableLineItem(this.state.currentLineItem)}),this.state.delConfirmDialog.isOpen&&t(Sn,{title:"Delete Line Item",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:this.state.delConfirmDialog.onConfirm,onClose:function(){e.setState({delConfirmDialog:{isOpen:!1}})}},t(We,{variant:"body1"},"Are you sure you want to delete?")),this.state.isReturnDialogOpen&&t(po,{lineItems:this.state.selectedLineItems,orderGroupId:this.props.orderGroup.OrderGroupId,closeView:function(){return e.setState({isReturnDialogOpen:!1})}}))},r}(n);function mo(e){if(!e.Shipments||0===e.Shipments.length)return[];for(var t=new Array,r=function(r){var n=e.Shipments[r];n.LineItems.forEach((function(e){e.ShipmentNo=r+1,e.ShipmentStatus=n.OrderShipmentStatus.Name,t.push(e)}))},n=0;n0)&&t($,{item:!0},t(Hi,{payments:this.props.orderForm.Payments})))},r}(n),yo=z((function(e){e.palette,e.spacing,e.breakpoints;return c({})}))(u((function(e,t){var r=e.orderGroup.currentOrderGroup;return{orderGroupId:r.OrderGroupId,orderForm:t.orderForm,orderGroupType:r.Type,classes:t.classes,isReadonly:li(r),isCreateNewOrder:r.IsDraft}}))(go)),vo=function(e){function n(t){var r=e.call(this,t)||this;r.state={selectedOrderTabIndex:0,showCancelPaymentPlanConfirm:!1},r.orderTabNames=new Array,r.closeOrderGroupView=function(){r.props.dispatch(fr.ApplicationActions.closeOrderGroupView()),r.props.dispatch(fr.ContactActions.setCurrentContact(null)),r.props.dispatch(fr.ContactActions.setCurrentAddress(null)),r.props.dispatch(fr.PaymentActions.hideAcceptPaymentForm()),r.props.dispatch(fr.PaymentActions.setPaymentMethodId("")),r.props.dispatch(fr.PaymentActions.setPayment(null)),r.props.dispatch(fr.PaymentActions.setBillingAddress(null)),r.props.dispatch(fr.PaymentActions.setBillingAddressDropdownIsExpanded(!1)),r.props.dispatch(fr.OrderGroupActions.setPaymentPlanSetting({}))},r.orderTabIndexChangedHandler=function(e){return Wt(r,void 0,void 0,(function(){var t;return qt(this,(function(r){return this.setState({selectedOrderTabIndex:e}),(t=new URLSearchParams(as.location.search)).set("tab",this.orderTabNames[e].key),as.replace(as.location.pathname+"?"+t.toString()),[2]}))}))},r.customPropertyChangedHandler=function(e){return Wt(r,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,ln.MetaField.updateOrderGroupMetaFields(this.props.orderGroup.OrderGroupId,this.props.orderGroup.Type,e)];case 1:return n.sent(),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 2:return t=n.sent(),this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(t)),[3,4];case 3:return r=n.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(r.message)),[3,4];case 4:return[2]}}))}))},r.convertCartToOrderHandler=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),hi(this.props.orderGroup)?[4,ln.Cart.convertToPurchaseOrder(this.props.orderGroup.OrderGroupId)]:[3,2];case 1:return e=r.sent(),as.replace(Er+"/"+e.OrderGroupId),us(Mr,wr+"?type=Order"),[3,3];case 2:this.props.dispatch(fr.ApplicationActions.showNotification("Cannot convert an empty cart to purchase order.")),r.label=3;case 3:return[3,5];case 4:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},r.convertCartToPaymentPlanHandler=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),hi(this.props.orderGroup)?[4,ln.Cart.convertToPaymentPlan(this.props.orderGroup.OrderGroupId)]:[3,2];case 1:return e=r.sent(),as.replace(Lr+"/"+e.OrderGroupId),us(kr,wr+"?type=PaymentPlan"),[3,3];case 2:this.props.dispatch(fr.ApplicationActions.showNotification("Cannot convert an empty cart to payment plan.")),r.label=3;case 3:return[3,5];case 4:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},r.convertPaymentPlanToOrderHandler=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),hi(this.props.orderGroup)?[4,ln.PaymentPlan.convertToPurchaseOrder(this.props.orderGroup.OrderGroupId)]:[3,2];case 1:return e=r.sent(),as.replace(Er+"/"+e.OrderGroupId),us(Mr,Lr+"/"+this.props.orderGroup.OrderGroupId),[3,3];case 2:this.props.dispatch(fr.ApplicationActions.showNotification("Cannot convert an empty payment plan to purchase order.")),r.label=3;case 3:return[3,5];case 4:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},r.cancelPaymentPlanHandler=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:this.setState({showCancelPaymentPlanConfirm:!1}),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,ln.PaymentPlan.cancelPaymentPlan(this.props.orderGroup.OrderGroupId)];case 2:return r.sent(),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroupType,this.props.orderGroupId)];case 3:return e=r.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(e)),[3,5];case 4:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},r.loadPaymentMethods=function(){return Wt(r,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return[4,ln.PaymentMethod.getPaymentMethods(this.props.orderGroup.MarketId)];case 1:return e=t.sent(),this.props.dispatch(fr.PaymentActions.setPaymentMethods(e)),[2]}}))}))},r.loadCurrencies=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,ln.Currency.getCurrencies(this.props.orderGroup.MarketId)];case 1:return e=r.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrencies(e)),[3,3];case 2:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.initOrderTabs(t);var n=new URLSearchParams(as.location.search).get("tab");if(n){var s=r.orderTabNames.findIndex((function(e){return e.key===n}));s>0&&(r.state.selectedOrderTabIndex=s)}return r}return Vt(n,e),n.prototype.componentDidUpdate=function(){this.initOrderTabs(this.props)},n.prototype.initOrderTabs=function(e){var t=this;this.orderTabNames=[],this.orderTabNames.push({key:"summary",name:"Summary"}),this.orderTabNames.push({key:"details",name:"Form Details "}),"Order"===e.orderGroupType&&this.orderTabNames.push({key:"return",name:"Return & Exchange"}),this.orderTabNames.push({key:"contact",name:"Contact Details"}),"PaymentPlan"===e.orderGroupType&&(this.orderTabNames.push({key:"plansettings",name:"Settings"}),this.orderTabNames.push({key:"orders",name:"Orders"})),"Order"===e.orderGroupType&&this.props.orderDetailExtraTabs&&this.props.orderDetailExtraTabs.map((function(e,r){t.orderTabNames.push({key:"extraTab_"+r,name:e.title})})),"Cart"===e.orderGroupType&&this.props.cartDetailExtraTabs&&this.props.cartDetailExtraTabs.map((function(e,r){t.orderTabNames.push({key:"extraTab_"+r,name:e.title})})),"PaymentPlan"===e.orderGroupType&&this.props.paymentPlanExtraTabs&&this.props.paymentPlanExtraTabs.map((function(e,r){t.orderTabNames.push({key:"extraTab_"+r,name:e.title})}))},n.prototype.componentWillMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.getData()];case 1:return e.sent(),[2]}}))}))},n.prototype.shouldComponentUpdate=function(e,t){var r=this;return e.orderGroupId!==this.props.orderGroupId&&(as.push(ln.OrderGroup.getOrderGroupRouting(e.orderGroupType)+"/"+e.orderGroupId),setTimeout((function(){r.getData()}),200)),!0},n.prototype.getData=function(){return Wt(this,void 0,void 0,(function(){var e,t,r,n;return qt(this,(function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),[4,ln.OrderGroup.getSingleOrderGroup(this.props.orderGroupType,this.props.orderGroupId)];case 1:return e=s.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(e)),e.ValidationMessages.length>0&&this.props.dispatch(fr.ApplicationActions.showNotification(e.ValidationMessages.join(", "))),e.Customer.IsAnonymous?[3,3]:[4,ln.Contact.get(e.Customer.Id)];case 2:t=s.sent(),this.props.dispatch(fr.ContactActions.setCurrentContact(t)),s.label=3;case 3:return this.loadCurrencies(),[4,ln.Shipment.getShippingMethods()];case 4:return r=s.sent(),this.props.dispatch(fr.ShipmentActions.setShippingMethods(r)),"Cart"!==this.props.orderGroup.Type&&this.loadPaymentMethods(),[3,6];case 5:return n=s.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(n.message)),404===n.response.status&&as.replace("/?type="+this.props.orderGroupType),[3,6];case 6:return[2]}}))}))},n.prototype.closeView=function(){var e=new URLSearchParams(as.location.search).get("returnUrl"),t=void 0;if(e)return as.push(e),void this.closeOrderGroupView();switch(this.props.orderGroupType){case"Order":t=ds(Mr);break;case"PaymentPlan":t=ds(kr);break;default:t=ds(Fr)}void 0!==t?as.push(t):as.push("/"),this.closeOrderGroupView()},n.prototype.render=function(){var e,n,s=this,i=this.orderTabNames[this.state.selectedOrderTabIndex].key,o=function(){return t(r,null)},a=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,u=null===(n=this.props.extendUI)||void 0===n?void 0:n.bottomPlaceHolder;if(i.startsWith("extraTab_")){var d=parseInt(i.substring(i.lastIndexOf("_")+1,i.length),10);"Order"===this.props.orderGroupType&&this.props.orderDetailExtraTabs&&(o=this.props.orderDetailExtraTabs[d].render),"Cart"===this.props.orderGroupType&&this.props.cartDetailExtraTabs&&(o=this.props.cartDetailExtraTabs[d].render),"PaymentPlan"===this.props.orderGroupType&&this.props.paymentPlanExtraTabs&&(o=this.props.paymentPlanExtraTabs[d].render)}return this.props.orderGroup&&t("div",null,t(pi,null),t(Nn,{closeView:function(){return s.closeView()},title:("PaymentPlan"===this.props.orderGroupType?"Payment Plan":this.props.orderGroupType)+" Details",showDialogActions:!0},a&&t(a,{Id:this.props.orderGroupId,className:"top-placeholder"}),t($,{container:!0,direction:"column",spacing:8},t($,{item:!0},"Order"===this.props.orderGroup.Type&&t(yi,null),"Cart"===this.props.orderGroup.Type&&t($,{container:!0,justify:"flex-end",spacing:8},t($,{item:!0},t(se,{outlined:!0,onClick:this.convertCartToOrderHandler,id:"convertToPurchaseOrder"},"Convert to purchase order")),t($,{item:!0},t(se,{outlined:!0,onClick:this.convertCartToPaymentPlanHandler,id:"convertToPaymentPlan"},"Convert to payment plan"))),"PaymentPlan"===this.props.orderGroup.Type&&t($,{container:!0,justify:"flex-end",spacing:8},this.props.orderGroup.CanConvertPaymentPlanToPurchaseOrder&&t($,{item:!0},t(se,{outlined:!0,onClick:this.convertPaymentPlanToOrderHandler,id:"convertPaymenPlanToPurchaseOrder"},"Create First Purchase Order")),this.props.orderGroup.OrderStatus===oi.InProgress&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return s.setState({showCancelPaymentPlanConfirm:!0})},id:"cancelPaymentPlan"},"Cancel Payment Plan")))),t($,null,t(Xe,{position:"static",color:"default"},t(fe,{activeIndex:this.state.selectedOrderTabIndex,handleActiveIndexUpdate:this.orderTabIndexChangedHandler},this.orderTabNames.map((function(e){return t(ge,{key:e.key},e.name)})))),t(b,null,t(O,null,t($,null,"summary"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&("Cart"===this.props.orderGroupType?t(ni,{orderGroup:this.props.orderGroup}):t(ti,{orderGroup:this.props.orderGroup,isReadonly:this.props.isReadonly})),"details"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t($,null,t(yo,{orderForm:this.props.orderGroup.Forms[0]})),"return"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&"Order"===this.props.orderGroup.Type&&t($,null,t(Ai,{orderGroupId:this.props.orderGroupId})),"contact"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t($,null,t(si,{orderGroup:this.props.orderGroup})),"plansettings"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&"PaymentPlan"===this.props.orderGroup.Type&&t($,null,t(ci,{editMode:!1,paymentPlan:this.props.orderGroup})),"orders"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&"PaymentPlan"===this.props.orderGroup.Type&&t($,null,t(Oi,{paymentPlan:this.props.orderGroup})),o&&t(o,{Id:this.props.orderGroupId,className:"extra-tab-content"})))))),u&&t(u,{Id:this.props.orderGroupId,className:"bottom-placeholder"}),this.state.showCancelPaymentPlanConfirm&&t(Sn,{title:"Cancel Payment Plan",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:this.cancelPaymentPlanHandler,onClose:function(){s.setState({showCancelPaymentPlanConfirm:!1})}},t(m,{variant:"body1"},"Are you sure you want to cancel this payment plan?"))))},n}(n),Co=function(e,t){var r,n,s,i;switch(e){case"Order":i=null===(r=t.setting.pageConfig.orderDetail)||void 0===r?void 0:r.extendUI;break;case"Cart":i=null===(n=t.setting.pageConfig.cartDetail)||void 0===n?void 0:n.extendUI;break;case"PaymentPlan":i=null===(s=t.setting.pageConfig.paymentPlanDetail)||void 0===s?void 0:s.extendUI}return i},So=z((function(){return c({})}))(u((function(e,t){var r,n,s,i,o,a,u,d,c,p;return{orderGroupType:t.orderGroupType,orderGroupId:t.orderGroupId,orderGroup:e.orderGroup.currentOrderGroup,rowsPerPage:e.application.rowsPerPage,orderStatuses:e.orderGroup.orderStatuses,currencies:e.orderGroup.currencies,isReadonly:li(e.orderGroup.currentOrderGroup),selectedEntry:e.orderGroup.selectedEntry,hasReadonlyOrderStatus:(p=e.orderGroup.currentOrderGroup,!!p&&("Cart"===p.Type||p.OrderStatus===oi.Cancelled||p.OrderStatus===oi.Completed)),classes:t.classes,orderDetailExtraTabs:null===(s=null===(n=null===(r=e.setting.pageConfig)||void 0===r?void 0:r.orderDetail)||void 0===n?void 0:n.config)||void 0===s?void 0:s.extraTabs,cartDetailExtraTabs:null===(a=null===(o=null===(i=e.setting.pageConfig)||void 0===i?void 0:i.cartDetail)||void 0===o?void 0:o.config)||void 0===a?void 0:a.extraTabs,paymentPlanExtraTabs:null===(c=null===(d=null===(u=e.setting.pageConfig)||void 0===u?void 0:u.paymentPlanDetail)||void 0===d?void 0:d.config)||void 0===c?void 0:c.extraTabs,extendUI:Co(t.orderGroupType,e)}}))(vo)),Io=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Vt(r,e),r.prototype.render=function(){return t(So,Bt({},this.props))},r}(n),bo=function(e){return t($,{container:!0,justify:"flex-end",direction:"row",alignItems:"center",spacing:8},t($,{item:!0},t(We,{style:{fontWeight:"normal"},variant:e.variant},e.label)),t($,{item:!0},t(Rs,{amount:e.amount,align:"right",variant:e.variant,style:{fontWeight:"bold",paddingRight:16}})))},Ao=function(e){function r(t){var r=e.call(this,t)||this;return r.state={loaded:!1,errorMessage:"",refundAmountMessage:"",paymentMethodOptions:[],currentPayment:{},returnOrderSummary:{ItemTotal:0,InvalidatedDiscountsTotal:0,ExchangeTotal:0,RefundAmount:0,ExistingPayments:[]},refundAmount:0,maxRefundAmount:0},r.refundForm={},r.existPaymentHandleChange=function(e){var t=r.state.returnOrderSummary.ExistingPayments[e];r.setState({currentPayment:t,refundAmount:Math.min(r.state.maxRefundAmount,t.Amount.Amount)})},r.refundAmountHandlerChange=function(e,t){r.setState({refundAmount:Number(t)})},r.completeReturn=function(){return Wt(r,void 0,void 0,(function(){var e,t,r=this;return qt(this,(function(n){switch(n.label){case 0:if(""!==this.validateRefundForm())return[2];e=this.state.currentPayment,n.label=1;case 1:return n.trys.push([1,5,,6]),this.state.refundAmount>0?[4,ln.OrderGroup.createRefund(this.props.orderGroupId,this.props.orderGroup.Forms[0].OrderFormId,{existingPaymentId:e.PaymentId,amount:this.state.refundAmount})]:[3,3];case 2:n.sent(),n.label=3;case 3:return[4,ln.OrderGroup.completeReturn(this.props.orderGroupId,this.props.returnFormId).catch((function(e){r.setState({errorMessage:e.message})}))];case 4:return n.sent(),this.props.onClose(),as.go(0),[3,6];case 5:return t=n.sent(),this.setState({errorMessage:t.message}),[3,6];case 6:return[2]}}))}))},r.state.paymentMethodOptions=r.props.paymentMethods.map((function(e){return{label:e.Name,value:e.PaymentMethodId}})),r}return Vt(r,e),r.prototype.componentDidMount=function(){return Wt(this,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return[4,ln.OrderGroup.getRefundInfo(this.props.orderGroupId,this.props.returnFormId)];case 1:return(e=t.sent())&&this.setState({returnOrderSummary:Bt({},e.data),maxRefundAmount:e.data.RefundAmount,loaded:!0}),this.state.returnOrderSummary.ExistingPayments.length>0&&this.existPaymentHandleChange(0),[2]}}))}))},r.prototype.validateRefundForm=function(){var e="",t=this.state.currentPayment;return this.state.currentPayment?this.state.refundAmount>t.Amount.Amount&&(e="Total Refund Amount cannot exceed "+t.Amount.Amount):e="Please select Existing Payments!",this.setState({errorMessage:e}),e},r.prototype.render=function(){var e=this;return t(Cn,{open:!0,title:"Create Refund",okLabel:"OK",onOK:this.completeReturn,closeLabel:"Cancel",onClose:function(){e.props.onClose()}},this.state.loaded&&t(Ee,{instantValidate:!0,onSubmit:function(){return null},ref:function(t){return e.refundForm=t}},t(l,{container:!0,direction:"column",spacing:16},t(l,{item:!0},t("span",{style:{color:"red"}},this.state.errorMessage)),t(l,{item:!0},t(h,{variant:"outlined",type:"number",label:"Return Items ("+this.props.orderGroup.Currency+")",fullWidth:!0,disabled:!0,value:this.state.returnOrderSummary.ItemTotal})),t(l,{item:!0},t(h,{variant:"outlined",type:"number",label:"Invalidated Discounts ("+this.props.orderGroup.Currency+")",fullWidth:!0,disabled:!0,value:this.state.returnOrderSummary.InvalidatedDiscountsTotal})),t(l,{item:!0},t(h,{variant:"outlined",type:"number",label:"Exchange Total ("+this.props.orderGroup.Currency+")",fullWidth:!0,disabled:!0,value:this.state.returnOrderSummary.ExchangeTotal})),t(l,{item:!0},t(h,{variant:"outlined",type:"number",label:"Refund Total ("+this.props.orderGroup.Currency+")",fullWidth:!0,disabled:!0,value:this.state.maxRefundAmount})),t(l,{item:!0},this.state.returnOrderSummary.ExistingPayments.map((function(r,n){return t(l,{container:!0,key:n},t(l,{item:!0},t(l,{container:!0,alignItems:"center",spacing:8},t(l,{item:!0},t(_,{value:r.PaymentId,onChange:function(t){return e.existPaymentHandleChange(n)},checked:r.PaymentId===e.state.currentPayment.PaymentId,style:{marginLeft:"-12px"}})),t(l,{item:!0},t(m,null,r.PaymentMethodName+" ("+r.TransactionType+") \n - "+r.Amount.Amount+" "+e.props.orderGroup.Currency)))),e.state.currentPayment.PaymentId===r.PaymentId&&t(l,{item:!0,xs:12},t(l,{container:!0,spacing:16},t(l,{item:!0,xs:6},t(h,{variant:"outlined",type:"number",label:"Amount ("+e.props.orderGroup.Currency+")",fullWidth:!0,value:e.state.refundAmount,onChange:function(t){return e.refundAmountHandlerChange(r,t.target.value)},inputProps:{min:0,max:e.state.maxRefundAmount,step:.1}})),t(l,{item:!0,xs:6},t(Jr,{label:"Payment Method",options:e.state.paymentMethodOptions,fullWidth:!0,value:r.PaymentMethodId,disabled:!0})),t(l,{item:!0,xs:12,style:{marginTop:"-10px"}},e.state.refundAmount!==e.state.maxRefundAmount&&t("span",{style:{fontSize:"12px",color:"red"}},"The amount you are refunding is different from the suggested refund total")))))}))))))},r}(n),Oo=u((function(e,t){return Bt(Bt({},t),{paymentMethods:e.payment.paymentMethods,orderGroup:e.orderGroup.currentOrderGroup})}))(Ao),wo=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={confirmDialog:{isOpen:!1,title:"",message:"",closeButtonLabel:"",confirmButtonLabel:"",onConfirm:function(){return null}},isOpenRefundDialog:!1},t}return Vt(r,e),r.prototype.cancelReturn=function(){return Wt(this,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,ln.OrderGroup.cancelReturn(this.props.orderGroupId,this.props.returnOrderForm.OrderFormId)];case 1:return t.sent(),this.props.onUpdated(),[3,3];case 2:return e=t.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(e.message)),[3,3];case 3:return this.closeDialog(),[2]}}))}))},r.prototype.updateAcknowledgeReceiptItems=function(){return Wt(this,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,ln.OrderGroup.acknowledgeReceiptItems(this.props.orderGroupId,this.props.returnOrderForm.OrderFormId)];case 1:return t.sent(),this.props.onUpdated(),[3,3];case 2:return e=t.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(e.message)),[3,3];case 3:return this.closeDialog(),[2]}}))}))},r.prototype.closeDialog=function(){this.setState({confirmDialog:{isOpen:!1}})},r.prototype.showCancelConfirmDialog=function(){var e=this;this.setState({confirmDialog:{isOpen:!0,title:"Cancel Return",message:"Are you sure you want to cancel this return?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return e.cancelReturn()}}})},r.prototype.showAcknowledgeReceiptItemsConfirmDialog=function(){var e=this;this.setState({confirmDialog:{isOpen:!0,title:"Acknowledge Receipt Items",message:"Are you sure you want to acknowledge receipt items?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return e.updateAcknowledgeReceiptItems()}}})},r.prototype.canShowCancelButton=function(){return this.props&&this.props.returnOrderForm&&(this.props.returnOrderForm.Status.Code===Ii.AwaitingStockReturn||this.props.returnOrderForm.Status.Code===Ii.AwaitingCompletion)},r.prototype.canShowAcknowledgeButton=function(){return this.props&&this.props.returnOrderForm&&this.props.returnOrderForm.Status.Code===Ii.AwaitingStockReturn},r.prototype.canShowCompleteButton=function(){return this.props&&this.props.returnOrderForm&&this.props.returnOrderForm.Status.Code===Ii.AwaitingCompletion},r.prototype.canShowViewExchangeButton=function(){return this.props&&this.props.returnOrderForm&&this.props.returnOrderForm.ExchangeOrderId>0},r.prototype.canShowCreateExchangeButton=function(){return this.canShowCancelButton()&&this.props.returnOrderForm.ExchangeOrderId<=0},r.prototype.showCreateRefundDialog=function(){this.setState({isOpenRefundDialog:!0})},r.prototype.createExchangeOrder=function(){return Wt(this,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return[4,ln.OrderGroup.initExchangeOrder(this.props.orderGroupId)];case 1:return e=t.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(e)),us("previous_order_create"),as.push(Vr+"?returnFormId="+this.props.returnOrderForm.OrderFormId),[2]}}))}))},r.prototype.viewExchangeOrder=function(e){as.push(Er+"/"+e+"?returnUrl="+cs())},r.prototype.render=function(){var e=this;return t("div",null,t($,{container:!0,justify:"flex-end",spacing:8},this.canShowCompleteButton()&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.showCreateRefundDialog()}},"Complete Return")),this.canShowAcknowledgeButton()&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.showAcknowledgeReceiptItemsConfirmDialog()}},"Acknowledge Receipt Items")),this.canShowViewExchangeButton()&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.viewExchangeOrder(e.props.returnOrderForm.ExchangeOrderId)}},"View Exchange")),this.canShowCreateExchangeButton()&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.createExchangeOrder()}},"Create Exchange")),this.canShowCancelButton()&&t($,{item:!0},t(se,{outlined:!0,onClick:function(){return e.showCancelConfirmDialog()}},"Cancel Return"))),t(Cn,{open:this.state.confirmDialog.isOpen,title:this.state.confirmDialog.title,closeLabel:this.state.confirmDialog.closeButtonLabel,okLabel:this.state.confirmDialog.confirmButtonLabel,onOK:this.state.confirmDialog.onConfirm,onClose:function(){return e.closeDialog()}},t(m,{variant:"body1"},this.state.confirmDialog.message)),this.state.isOpenRefundDialog&&t(Oo,{onClose:function(){e.setState({isOpenRefundDialog:!1})},orderGroupId:this.props.orderGroupId,returnFormId:this.props.returnOrderForm.OrderFormId}))},r}(n),To=u((function(e,t){return Bt({},t)}))(wo),Do=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={returnLineItem:t.props.returnLineItem,returnReasons:Array(),isLoadingResource:!1,returnQuantity:t.props.returnLineItem.ReturnQuantity},t.handleReturnQuantityChange=function(e){isNaN(e.target.value)?t.setState({returnQuantity:0}):t.setState({returnQuantity:Number(e.target.value)})},t.handleReturnReasonChange=function(e){var r=Bt({},t.state.returnLineItem);r.ReturnReason=e,t.setState({returnLineItem:r})},t.update=function(){return Wt(t,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.state.returnQuantity>this.state.returnLineItem.Quantity?(this.props.dispatch(fr.ApplicationActions.showNotification("The return quantity must be less than or equal to available quantity.")),[2]):[4,ln.OrderGroup.updateReturnLineItem(this.props.orderGroupId,this.props.returnFormId,this.state.returnLineItem.LineItemId,this.state.returnQuantity,this.state.returnLineItem.ReturnReason)];case 1:return t.sent(),this.props.onUpdated&&this.props.onUpdated(),[3,3];case 2:return e=t.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(e.message)),[3,3];case 3:return[2]}}))}))},t}return Vt(r,e),r.prototype.componentWillMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,this.getData()];case 1:return e.sent(),[2]}}))}))},r.prototype.getData=function(){return Wt(this,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return this.setState({isLoadingResource:!0}),[4,ln.OrderGroup.getReturnReasons()];case 1:return e=r.sent(),t=e.map((function(e){return{label:e.Label,value:e.Label}})),this.setState({returnReasons:t,isLoadingResource:!1}),[2]}}))}))},r.prototype.render=function(){var e=t($,{container:!0,spacing:16},t($,{item:!0,xs:12,sm:12,md:12},t(Lt,{outlined:!0,label:"Display Name",style:{width:"100%"}},t(Mt,{readOnly:!0,disabled:!0,style:{width:"100%"},value:this.props.returnLineItem.DisplayName}))),t($,{item:!0,xs:12,sm:12,md:12},t(Lt,{outlined:!0,label:"Quantity",style:{width:"100%"}},t(Mt,{type:"number",readOnly:!0,disabled:!0,style:{width:"100%"},value:this.props.returnLineItem.Quantity}))),t($,{item:!0,xs:12,sm:12,md:12},t(Lt,{outlined:!0,onChange:this.handleReturnQuantityChange,style:{width:"100%"},label:"Return Quantity"},t(Mt,{type:"number",step:"0.01",min:"0",disabled:!this.props.isReturnEditable,readOnly:!this.props.isReturnEditable,max:this.state.returnLineItem.Quantity,value:this.state.returnQuantity}))),t($,{item:!0,xs:12,sm:12,md:12},t(Lt,{outlined:!0,type:"number",label:"Placed Price",style:{width:"100%"}},t(Mt,{type:"number",style:{width:"100%"},readOnly:!0,disabled:!0,value:this.props.returnLineItem.PlacedPrice.Amount}))),t($,{item:!0,xs:12,sm:12,md:12},!this.state.isLoadingResource&&t(Jr,{label:"Return Reason",disabled:!this.props.isReturnEditable,fullWidth:!0,value:this.state.returnLineItem.ReturnReason,options:this.state.returnReasons,required:!0,onChange:this.handleReturnReasonChange})));return this.props.isReturnEditable?t(Cn,{title:"Edit Return Line Item",open:!0,okLabel:"Save",onOK:this.update,onClose:this.props.onClose},e):t(Cn,{title:"View Return Line Item",open:!0,onClose:this.props.onClose},e)},r}(n),Po=u()(Do),Go=function(e){function r(r){var n=e.call(this,r)||this;return n.columns=[{name:"NAME",selector:"DisplayName",render:function(e){return t(l,{container:!0,direction:"row",className:n.props.classes.rowData},t(Ji,Bt({},e)),t(l,{item:!0},t(We,{noWrap:!0,variant:"body2",color:"inherit"},e.DisplayName),t(We,{variant:"body1",color:"inherit"},e.Code)))}},{name:"PLACED PRICE",selector:"PlacedPrice",right:!0,render:function(e){return t(Rs,{amount:e.PlacedPrice})}},{name:"PURCHASED QUANTITY",selector:"Quantity",right:!0},{name:"SHIPMENT NO",selector:"OriginalShipmentNo",right:!0},{name:"RETURN QUANTITY",selector:"ReturnQuantity",right:!0},{name:"TOTAL BEFORE RETURN",selector:"Total",right:!0,render:function(e){return t(Rs,{amount:e.Total})}},{name:"",width:10,render:function(e,r){var s=[];return n.isReturnEditable()?(s.push({title:"Edit",clickHandler:function(){return Wt(n,void 0,void 0,(function(){return qt(this,(function(t){return this.goToLineItemDetail(e),[2]}))}))}}),s.push({title:"Delete",clickHandler:function(){return Wt(n,void 0,void 0,(function(){return qt(this,(function(t){return this.setState({currentItem:e,isDeleteDialogOpen:!0}),[2]}))}))}})):s.push({title:"View",clickHandler:function(){return Wt(n,void 0,void 0,(function(){return qt(this,(function(t){return this.goToLineItemDetail(e),[2]}))}))}}),t(Ci,{actions:s,rowData:e,rowIndex:r})}}],n.handleReturnCommentChange=function(e){var t=Bt({},n.state.returnOrderForm);t.ReturnComment=e.target.value,n.setState({returnOrderForm:t})},n.closeDialog=n.closeDialog.bind(n),n}return Vt(r,e),r.prototype.loadPaymentMethods=function(e){return Wt(this,void 0,void 0,(function(){return qt(this,(function(t){switch(t.label){case 0:return[4,ln.PaymentMethod.getPaymentMethods(e)];case 1:return[2,t.sent()]}}))}))},r.prototype.componentWillMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return this.setState({isLoadingResource:!0}),[4,this.getData()];case 1:return e.sent(),this.setState({isLoadingResource:!1}),[2]}}))}))},r.prototype.getData=function(){return Wt(this,void 0,void 0,(function(){var e,t,r,n;return qt(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,ln.OrderGroup.getReturn(this.props.orderGroupId,this.props.returnFormId)];case 1:return e=s.sent(),this.setState({returnOrderForm:e}),[4,ln.OrderGroup.getSingleOrderGroup("Order",this.props.orderGroupId)];case 2:return t=s.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(t)),t.ValidationMessages.length>0&&this.props.dispatch(fr.ApplicationActions.showNotification(t.ValidationMessages.join(", "))),[4,this.loadPaymentMethods(t.MarketId)];case 3:return r=s.sent(),this.props.dispatch(fr.PaymentActions.setPaymentMethods(r)),[3,5];case 4:return n=s.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(n.message)),[3,5];case 5:return[2]}}))}))},r.prototype.cancelReturn=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,ln.OrderGroup.cancelReturn(this.props.orderGroupId,this.props.returnFormId)];case 1:return e.sent(),[4,this.getData()];case 2:return e.sent(),[2]}}))}))},r.prototype.closeView=function(){var e=Er+"/"+this.props.orderGroupId+"?tab=return";as.push(e)},r.prototype.closeDialog=function(){this.setState({lineItemDialogOpen:!1})},r.prototype.goToLineItemDetail=function(e){this.setState({lineItemDialogOpen:!0,returnLineItemSelected:e,isReturnEditable:this.isReturnEditable()})},r.prototype.deleteLineItem=function(e){return Wt(this,void 0,void 0,(function(){return qt(this,(function(t){switch(t.label){case 0:return this.setState({isLoadingResource:!0}),[4,ln.OrderGroup.deleteReturnLineItem(this.props.orderGroupId,this.props.returnFormId,e.LineItemId)];case 1:return t.sent(),[2]}}))}))},r.prototype.updateReturnComment=function(){return Wt(this,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,ln.OrderGroup.updateReturnForm(this.props.orderGroupId,this.props.returnFormId,this.state.returnOrderForm)];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(e.message)),[3,3];case 3:return[2]}}))}))},r.prototype.isReturnEditable=function(){return this.state.returnOrderForm.Status.Code===Ii.AwaitingStockReturn},r.prototype.render=function(){var e=this;return t("div",null,t(Nn,{closeView:function(){return e.closeView()},title:"Return Details",showDialogActions:!0},this.state.lineItemDialogOpen&&t(Po,{orderGroupId:this.props.orderGroupId,returnFormId:this.props.returnFormId,returnLineItem:this.state.returnLineItemSelected,isReturnEditable:this.state.isReturnEditable,onUpdated:function(){return Wt(e,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return this.closeDialog(),[4,this.getData()];case 1:return e.sent(),[2]}}))}))},onClose:this.closeDialog}),t(l,{container:!0,direction:"column",spacing:8},t(l,{item:!0},t(To,{onUpdated:function(){return e.getData()},returnOrderForm:this.state.returnOrderForm,orderGroupId:this.props.orderGroupId})),t(l,{item:!0},t(b,null,t(O,null,this.state&&this.state.returnOrderForm&&t(l,{container:!0,direction:"column",spacing:16},t(l,{item:!0},t(We,{className:this.props.classes.rowLabel},"Return No"),t(We,{className:this.props.classes.rowData},this.state.returnOrderForm.RMANumber)),t(l,{item:!0},t(We,{className:this.props.classes.rowLabel},"Created Date"),t(We,{className:this.props.classes.rowData},ot(this.state.returnOrderForm.Created).format("LLL"))),t(l,{item:!0},t(We,{className:this.props.classes.rowLabel},"Created By"),t(We,{className:this.props.classes.rowData},this.state.returnOrderForm.Creator.FullName)),t(l,{item:!0},t(We,{className:this.props.classes.rowLabel},"Status"),t(We,{className:this.props.classes.rowData},this.state.returnOrderForm.Status.Name)),t(l,{item:!0},t(We,{className:this.props.classes.rowLabel},"Comment"),t(Lt,{className:this.props.classes.rowData,textarea:!0,style:{height:"100px",width:"400px"}},t(Mt,{style:{resize:"none"},maxLength:1024,readOnly:this.state.returnOrderForm.Status.Code!==Ii.AwaitingStockReturn,value:this.state.returnOrderForm.ReturnComment,onChange:this.handleReturnCommentChange,onBlur:function(){e.updateReturnComment()}}))),t(l,{item:!0},!this.state.isLoadingResource&&this.state.returnOrderForm&&t(Us,{columns:this.columns,data:mo(this.state.returnOrderForm)})),t(l,null,t(l,null,t(bo,{amount:this.state.returnOrderForm.ItemsTotal,label:"Line Item Total",variant:"subtitle1"})),t(l,null,t(bo,{amount:this.state.returnOrderForm.InvalidDiscount,label:"Invalidated Discounts",variant:"subtitle1"})),t(l,null,t(bo,{amount:this.state.returnOrderForm.Total,label:"Return Total",variant:"subtitle1"}))))))))),t(Cn,{open:this.state.isDeleteDialogOpen,title:"Delete Item",closeLabel:"No",okLabel:"Yes",onOK:function(){e.deleteLineItem(e.state.currentItem).then((function(){e.setState({isDeleteDialogOpen:!1}),e.getData().then((function(){return e.setState({isLoadingResource:!1})}))}))},onClose:function(){return e.setState({isDeleteDialogOpen:!1})}},t(We,{variant:"body1"},"Are you sure you want to delete this item?")))},r}(n),No=p((function(e){e.spacing;return c({rowLabel:{display:"inline-block",width:"200px"},rowData:{display:"inline-block"}})}))(u((function(e,t){return Bt({orderGroup:e.orderGroup.currentOrderGroup},t)}))(Go)),Ro=function(e){function n(t){var r,n=e.call(this,t)||this;if(n.state={selectedOrderTabIndex:1,showConfirmDiscardDialog:!1,returnOrderFormId:-1},n.orderTabNames=new Array,n.orderTabIndexChangedHandler=function(e){return Wt(n,void 0,void 0,(function(){var t;return qt(this,(function(r){return this.setState({selectedOrderTabIndex:e}),(t=new URLSearchParams(as.location.search)).set("tab",this.orderTabNames[e].key),as.replace(as.location.pathname+"?"+t.toString()),[2]}))}))},n.createOrderHandler=function(){return Wt(n,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),[4,ln.OrderGroup.createPurchaseOrder(this.props.orderGroup)];case 1:return e=r.sent(),this.state.returnOrderFormId>-1&&e.ParentOrderId?[4,ln.OrderGroup.updateExchangeOrderId(e.ParentOrderId,this.state.returnOrderFormId,e.OrderGroupId)]:[3,3];case 2:r.sent(),r.label=3;case 3:return as.replace(Er+"/"+e.OrderGroupId),[3,5];case 4:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},!n.props.orderGroup)return as.push("/?type=Order"),n;n.initOrderTabs(t);var s=new URLSearchParams(as.location.search),i=s.get("tab");if(i){var o=n.orderTabNames.findIndex((function(e){return e.key===i}));o>0&&(n.state.selectedOrderTabIndex=o)}return n.state.returnOrderFormId=parseInt(null!=(r=s.get("returnFormId"))?r:"-1",10),n}return Vt(n,e),n.prototype.initOrderTabs=function(e){this.orderTabNames.push({key:"summary",name:"Summary"}),this.orderTabNames.push({key:"details",name:"Form Details "}),this.orderTabNames.push({key:"contact",name:"Contact Details"})},n.prototype.closeView=function(){var e=ds("previous_order_create");as.push(null!=e?e:"/")},n.prototype.render=function(){var e,n,s=this,i=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,o=null===(n=this.props.extendUI)||void 0===n?void 0:n.bottomPlaceHolder;return t(r,null,this.props.orderGroup&&t(Nn,{closeView:function(){return s.setState({showConfirmDiscardDialog:!0})},title:"Prepare Order",showDialogActions:!0},i&&t(i,{MarketId:this.props.selectedMarket,CustomerId:this.props.orderGroup.Customer.Id}),t(l,{container:!0,direction:"column",spacing:8},t(l,{item:!0},t(l,{container:!0,justify:"flex-end"},t(l,{item:!0},t(se,{outlined:!0,type:"submit",disabled:!mi(this.props.orderGroup),onClick:this.createOrderHandler},"Create Order")))),t(l,{item:!0},t(V,{position:"static",color:"default"},t(fe,{activeIndex:this.state.selectedOrderTabIndex,handleActiveIndexUpdate:this.orderTabIndexChangedHandler},this.orderTabNames.map((function(e){return t(ge,{key:e.key},e.name)})))),t(b,null,t(O,null,t(l,null,"summary"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t(ti,{orderGroup:this.props.orderGroup,isReadonly:!0,createMode:!0}),"details"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t(l,null,t(yo,{orderForm:this.props.orderGroup.Forms[0]})),"contact"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t(l,null,t(si,{orderGroup:this.props.orderGroup}))))))),o&&t(o,{MarketId:this.props.selectedMarket,CustomerId:this.props.orderGroup.Customer.Id})),this.state.showConfirmDiscardDialog&&t(Sn,{title:"Discard Order",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:this.closeView,onClose:function(){s.setState({showConfirmDiscardDialog:!1})}},t(m,{variant:"body1"},"Are you sure you want to discard Order?")))},n}(n),Eo=u((function(e,t){var r,n;return{selectedMarket:e.market.selectedMarket,orderGroup:e.orderGroup.currentOrderGroup,extendUI:null===(n=null===(r=e.setting.pageConfig)||void 0===r?void 0:r.createOrder)||void 0===n?void 0:n.extendUI}}))(Ro),xo=function(e){function n(t){var r=e.call(this,t)||this;r.state={selectedOrderTabIndex:1,showConfirmDiscardDialog:!1,loaded:!1},r.orderTabNames=new Array,r.paymentPlanSettingValidator={validate:function(){return!1}},r.initCartData=function(){return Wt(r,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return[4,ln.Cart.getCustomerCart(this.props.customerId,this.props.marketId)];case 1:return t.sent()&&this.props.dispatch(fr.ApplicationActions.showNotification("EPiServer Commerce does not allow carts with same customer and market. Existing cart of the customer in current market was cleared.")),[4,ln.Cart.createOrRefreshCart(this.props.customerId,this.props.marketId,"Default")];case 2:return(e=t.sent())&&this.props.dispatch(fr.OrderGroupActions.updateCurrentOrderGroup(e)),[2]}}))}))},r.orderTabIndexChangedHandler=function(e){return Wt(r,void 0,void 0,(function(){var t;return qt(this,(function(r){return this.setState({selectedOrderTabIndex:e}),(t=new URLSearchParams(as.location.search)).set("tab",this.orderTabNames[e].key),as.replace(as.location.pathname+"?"+t.toString()),[2]}))}))},r.closeView=function(){r.props.dispatch(fr.ApplicationActions.closeCustomerSelectionView()),r.props.dispatch(fr.OrderGroupActions.setPaymentPlanSetting({})),ln.Cart.deleteCart(r.props.orderGroup.OrderGroupId);var e=ds("previous_paymentplan_create");as.push(null!=e?e:"/")},r.createPaymentPlanHandler=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,ln.PaymentPlan.createPaymentPlan(this.props.orderGroup.OrderGroupId,this.props.paymentPlanSetting)];case 1:return e=r.sent(),as.replace(Lr+"/"+e.OrderGroupId),[3,3];case 2:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.initOrderTabs(t);var n=new URLSearchParams(as.location.search).get("tab");if(n){var s=r.orderTabNames.findIndex((function(e){return e.key===n}));s>0&&(r.state.selectedOrderTabIndex=s)}return r}return Vt(n,e),n.prototype.componentDidMount=function(){return Wt(this,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return this.props.orderGroup&&this.props.orderGroup.OrderGroupId&&this.props.currentOrderGroupId===this.props.orderGroup.OrderGroupId?[3,3]:[4,this.initCartData()];case 1:return t.sent(),[4,ln.Currency.getCurrencies(this.props.orderGroup.MarketId)];case 2:e=t.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrencies(e)),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroupId(this.props.orderGroup.OrderGroupId)),t.label=3;case 3:return this.setState({loaded:!0}),[2]}}))}))},n.prototype.initOrderTabs=function(e){this.orderTabNames.push({key:"summary",name:"Summary"}),this.orderTabNames.push({key:"details",name:"Form Details "}),this.orderTabNames.push({key:"contact",name:"Contact Details"}),this.orderTabNames.push({key:"settings",name:"Settings"})},n.prototype.render=function(){var e,n,s=this,i=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,o=null===(n=this.props.extendUI)||void 0===n?void 0:n.bottomPlaceHolder;return t(r,null,this.props.orderGroup&&this.state.loaded&&t(Nn,{closeView:function(){return s.setState({showConfirmDiscardDialog:!0})},title:"Create Payment Plan",showDialogActions:!0},i&&t(i,{MarketId:this.props.marketId,CustomerId:this.props.customerId}),t(l,{container:!0,direction:"column",spacing:8},t(l,{item:!0},t(l,{container:!0,justify:"flex-end"},t(l,{item:!0},t(se,{outlined:!0,type:"submit",disabled:!mi(this.props.orderGroup)||!this.paymentPlanSettingValidator.validate(),onClick:this.createPaymentPlanHandler},"Create Payment Plan")))),t(l,{item:!0},t(V,{position:"static",color:"default"},t(fe,{activeIndex:this.state.selectedOrderTabIndex,handleActiveIndexUpdate:this.orderTabIndexChangedHandler},this.orderTabNames.map((function(e){return t(ge,{key:e.key},e.name)})))),t(b,null,t(O,null,t(l,null,"summary"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t(ti,{orderGroup:this.props.orderGroup,isReadonly:!1,createMode:!0}),"details"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t(l,null,t(yo,{orderForm:this.props.orderGroup.Forms[0]})),"contact"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t(l,null,t(si,{orderGroup:this.props.orderGroup})),"settings"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t(l,null,t(ci,{editMode:!0,createMode:!0,paymentPlan:this.props.orderGroup,validator:this.paymentPlanSettingValidator}))))))),o&&t(o,{MarketId:this.props.marketId,CustomerId:this.props.customerId})),this.state.showConfirmDiscardDialog&&t(Sn,{title:"Discard Payment Plan",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:this.closeView,onClose:function(){s.setState({showConfirmDiscardDialog:!1})}},t(m,{variant:"body1"},"Are you sure you want to discard Payment Plan?")))},n}(n),Lo=u((function(e,t){var r,n;return{orderGroup:e.orderGroup.currentOrderGroup,currentOrderGroupId:e.orderGroup.currentOrderGroupId,marketId:t.marketId,customerId:t.customerId,paymentPlanSetting:e.orderGroup.paymentPlanSetting,extendUI:null===(n=null===(r=e.setting.pageConfig)||void 0===r?void 0:r.createPaymentPlan)||void 0===n?void 0:n.extendUI}}))(xo),Mo=z((function(e){e.palette,e.spacing,e.breakpoints;return c({root:{border:"solid 1px #000",padding:"8px 12px",backgroundColor:"#fff",textAlign:"center"}})}))(u((function(e,t){return{orderGroupFilterIsVisible:e.application.orderGroupFilterIsVisible,classes:t.classes}}))((function(e){var r=e.classes;return e.orderGroupFilterIsVisible?t("div",{className:r.root},t(We,null,"This feature is yet not available.")):null}))),Fo=require("autosuggest-highlight/match"),ko=require("autosuggest-highlight/parse"),_o=function(e,r){var n=Fo(e.FullName,r.query),s=ko(e.FullName,n),i=Fo(e.Email,r.query),o=ko(e.Email,i);return t(pe,null,t(le,{style:{height:"48px"}},t(he,{primaryText:t("div",null,s.map((function(e,r){return e.highlight?t("span",{key:String(r),style:{fontWeight:500}},e.text):t("strong",{key:String(r),style:{fontWeight:300}},e.text)})),t("div",null,t(m,{color:"textSecondary",gutterBottom:!0},t("div",null,o.map((function(e,r){return e.highlight?t("span",{key:String(r),style:{fontWeight:500}},e.text):t("strong",{key:String(r),style:{fontWeight:300}},e.text)}))))))})),t(me,null))},Vo=function(e){var r=e.ref,n=Ht(e,["ref"]);return t(h,{autoFocus:!0,required:!0,fullWidth:!0,label:"Choose customer",placeholder:"Search by name or e-mail...",variant:"outlined",InputProps:Bt({inputRef:r},n)})},Uo=function(e){return e.FullName};var Bo=z((function(e){e.palette;var t=e.spacing;e.breakpoints;return c({container:{position:"relative"},suggestionsContainerOpen:{position:"absolute",zIndex:1,marginTop:t.unit,left:0,right:0,maxHeight:"300px",overflowY:"auto"},suggestion:{display:"block"},suggestionsList:{margin:0,padding:0,listStyleType:"none"},divider:{height:2*t.unit},email:{display:"block",fontSize:"0.9em"}})}))(u((function(e,t){var r=e.market.markets.find((function(e){return!0===e.IsCurrentMarket}));return{suggestions:e.application.customerSearchFieldSuggestions,classes:t.classes,listedOrderGroups:e.orderGroup.listedOrderGroups,orderPageIndex:e.application.pageIndex,orderRowsPerPage:e.application.rowsPerPage,selectedMarket:e.market.selectedMarket||(r?r.Id:""),selectedContactId:e.application.selectedContactId,onSelectionChanged:t.onSelectionChanged}}))((function(e){var r=this,n=e.classes,s=i(""),u=s[0],d=s[1],c=i(""),p=c[0],h=c[1];o((function(){!function(){Wt(this,void 0,void 0,(function(){var t,r;return qt(this,(function(n){switch(n.label){case 0:if(!e.selectedContactId||u===e.selectedContactId)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),d(e.selectedContactId),[4,ln.Contact.get(e.selectedContactId)];case 2:return t=n.sent(),e.dispatch(fr.ApplicationActions.setCustomerSearchFieldSuggestions([{Id:t.Id,FullName:t.FullName?t.FullName:"",Email:t.Email?t.Email:""}])),h(t.FullName),e.onSelectionChanged(e.selectedMarket,e.selectedContactId),[3,4];case 3:return r=n.sent(),e.dispatch(fr.ApplicationActions.showNotification(r.message)),[3,4];case 4:return[2]}}))}))}()}),[e.selectedContactId]);var m=a(Nt((function(t){var n=t.value;return Wt(r,void 0,void 0,(function(){var t,r,s;return qt(this,(function(i){switch(i.label){case 0:t=n.trim().toLowerCase(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,ln.Contact.list(t)];case 2:return r=i.sent(),e.dispatch(fr.ApplicationActions.setCustomerSearchFieldSuggestions(r)),[3,4];case 3:return s=i.sent(),e.dispatch(fr.ApplicationActions.showNotification(s.message)),[3,4];case 4:return[2]}}))}))}),1e3,{trailing:!0}),[]),f=function(){e.dispatch(fr.CreateContactFormActions.showCreateContactForm())};return t(l,{container:!0,spacing:16,direction:"row"},t(l,{item:!0,xs:12},t($s,{selectedMarket:e.selectedMarket,updateInputValue:function(t){return function(t){return Wt(r,void 0,void 0,(function(){return qt(this,(function(r){return e.dispatch(fr.MarketActions.setSelectedMarket(t)),e.onSelectionChanged(t,e.selectedContactId),[2]}))}))}(t)}})),t(l,{item:!0,xs:12},t(Et,{renderInputComponent:Vo,suggestions:e.suggestions,onSuggestionsFetchRequested:m,onSuggestionsClearRequested:function(){e.dispatch(fr.ApplicationActions.setCustomerSearchFieldSuggestions([]))},renderSuggestionsContainer:function(e){return function(e,r){var n=e.containerProps,s=e.children;return t("div",{style:{marginTop:"8px"}},!s&&t(se,{onClick:function(e){e.preventDefault(),r(e)},outlined:!0},"New Customer"),t(M,Bt({},n,{style:{marginTop:0},square:!0}),s))}(e,f)},getSuggestionValue:Uo,renderSuggestion:_o,onSuggestionSelected:function(t,n){return Wt(r,void 0,void 0,(function(){return qt(this,(function(t){return e.dispatch(fr.ApplicationActions.setSelectedContactId(n.suggestion.Id)),e.onSelectionChanged(e.selectedMarket,n.suggestion.Id),d(n.suggestion.Id),[2]}))}))},inputProps:{value:p,onChange:function(t,r){r&&(h(r.newValue),""===r.newValue&&(e.onSelectionChanged(e.selectedMarket,""),e.dispatch(fr.ApplicationActions.setSelectedContactId(""))))},type:"search"},theme:{container:n.container,suggestionsContainerOpen:n.suggestionsContainerOpen,suggestionsList:n.suggestionsList,suggestion:n.suggestion}})))}))),Ho=function(e){function n(t){var r=e.call(this,t)||this;return r.getTitle=function(e){switch(e){case"Cart":return"Open Cart";case"Order":return"Create Order";case"PaymentPlan":return"Create Payment Plan";default:return""}},r.selectionChangedHandler=function(e,t){return Wt(r,void 0,void 0,(function(){var r,n;return qt(this,(function(s){switch(s.label){case 0:if(!e||!t)return this.setState({cartMode:null,currentCart:null,isFormValid:!1}),[2];if(this.setState({cartMode:null,isFormValid:!0}),"Cart"!==this.props.orderGroupType)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,ln.Cart.getCustomerCart(t,e)];case 2:return r=s.sent(),this.setState({currentCart:r,cartMode:r?"open":"create"}),[3,4];case 3:return n=s.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(n.message)),[3,4];case 4:return[2]}}))}))},r.createOrRefreshCart=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,ln.Cart.createOrRefreshCart(this.props.selectedContactId,this.props.selectedMarket,"Default")];case 1:return(e=r.sent())&&(this.closeView(),as.push(xr+"/"+e.OrderGroupId)),[3,3];case 2:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.openCustomerCart=function(){return Wt(r,void 0,void 0,(function(){return qt(this,(function(e){return this.state.currentCart?(this.closeView(),as.push(xr+"/"+this.state.currentCart.OrderGroupId)):this.props.dispatch(fr.ApplicationActions.showNotification("Cart is not found.")),[2]}))}))},r.createCustomerOrder=function(){return Wt(r,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return[4,ln.OrderGroup.initPurchaseOrder(this.props.selectedContactId,this.props.selectedMarket)];case 1:return e=t.sent(),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup(e)),this.closeView(),us("previous_order_create"),as.push(""+Vr),[2]}}))}))},r.createPaymentPlan=function(){return Wt(r,void 0,void 0,(function(){return qt(this,(function(e){return this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroup({})),this.props.dispatch(fr.OrderGroupActions.setCurrentOrderGroupId(null)),this.closeView(),us("previous_paymentplan_create"),as.push(Ur+"?marketId="+this.props.selectedMarket+"&customerId="+this.props.selectedContactId),[2]}))}))},r.closeView=function(){r.props.dispatch(fr.ApplicationActions.setSelectedContactId("")),r.props.dispatch(fr.ApplicationActions.closeCustomerSelectionView())},r.state={title:r.getTitle(r.props.orderGroupType),orderGroupType:r.props.orderGroupType,isFormValid:!1,currentCart:null,cartMode:null},r}return Vt(n,e),n.prototype.render=function(){return t(te,{open:!0,maxWidth:"sm",fullWidth:!0,onClose:this.closeView,className:this.props.classes.root,classes:{paper:this.props.classes.paper}},t(Ct,null,this.state.title),t(ne,{className:this.props.classes.dialogContent},t(Bo,{onSelectionChanged:this.selectionChangedHandler})),t(re,null,t(se,{onClick:this.closeView},"Cancel"),"Cart"===this.props.orderGroupType&&t(r,null,"create"===this.state.cartMode&&t(se,{disabled:!this.state.isFormValid,unelevated:!0,type:"submit",onClick:this.createOrRefreshCart},"Create a cart"),"open"===this.state.cartMode&&t(se,{disabled:!this.state.isFormValid,unelevated:!0,type:"submit",onClick:this.openCustomerCart},"Open cart")),"Order"===this.props.orderGroupType&&t(se,{disabled:!this.state.isFormValid,unelevated:!0,type:"submit",onClick:this.createCustomerOrder},"Create Order"),"PaymentPlan"===this.props.orderGroupType&&t(se,{disabled:!this.state.isFormValid,unelevated:!0,type:"submit",onClick:this.createPaymentPlan},"Create Payment Plan")))},n}(n),Wo=z((function(e){e.palette,e.spacing,e.breakpoints;return c({root:{},paper:{overflowY:"visible"},dialogContent:{overflowY:"visible"}})}))(u((function(e,t){return{selectedMarket:e.market.selectedMarket,selectedContactId:e.application.selectedContactId,listedOrderGroups:e.orderGroup.listedOrderGroups,orderGroupType:t.orderGroupType,classes:t.classes}}))(Ho)),qo=function(e){function r(t){var r=e.call(this,t)||this;return r.updateInputValue=function(e){return Wt(r,void 0,void 0,(function(){var t;return qt(this,(function(r){return(t=Object.assign({},this.props.contact))[e.target.name]=String(e.target.value),this.props.dispatch(fr.CreateContactFormActions.setCreateContactFormContact(t)),[2]}))}))},r.saveChanges=function(){return Wt(r,void 0,void 0,(function(){var e,t;return qt(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,ln.Contact.createContact(this.props.contact)];case 1:return e=r.sent(),this.props.dispatch(fr.ApplicationActions.setSelectedContactId(e.Id)),this.closeView(),[3,3];case 2:return t=r.sent(),this.props.dispatch(fr.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.closeView=function(){r.props.dispatch(fr.CreateContactFormActions.hideCreateContactForm())},r}return Vt(r,e),r.prototype.componentDidUpdate=function(e){this.currentForm&&e.isCurrentFormValid!==this.currentForm.isFormValid()&&this.props.dispatch(fr.CreateContactFormActions.setCreateContactFormIsValid(this.currentForm.isFormValid()))},r.prototype.render=function(){var e=this;return t(te,{open:!0,maxWidth:"sm",fullWidth:!0},t(Ct,null,"Create Contact"),t(ne,null,t(Ee,{ref:function(t){return e.currentForm=t},onSubmit:this.saveChanges},t(ms,{contact:this.props.contact,saveChanges:this.saveChanges,updateInputValue:this.updateInputValue}))),t(re,null,t(se,{onClick:this.closeView},"Cancel"),t(se,{unelevated:!0,type:"submit",disabled:!this.props.isCurrentFormValid,onClick:this.saveChanges},"Save Customer")))},r}(n),jo=u((function(e){return{contact:e.createContactForm.contact,selectedMarket:e.market.selectedMarket,isCurrentFormValid:e.createContactForm.isValid,listedOrderGroups:e.orderGroup.listedOrderGroups}}))(qo),Yo=require("autosuggest-highlight/match"),zo=require("autosuggest-highlight/parse"),Qo=function(e,r){var n=Yo(e.FullName,r.query),s=zo(e.FullName,n),i=Yo(e.Email,r.query),o=zo(e.Email,i);return t(pe,null,t(le,{style:{height:"48px"}},t(he,{primaryText:t("div",null,s.map((function(e,r){return e.highlight?t("span",{key:String(r),style:{fontWeight:500}},e.text):t("strong",{key:String(r),style:{fontWeight:300}},e.text)})),t("div",null,t(m,{color:"textSecondary",gutterBottom:!0},t("div",null,o.map((function(e,r){return e.highlight?t("span",{key:String(r),style:{fontWeight:500}},e.text):t("strong",{key:String(r),style:{fontWeight:300}},e.text)}))))))})),t(me,null))},Ko=function(e){var r=e.ref,n=Ht(e,["ref"]);return t(h,{autoFocus:!0,required:!0,fullWidth:!0,label:"Choose customer",placeholder:"Search by name or e-mail...",variant:"outlined",InputProps:Bt({inputRef:r},n)})},Xo=function(e){return e.FullName};var Jo=z((function(){return c({container:{position:"relative"},suggestionsContainerOpen:{zIndex:1,position:"fixed",marginTop:"0px",maxHeight:"300px",overflowY:"auto",width:"512px"},suggestion:{display:"block"},suggestionsList:{margin:0,padding:0,listStyleType:"none"}})}))(u((function(e,t){return{classes:t.classes,onContactSelected:t.onContactSelected,onClose:t.onClose}}))((function(e){var r=this,n=e.classes,s=i(""),o=s[0],u=s[1],d=i([]),c=d[0],p=d[1],h=a(Nt((function(t){var n=t.value;return Wt(r,void 0,void 0,(function(){var t,r,s;return qt(this,(function(i){switch(i.label){case 0:t=n.trim().toLowerCase(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,ln.Contact.list(t)];case 2:return r=i.sent(),p(r),[3,4];case 3:return s=i.sent(),e.dispatch(fr.ApplicationActions.showNotification(s.message)),[3,4];case 4:return[2]}}))}))}),1e3,{trailing:!0}),[]);return t(Cn,{title:"Open Customer",open:!0,onClose:e.onClose},t(l,{container:!0,spacing:16},t(l,{item:!0,xs:12},t(Et,{renderInputComponent:Ko,suggestions:c,onSuggestionsFetchRequested:h,onSuggestionsClearRequested:function(){p([])},renderSuggestionsContainer:function(e){return function(e){var r=e.containerProps,n=e.children;return t(M,Bt({},r),n)}(e)},getSuggestionValue:Xo,renderSuggestion:Qo,onSuggestionSelected:function(t,n){return Wt(r,void 0,void 0,(function(){return qt(this,(function(t){return e.onContactSelected&&e.onContactSelected(n.suggestion.Id),[2]}))}))},inputProps:{value:o,onChange:function(e,t){t&&u(t.newValue)},type:"search"},theme:{container:n.container,suggestionsContainerOpen:n.suggestionsContainerOpen,suggestionsList:n.suggestionsList,suggestion:n.suggestion}}))))}))),Zo=function(e){function r(t){var r=e.call(this,t)||this;return r.state={orderGroupType:r.props.orderGroupType,searchText:r.props.searchText,searchInputValue:r.props.searchText,isLoadingResource:!0,searchOptions:r.getSearchTypeOptions(r.props.orderGroupType),searchType:r.props.searchType,openCustomerDialogVisible:!1},r.handleScroll=function(){return Wt(r,void 0,void 0,(function(){var e;return qt(this,(function(t){switch(t.label){case 0:return window.innerHeight+window.pageYOffset>=document.body.offsetHeight&&this.props.listedOrderGroups.length0&&0===this.props.listedOrderGroups.length?t(We,null,"Sorry, we couldn't find any results matching \""+this.state.searchText+'"'):this.props.listedOrderGroups.map((function(r,n){var s=t(We,{variant:"body1",className:e.props.classes.orderStatusText},Qs(r.OrderStatus)),i=[];return r.HasAwaitingReturnCompletable&&i.push("Awaiting Return Completion"),r.HasAwaitingStockReturns&&i.push("Awaiting Stock Return"),t($,{item:!0,key:n,onClick:function(){return e.goToDetail(r.OrderGroupId,r.Type)},className:e.props.classes.orderRow},t($,{container:!0,direction:"row",spacing:16,alignItems:"flex-start",justify:"space-between"},t($,{item:!0,xs:12,md:1,className:e.props.classes.orderGroupId},t(We,{variant:"body1"},"Order"===r.Type?r.OrderNumber:"# "+r.OrderGroupId)),t($,{item:!0,xs:12,md:2,className:e.props.classes.orderDate},t(We,{variant:"body1",className:e.props.classes.orderDateText},r.Created&&ot(r.Created).format("LLL"))),t($,{item:!0,xs:12,md:1,className:e.props.classes.cartName},t(We,{variant:"body1"},r.Name)),t($,{item:!0,xs:12,md:1,className:e.props.classes.marketName},t(We,{variant:"body1"},r.MarketName)),t($,{item:!0,xs:12,md:1,className:e.props.classes.customerName},t(We,{variant:"body1"},r.CustomerName)),t($,{item:!0,xs:12,sm:12,md:2,className:e.props.classes.email},t(We,{variant:"body1"},r.Customer.Email)),t($,{item:!0,xs:12,sm:6,md:2,className:e.props.classes.orderAmount},t(Rs,{amount:r.Total,className:e.props.classes.orderAmountText,align:"right"})),t($,{item:!0,xs:12,sm:6,md:2,className:e.props.classes.orderStatus},s,i.length>0&&t(We,{variant:"subtitle2"},"(",i.join(", "),")"))))}))},r.prototype.render=function(){var e=this;return t(b,{className:this.props.classes.root},t(O,null,t($,{container:!0,spacing:16,direction:"column"},t($,{item:!0},t($,{container:!0,justify:"space-between"},t($,{item:!0},t($,{container:!0,spacing:8},t($,{item:!0},t(se,{unelevated:"Cart"===this.state.orderGroupType,outlined:!0,onClick:function(){return e.switchOrderGroupType("Cart")}},"Carts")),t($,{item:!0},t(se,{unelevated:"Order"===this.state.orderGroupType,outlined:!0,onClick:function(){return e.switchOrderGroupType("Order")}},"Orders")),t($,{item:!0},t(se,{unelevated:"PaymentPlan"===this.state.orderGroupType,outlined:!0,onClick:function(){return e.switchOrderGroupType("PaymentPlan")}},"Payment plan")),t($,{item:!0},t(Jr,{dense:!0,value:this.state.searchType,options:this.state.searchOptions,onChange:this.handleSearchTypeChange})),t($,{item:!0},t(h,{value:this.state.searchInputValue,variant:"outlined",placeholder:"Search",onChange:this.handleSearchTextChange,onKeyPress:function(t){"Enter"===t.key&&e.handleEnterThrottle()},InputProps:{classes:{root:this.props.classes.searchInput},startAdornment:t(U,{position:"start"},t(Ft,null)),endAdornment:0===this.state.searchInputValue.length?void 0:t(U,{position:"end"},t(kt,{onClick:this.clearSearchText}))}})))),t($,{item:!0},t($,{container:!0,spacing:8},t($,{item:!0},"Cart"===this.state.orderGroupType&&t(se,{onClick:this.openCustomerSelectionView,outlined:!0},"Open Cart"),"Order"===this.state.orderGroupType&&t(se,{outlined:!0,onClick:this.handleCreateOrder},"Create Order"),"PaymentPlan"===this.state.orderGroupType&&t(se,{outlined:!0,onClick:this.handleCreatePaymentPlan},"Create Payment Plan")),t($,{item:!0},t(se,{outlined:!0,onClick:this.handleOpenCustomerSearchDialog},"Open Customer"),this.state.openCustomerDialogVisible&&t(Jo,{onContactSelected:this.handleContactSelected,onClose:this.handleCloseCustomerSearchDialog})))))),t($,{item:!0},t($,{container:!0,direction:"column"},t($,{item:!0},t(Ke,{smDown:!0},t($,{item:!0,className:this.props.classes.orderHeaderRow},t($,{container:!0,direction:"row",spacing:16,alignItems:"flex-start",justify:"space-between"},t($,{item:!0,xs:6,md:1},t(We,{variant:"caption"},"No.")),t($,{item:!0,xs:6,md:2},t(We,{variant:"caption"},"Created Date")),t($,{item:!0,xs:6,md:1},t(We,{variant:"caption"},"Name")),t($,{item:!0,xs:6,md:1},t(We,{variant:"caption"},"Market")),t($,{item:!0,xs:12,sm:6,md:1},t(We,{variant:"caption"},"Customer Name")),t($,{item:!0,xs:12,sm:6,md:2},t(We,{variant:"caption"},"Customer Email")),t($,{item:!0,xs:6,sm:6,md:2},t(We,{variant:"caption",align:"right"},"Amount")),t($,{item:!0,xs:6,sm:6,md:2},t(We,{variant:"caption"},"Status"))))),this.renderGridBody()),this.state.isLoadingResource&&t($,{item:!0},t(Ce,{className:this.props.classes.progressIndicator})))))))},r}(n),$o={cursor:"pointer",borderBottom:"1px solid #eee",paddingTop:mn.paddingDefault,paddingBottom:mn.paddingDefault},ea=z((function(e){var t,r,n,s,i,o,a,u,d,p,l,h=e.palette,m=(e.spacing,e.breakpoints);return c({root:{margin:15,width:"calc(100% - 30px)"},orderRow:Bt(Bt({},$o),{paddingLeft:5,paddingRight:5,cursor:"pointer","&:hover":{backgroundColor:fn.hoveredList,color:h.getContrastText(fn.hoveredList)}}),orderHeaderRow:Bt({},$o),emptyListStatement:{margin:mn.marginDefault,padding:mn.paddingDefault,textAlign:"center"},progressContainer:{marginTop:8,textAlign:"center"},progressIndicator:{margin:8,color:h.secondary.light},customerName:(t={fontWeight:"bold",order:4},t[m.down("sm")]={order:0},t),email:(r={fontWeight:"bold",order:5},r[m.down("sm")]={order:1},r),customerNameText:{fontWeight:"bold"},orderDate:(n={order:2},n[m.down("sm")]={order:3},n),orderDateText:(s={},s[m.down("sm")]={color:h.secondary.light},s),orderGroupId:(i={order:1},i[m.down("sm")]={display:"none"},i),marketName:(o={order:4},o[m.down("sm")]={order:2},o),cartName:(a={order:3},a[m.down("sm")]={display:"none"},a),orderAmount:(u={order:6},u[m.down("sm")]={order:4},u),orderAmountText:(d={},d[m.down("sm")]={textAlign:"left"},d),orderStatus:(p={order:7},p[m.down("sm")]={order:5},p),orderStatusText:(l={},l[m.down("sm")]={color:h.secondary.light},l),searchInput:{height:"36px"}})}))(u((function(e,t){return{listedOrderGroups:e.orderGroup.listedOrderGroups,pageIndex:e.application.pageIndex,rowsPerPage:e.application.rowsPerPage,totalOrderGroups:e.application.totalOrderGroups,orderGroupType:t.orderGroupType,classes:t.classes,searchText:t.searchText,searchType:t.searchType}}))(Zo)),ta=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Vt(r,e),r.prototype.render=function(){var e,r,n=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,s=null===(r=this.props.extendUI)||void 0===r?void 0:r.bottomPlaceHolder;return t("div",null,n&&t(n,{className:"top-placeholder"}),t(Mo,null),this.props.customerSelectionViewIsVisible&&t(Wo,{orderGroupType:this.props.orderGroupType}),this.props.createContactFormIsVisible&&t(jo,null),t(ea,{orderGroupType:this.props.orderGroupType,searchText:this.props.searchText,searchType:this.props.searchType}),s&&t(s,{className:"bottom-placeholder"}))},r}(n),ra=function(e,t){var r,n,s,i;switch(e){case"Order":i=null===(r=t.setting.pageConfig.orderList)||void 0===r?void 0:r.extendUI;break;case"Cart":i=null===(n=t.setting.pageConfig.cartList)||void 0===n?void 0:n.extendUI;break;case"PaymentPlan":i=null===(s=t.setting.pageConfig.paymentPlanList)||void 0===s?void 0:s.extendUI}return i};var na,sa=(na=z((function(e){return e.palette,e.spacing,e.breakpoints,c({})}))(u((function(e,t){return{customerSelectionViewIsVisible:e.application.customerSelectionViewIsVisible,orderGroupType:t.orderGroupType,searchText:t.searchText,searchType:t.searchType,orderGroupViewIsVisible:e.application.orderGroupViewIsVisible,createContactFormIsVisible:e.createContactForm.isVisible,classes:t.classes,extendUI:ra(t.orderGroupType,e)}}))(ta)),function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Vt(r,e),r.prototype.render=function(){return t("div",null,this.props.topPlaceHolder?this.props.topPlaceHolder:"",t(na,Bt({},this.props)),this.props.bottomPlaceHolder?this.props.bottomPlaceHolder:"")},r}(n)),ia=u((function(e,t){var r;return{extraPages:null===(r=e.setting.pageConfig)||void 0===r?void 0:r.extraPages}}))((function(e){return t(Ve,null,t("div",null,t(_e,{path:Dr,render:function(e){return t(Ns,Bt({customerId:e.match.params.id},e))}}),t(_e,{path:Mr,exact:!0,render:function(e){var r=e.match.params;return t(Io,{orderGroupId:r.id,orderGroupType:"Order"})}}),t(_e,{path:Fr,exact:!0,render:function(e){var r=e.match.params;return t(Io,{orderGroupId:r.id,orderGroupType:"Cart"})}}),t(_e,{path:kr,exact:!0,render:function(e){var r=e.match.params;return t(Io,{orderGroupId:r.id,orderGroupType:"PaymentPlan"})}}),t(_e,{path:_r,exact:!0,render:function(e){var r=e.match.params;return t(No,{orderGroupId:r.id,returnFormId:r.formId})}}),t(_e,{path:Vr,render:function(e){return t(Eo,Bt({},e))}}),t(_e,{path:Ur,render:function(e){var r=new URLSearchParams(e.location.search),n=r.get("customerId")||"",s=r.get("marketId")||"";return t(Lo,{customerId:n,marketId:s})}}),t(_e,{path:wr,exact:!0,render:function(e){var r,n,s,i=new URLSearchParams(e.location.search),o=i.get("type");switch(o){case"Order":o="Order";break;case"PaymentPlan":o="PaymentPlan";break;default:o="Cart"}var a=null!=(r=i.get("search"))?r:"",u=null!=(s=ii[(n=i.get("searchBy"),null!=n?n:"CustomerName")])?s:ii.CustomerName;return u===ii.OrderNumber&&"Order"!==o&&(u=ii.CustomerName),t(sa,{orderGroupType:o,searchText:a,searchType:u})}}),e.extraPages&&e.extraPages.map((function(e){return t(_e,{key:e.path,path:e.path,exact:e.exact,render:function(t){return e.render(t)}})}))))})),oa=K({typography:{fontFamily:"Barlow, sans-serif",useNextVariants:!0},palette:{primary:{main:"#1456F1",light:"#8EBAFF",contrastText:"#fff"},secondary:{main:"#FF9283",contrastText:"#000"},error:{main:"#f01c10"}},overrides:{MuiCard:{root:{overflow:"unset"}},MuiModal:{root:{zIndex:1e4}},MuiSnackbar:{root:{zIndex:10001}}}});(new Or).initialize(gr);var aa=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={ready:!1},t}return Vt(r,e),r.prototype.componentDidMount=function(){return Wt(this,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,Wt(void 0,void 0,void 0,(function(){var e,t,r,n,s,i;return qt(this,(function(o){switch(o.label){case 0:return[4,Wt(void 0,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,ln.Geographics.getCountries()];case 1:return[2,e.sent()]}}))}))];case 1:return e=o.sent(),gr.dispatch(fr.GeographicsActions.setCountries(e)),[4,Wt(void 0,void 0,void 0,(function(){return qt(this,(function(e){switch(e.label){case 0:return[4,ln.Market.getMarkets()];case 1:return[2,e.sent()]}}))}))];case 2:return t=o.sent(),gr.dispatch(fr.MarketActions.setMarkets(t)),r=t.find((function(e){return!0===e.IsCurrentMarket})),gr.dispatch(fr.MarketActions.setSelectedMarket(r?r.Id:"")),[4,ln.Shipment.getShippingMethods()];case 3:return n=o.sent(),gr.dispatch(fr.ShipmentActions.setShippingMethods(n)),[4,ln.OrderGroup.getOrderStatuses()];case 4:return s=o.sent(),gr.dispatch(fr.OrderGroupActions.setOrderStatuses(s)),[4,ln.Shipment.getShipmentStatuses()];case 5:return i=o.sent(),gr.dispatch(fr.ShipmentActions.setShipmentStatuses(i)),[2]}}))}))];case 1:return e.sent(),this.setState({ready:!0}),null!=this.props.setting&&gr.dispatch(fr.AppSettingActions.updateSetting(this.props.setting)),[2]}}))}))},r.prototype.render=function(){return this.state.ready&&t(d,{store:gr},t(B,{theme:oa},t(q,{utils:X},t(yr,null),t(Ar,null),t(vr,null),t(Cr,null),t(ia,null))))},r}(n),ua=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Vt(t,e),t}((function(){}));export{ua as AppSettingState,aa as CSRApp}; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.js new file mode 100644 index 00000000..e74c725e --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/bundle.js @@ -0,0 +1 @@ +"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),r=e(t);require("@episerver/ui-framework/dist/main.css");var n=require("react-redux"),s=require("@material-ui/core"),a=require("material-ui-pickers"),i=require("redux"),o=require("@material-ui/core/styles"),c=e(require("@date-io/moment")),l=e(require("@material-ui/core/Fab")),u=e(require("@material-ui/icons/FeedbackOutlined")),d=e(require("@material-ui/core/Grid")),p=e(require("@material-ui/icons/Warning")),h=e(require("@material-ui/core/Dialog")),m=e(require("@material-ui/core/DialogActions")),g=e(require("@material-ui/core/DialogContent")),f=require("@episerver/ui-framework"),y=e(require("@material-ui/core/Typography/Typography")),E=e(require("@material-ui/core/Snackbar")),v=e(require("@material-ui/core/CircularProgress")),C=e(require("axios")),S=require("us-state-codes"),I=require("zipcodes"),b=require("yup"),A=require("@material/react-select"),O=e(A);require("@material/react-menu/index.scss"),require("@material/react-select/index.scss");var T=require("react-material-ui-form-validator"),w=require("bignumber.js"),G=require("countries-list"),D=require("react-router-dom"),P=e(require("@material-ui/core/Card")),N=e(require("@material-ui/core/CardHeader")),R=e(require("@material-ui/core/CardContent")),x=e(require("@material-ui/core/Typography")),L=e(require("@material-ui/icons/Mail")),M=e(require("@material-ui/icons/Phone")),F=e(require("@material-ui/icons/AddCircle")),k=e(require("@material-ui/core/CardActionArea")),_=e(require("@material-ui/core/Slide")),V=e(require("@material-ui/core/Hidden")),U=e(require("@material-ui/core/AppBar")),B=e(require("@material-ui/core/Toolbar")),H=e(require("@material-ui/icons/Menu")),q=e(require("@material-ui/core/Table")),W=e(require("@material-ui/core/TableBody")),j=e(require("@material-ui/core/TableCell")),Y=e(require("@material-ui/core/TableHead")),z=e(require("@material-ui/core/TablePagination")),Q=e(require("@material-ui/core/TableRow")),K=e(require("@material-ui/core/Paper")),X=e(require("moment")),J=e(require("@material-ui/core/Tooltip")),Z=e(require("@material-ui/core/IconButton")),$=e(require("@material-ui/icons/Edit")),ee=e(require("@material-ui/icons/Delete")),te=e(require("@material-ui/icons/Save")),re=e(require("@material-ui/icons/Close")),ne=require("@material/data-table"),se=e(require("@material-ui/core/RadioGroup")),ae=e(require("@material-ui/core/FormControlLabel")),ie=e(require("@material-ui/core/FormLabel")),oe=e(require("@material-ui/core/Radio")),ce=e(require("@material-ui/core/DialogTitle")),le=e(require("@material-ui/core/DialogContentText")),ue=e(require("@material-ui/core/Divider")),de=e(require("@material-ui/core/Chip")),pe=e(require("@material-ui/core/TextField")),he=e(require("@material-ui/core/InputAdornment")),me=e(require("@material-ui/core/Avatar")),ge=e(require("@material-ui/icons/Done")),fe=e(require("@material-ui/icons/LocalOffer")),ye=e(require("@material-ui/icons/CardGiftcard")),Ee=e(require("@material-ui/core/Badge")),ve=require("lodash-es"),Ce=e(require("react-autosuggest")),Se=e(require("@material-ui/icons/ShoppingCart")),Ie=require("@material/react-text-field"),be=e(Ie),Ae=require("@material-ui/icons"),Oe=function(e,t){return(Oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function Te(e,t){function r(){this.constructor=e}Oe(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var we,Ge=function(){return(Ge=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&s[s.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]0&&(r.searchValue=encodeURIComponent(e.searchText),r.searchField=e.searchType),[4,C.get(t,{params:r})];case 1:return[2,{TotalOrderGroups:(n=s.sent()).data.TotalOrderGroups,Results:n.data.Results.map((function(e,t){return Pt(e)}))}]}}))}))},t.getReturns=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns",[4,C.get(t)];case 1:return[2,{Totals:(r=n.sent()).data.Totals,Results:r.data.Results.map((function(e,t){return Pt(e)}))}]}}))}))},t.getReturn=function(e,r){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns/"+r,[4,C.get(t)];case 1:return[2,n.sent().data]}}))}))},t.initPurchaseOrder=function(e,r){return Pe(t,void 0,void 0,(function(){var t,n,s;return Ne(this,(function(a){switch(a.label){case 0:return t=""+this.baseApiUrl+vt+"/initorder/"+e+"/"+r,[4,C.post(t)];case 1:return n=a.sent(),(s=Pt(n.data)).IsDraft=!0,[2,s]}}))}))},t.initExchangeOrder=function(e){return Pe(t,void 0,void 0,(function(){var t,r,n;return Ne(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+vt+"/initexchange/"+e,[4,C.post(t)];case 1:return r=s.sent(),(n=Pt(r.data)).IsDraft=!0,[2,n]}}))}))},t.createPurchaseOrder=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+vt,[4,C.post(t,e)];case 1:return r=n.sent(),[2,Pt(r.data)]}}))}))},t.calculateOrder=function(e){return Pe(t,void 0,void 0,(function(){var t,r,n;return Ne(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+vt+"/calculate",[4,C.post(t,e)];case 1:return r=s.sent(),(n=Pt(r.data)).IsDraft=!0,[2,n]}}))}))},t.createReturn=function(e,r){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns",[4,C.post(t,r)];case 1:return[2,n.sent().data]}}))}))},t.cancelReturn=function(e,r){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns/"+r+"/cancel",[4,C.post(t)];case 1:return[2,n.sent().data]}}))}))},t.acknowledgeReceiptItems=function(e,r){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns/"+r+"/acknowledgeReceiptItems",[4,C.post(t)];case 1:return[2,n.sent()]}}))}))},t.getSingleOrderGroup=function(e,r){return Pe(t,void 0,void 0,(function(){var t,n;return Ne(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r,[4,C.get(t)];case 1:return n=s.sent(),[2,Pt(n.data)]}}))}))},t.addCoupon=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){switch(a.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/coupons",[4,C.post(t,s)];case 1:return[2,a.sent()]}}))}))},t.removeCoupon=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){switch(a.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/coupons",[4,C.delete(t,{params:{couponCode:s.Code}})];case 1:return[2,a.sent()]}}))}))},t.deleteLineItem=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+this.getOrderGroupRouting(e)+"/"+r+"/lineitems/"+n,[4,C.delete(t)];case 1:return[2,s.sent()]}}))}))},t.deleteReturnLineItem=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns/"+r+"/lineitems/"+n,[4,C.delete(t)];case 1:return[2,s.sent()]}}))}))},t.updateLineItem=function(e){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e.OrderGroupType)+"/"+e.OrderGroupId+"/lineitems/"+e.LineItemId,[4,C.patch(t,e)];case 1:return[2,r.sent()]}}))}))},t.updateReturnLineItem=function(e,r,n,s,a){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(i){switch(i.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns/"+r+"/lineitems/"+n,[4,C.patch(t,{returnQuantity:s,returnReason:a})];case 1:return[2,i.sent()]}}))}))},t.updateReturnForm=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns/"+r,[4,C.patch(t,n)];case 1:return[2,s.sent()]}}))}))},t.updateExchangeOrderId=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(s){switch(s.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/returns/"+r+"/"+n,[4,C.patch(t)];case 1:return[2,s.sent()]}}))}))},t.addLineItemToOrderGroup=function(e,r,n,s,a){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/shipments/"+s+"/lineitems",[4,C.post(t,a)];case 1:return[2,i.sent()]}}))}))},t.initLineItem=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){switch(a.label){case 0:return t=""+this.baseApiUrl+vt+"/inititem?currencyCode="+e+"&marketId="+r+"&customerId="+n,[4,C.post(t,s)];case 1:return[4,a.sent().data];case 2:return[2,a.sent()]}}))}))},t.getOrderStatuses=function(){return Pe(t,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/orderstatuses",[4,C.get(e)];case 1:return[2,t.sent().data]}}))}))},t.updateOrderStatus=function(e,r){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+vt+"/"+e+"/status/"+r,[4,C.put(t)];case 1:return[2,n.sent()]}}))}))},t.getReturnReasons=function(){return Pe(t,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/returnorders/returnreasons/",[4,C.get(e)];case 1:return[2,t.sent().data]}}))}))},t.addShippingAddress=function(e,r,n,s,a){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/shipments/"+s+"/shippingAddress",[4,C.post(t,a)];case 1:return[2,i.sent()]}}))}))},t.updateShippingAddress=function(e,r,n,s,a){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/shipments/"+s+"/shippingaddress",[4,C.put(t,a)];case 1:return[2,i.sent()]}}))}))},t.updateShippingMethod=function(e,r,n,s,a){return Pe(t,void 0,void 0,(function(){var t,i;return Ne(this,(function(o){switch(o.label){case 0:return t={shippingMethodId:a},i=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/shipments/"+s+"/shippingmethod",[4,C.patch(i,t)];case 1:return[2,o.sent()]}}))}))},t.getPaymentModel=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){switch(a.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+r+"/forms/"+n+"/payments/getmodel/"+s,[4,C.get(t)];case 1:return[2,a.sent().data]}}))}))},t.addPayment=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){switch(a.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(e)+"/"+n+"/forms/"+s+"/payments",[4,C.post(t,r)];case 1:return[2,a.sent()]}}))}))},t.createRefund=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/orders/"+e+"/forms/"+r+"/payments/refund",[4,C.post(t,n)];case 1:return[2,s.sent()]}}))}))},t.updateCurrencyForOrder=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t,s;return Ne(this,(function(a){switch(a.label){case 0:return t=this.getOrderGroupRouting(e),s=this.baseApiUrl+"/"+t+"/"+r+"/currency/"+n,[4,C.patch(s)];case 1:return[2,a.sent()]}}))}))},t.getPlacedPrice=function(e,r,n,s,a){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/entries/placedprice",[4,C.post(t,{entryCode:e,quantity:r,marketId:n,currency:s,customerId:a})];case 1:return[2,i.sent()]}}))}))},t.getRefundInfo=function(e,r){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(t){switch(t.label){case 0:return[4,C.get(this.baseApiUrl+"/orders/"+e+"/returns/"+r+"/getRefundInfo")];case 1:return[2,t.sent()]}}))}))},t.completeReturn=function(e,r){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(t){switch(t.label){case 0:return[4,C.post(this.baseApiUrl+"/orders/"+e+"/returns/"+r+"/completeReturn")];case 1:return[2,t.sent()]}}))}))},t.initPaymentPlan=function(e,r){return Pe(t,void 0,void 0,(function(){var t,n,s;return Ne(this,(function(a){switch(a.label){case 0:return t=""+this.baseApiUrl+St+"/initPaymentPlan/"+e+"/"+r,[4,C.post(t)];case 1:return n=a.sent(),(s=Pt(n.data)).IsDraft=!0,[2,s]}}))}))},t}return Te(t,e),t}(Dt),Rt=function(e){function t(){var t=e.call(this)||this;return t.getCustomerCart=function(e,r){return Pe(t,void 0,void 0,(function(){var t,n,s;return Ne(this,(function(a){switch(a.label){case 0:return t=""+this.baseApiUrl+ht+"/"+e+Ct+"/Default/"+r,[4,C.get(t)];case 1:return n=a.sent(),s=Pt(n.data),[2,204===n.status?null:s]}}))}))},t.createOrRefreshCart=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t,s,a;return Ne(this,(function(i){switch(i.label){case 0:return t=this.baseApiUrl+"/carts",[4,C.put(t,null,{params:{marketId:r,contactId:e,cartName:n}})];case 1:return s=i.sent(),a=Pt(s.data),[2,201===s.status?a:null]}}))}))},t.deleteCart=function(e){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/carts/"+e,[4,C.delete(t)];case 1:return[2,r.sent()]}}))}))},t.convertToPurchaseOrder=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Ct+"/"+e+"/ConvertToPurchaseOrder",[4,C.post(t)];case 1:return r=n.sent(),[2,Pt(r.data)]}}))}))},t.convertToPaymentPlan=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Ct+"/"+e+"/ConvertToPaymentPlan",[4,C.post(t)];case 1:return r=n.sent(),[2,Pt(r.data)]}}))}))},t.updateMarketForCart=function(e,r){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(n){switch(n.label){case 0:return t=""+this.baseApiUrl+Ct+"/"+e+"/market/"+r,[4,C.patch(t)];case 1:return[2,n.sent()]}}))}))},t}return Te(t,e),t}(Dt),xt=function(e){function t(){var t=e.call(this)||this;return t.getPurchaseOrders=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t,s;return Ne(this,(function(a){switch(a.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e+"/purchaseOrders",[4,C.get(t,{params:{orderGroupId:e,startingIndex:r,numberOfRecords:n}})];case 1:return[2,{TotalOrderGroups:(s=a.sent()).data.TotalOrderGroups,Results:s.data.Results.map((function(e,t){return Pt(e)}))}]}}))}))},t.convertToPurchaseOrder=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e+"/convertToPurchaseOrder",[4,C.post(t)];case 1:return r=n.sent(),[2,Pt(r.data)]}}))}))},t.cancelPaymentPlan=function(e){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e+"/cancel",[4,C.post(t)];case 1:return[2,r.sent()]}}))}))},t.createPaymentPlan=function(e,r){return Pe(t,void 0,void 0,(function(){var t,n;return Ne(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e,[4,C.post(t,r)];case 1:return n=s.sent(),[2,Pt(n.data)]}}))}))},t.updatePaymentPlanSetting=function(e,r){return Pe(t,void 0,void 0,(function(){var t,n;return Ne(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/paymentplans/"+e,[4,C.put(t,r)];case 1:return n=s.sent(),[2,Pt(n.data)]}}))}))},t}return Te(t,e),t}(Dt),Lt=function(e){this.firstName=e.FirstName||"",this.middleName=e.MiddleName||"",this.lastName=e.LastName||"",this.fullName=e.FullName||"",this.email=e.Email||"",this.customerGroup=e.CustomerGroup||""},Mt=function(e){function t(t){return e.call(this,t)||this}return Te(t,e),t}(Lt),Ft=function(e){function t(t){var r=e.call(this,t)||this;return r.id=t.Id,r}return Te(t,e),t}(Lt);!function(e){e[e.Name=128]="Name",e[e.FirstName=64]="FirstName",e[e.LastName=64]="LastName",e[e.Organization=64]="Organization",e[e.Line1=80]="Line1",e[e.Line2=80]="Line2",e[e.City=64]="City",e[e.State=64]="State",e[e.CountryCode=50]="CountryCode",e[e.CountryName=50]="CountryName",e[e.PostalCode=20]="PostalCode",e[e.RegionCode=50]="RegionCode",e[e.RegionName=64]="RegionName",e[e.DaytimePhoneNumber=32]="DaytimePhoneNumber",e[e.EveningPhoneNumber=32]="EveningPhoneNumber",e[e.Email=256]="Email"}($e||($e={}));var kt=$e,_t=function(e){var t=e.value.toString();return r.createElement(O,{key:e.refreshCounter||0,label:e.label,value:t,disabled:e.disabled,required:e.required,enhanced:!0,outlined:!0,onEnhancedChange:function(t,r){if(e.onChange){var n=r.getAttribute("data-value");"number"==typeof e.value?e.onChange(Number(n)):e.onChange(n)}},className:"epi-exposed-dropdown"+(e.fullWidth?" fullwidth":"")+(e.dense?" dense":"")},e.options.map((function(e){return r.createElement(A.Option,{key:e.value,value:e.value},e.label)})))},Vt=function(){function e(){}return e.Required="required",e.IsEmpty="isEmpty",e.IsNumber="isNumber",e.IsFloat="isFloat",e.IsPositive="isPositive",e.IsString="isString",e.IsEmail="isEmail",e.MaxStringLength="maxStringLength",e.MinStringLength="minStringLength",e.NotAllowPotentialXSSCharacters="notAllowPotentialXSSCharacters",e.IsURL="isURL",e.IsDate="isDate",e.IsDateTime="isDateTime",e.IsFloatRegex="matchRegexp:^[+-]?([0-9]+[.])?[0-9]+$",e.IsMoney="isMoney",e.IsInteger="isInteger",e.IsDecimal="isDecimal",e.isValidInteger=function(e){return!(isNaN(e)||e>2147483647||e<-2147483648)},e.isValidMoney=function(e){var t=new w.BigNumber(e);return""===e||!(t.isNaN()||t.decimalPlaces()>4||t.isGreaterThan(new w.BigNumber("922337203685477.5807"))||t.isLessThan(0))},e.isValidDecimal=function(e){var t=new w.BigNumber(e);return""===e||!(t.isNaN()||t.decimalPlaces()>0||t.gt(new w.BigNumber("9".repeat(18)))||t.lt(new w.BigNumber("-"+"9".repeat(18))))},e.isValidUrl=function(e){return!e||/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/.test(e)},e.setMaxStringLength=function(e){return"maxStringLength:"+e.toString()},e.setMinStringLength=function(e){return"minStringLength:"+e.toString()},e.getValidationMessage=function(t,r){switch(void 0===r&&(r=null),t){case e.Required:return"This field is required";case e.IsEmail:return"E-mail is not valid";case e.NotAllowPotentialXSSCharacters:return"Field must not contain any of the \n following characters: '<\">*%&:?";case e.MaxStringLength:return"Field exceeds maximum of "+r.toString()+" characters allowed";case e.MinStringLength:return"Field must be at least "+r.toString()+" character(s)";case e.IsNumber:return"Number is not valid";case e.IsURL:return"URL is not valid";case e.IsDate:return"Date is not valid";case e.IsDateTime:return"DateTime is not valid";case e.IsFloatRegex:return"Number is not valid";case e.IsMoney:return"Money is not valid";case e.IsInteger:return"Integer is not valid";case e.IsDecimal:return"Decimal is not valid";default:return"Not yet defined validation message"}},e.initCustomValidator=function(){T.ValidatorForm.addValidationRule(e.NotAllowPotentialXSSCharacters,(function(e){return!new RegExp(/[\<\>\*\%\&\:\\\?\'\"]/).test(e)})),T.ValidatorForm.addValidationRule(e.Required,(function(e){return null!=e&&void 0!==e&&(e instanceof Array?e.length>0:"string"!=typeof e||""!==e.trim())}))},e}();Vt.initCustomValidator();var Ut=b.object({Name:b.string().trim().required(Vt.getValidationMessage(Vt.Required)).max(kt.Name,Vt.getValidationMessage(Vt.MaxStringLength,kt.Name)).test("NotAllowPotentialXSSCharacters","Field must not contain any of the following characters: ''<\">*%&:?'",(function(e){return!new RegExp(/[\<\>\*\%\&\:\\\?\'\"]/).test(e)})),FirstName:b.string().trim().max(kt.FirstName,Vt.getValidationMessage(Vt.MaxStringLength,kt.FirstName)).nullable(),LastName:b.string().trim().required(Vt.getValidationMessage(Vt.Required)).max(kt.LastName,Vt.getValidationMessage(Vt.MaxStringLength,kt.LastName)),Line1:b.string().trim().required(Vt.getValidationMessage(Vt.Required)).max(kt.Line1,Vt.getValidationMessage(Vt.MaxStringLength,kt.Line1)),Line2:b.string().trim().max(kt.Line2,Vt.getValidationMessage(Vt.MaxStringLength,kt.Line2)).nullable(),City:b.string().trim().required(Vt.getValidationMessage(Vt.Required)).max(kt.City,Vt.getValidationMessage(Vt.MaxStringLength,kt.City)),PostalCode:b.string().trim().max(kt.PostalCode,Vt.getValidationMessage(Vt.MaxStringLength,kt.PostalCode)).nullable(),CountryCode:b.string().trim().required(Vt.getValidationMessage(Vt.Required)),RegionCode:b.string().trim().max(kt.RegionCode,Vt.getValidationMessage(Vt.MaxStringLength,kt.RegionCode)).nullable(),DaytimePhoneNumber:b.string().trim().max(kt.DaytimePhoneNumber,Vt.getValidationMessage(Vt.MaxStringLength,kt.DaytimePhoneNumber)).nullable(),Email:b.string().trim().max(kt.Email,Vt.getValidationMessage(Vt.MaxStringLength,kt.Email)).email(Vt.getValidationMessage(Vt.IsEmail)).nullable()}),Bt=function(e){function r(t){var r=e.call(this,t)||this;return r.state={errors:{},countryOptions:[]},r.setCurrentAddress=function(e){r.props.dispatch(rt.ContactActions.setCurrentAddress(e)),r.props.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!0))},r.handleCountryChanged=function(e){var t=Ge({},r.props.address),n=r.props.availableCountries.find((function(t){return t.Code===e}));if(t.DaytimePhoneNumber=n.CallingCode+" ",t.CountryCode=e,t.CountryName=n.Name,r.setCurrentAddress(t),"USA"===e&&t.PostalCode){var s=I.lookup(t.PostalCode);s&&(t.RegionCode=S.getStateNameByStateCode(s.state))}r.setCurrentAddress(t)},r.handleFormChanges=function(e){return Pe(r,void 0,void 0,(function(){var t,r,n;return Ne(this,(function(s){return t=e.target.name,r=Object.assign({},this.props.address),n="checkbox"===e.target.type?e.target.checked:e.target.value,r[t]=n,this.setCurrentAddress(r),[2]}))}))},r.validateForm=function(){try{return Ut.validateSync(r.props.address,{abortEarly:!1})}catch(t){var e={};return t.inner.map((function(t){e[t.path]=t.message})),r.setState({errors:e}),null}},r.state.countryOptions=r.props.availableCountries.map((function(e){return{label:e.Name,value:e.Code}})),r.props.mode===_e.Add&&(r.props.address.FirstName=r.props.currentAddress.FirstName,r.props.address.LastName=r.props.currentAddress.LastName),r.props.validator.validate=r.validateForm,r}return Te(r,e),r.prototype.render=function(){var e=this;return t.createElement(s.Grid,{container:!0,spacing:16},t.createElement(s.Grid,{item:!0,sm:12},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"Name",label:"Address Name",value:this.props.address.Name||"",onChange:this.handleFormChanges,required:!0,error:!!this.state.errors.Name,helperText:this.state.errors.Name})),t.createElement(s.Grid,{item:!0,sm:12,md:6},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"FirstName",label:"First Name",value:this.props.address.FirstName||"",onChange:this.handleFormChanges,error:!!this.state.errors.FirstName,helperText:this.state.errors.FirstName})),t.createElement(s.Grid,{item:!0,sm:12,md:6},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"LastName",label:"Last Name",value:this.props.address.LastName||"",onChange:this.handleFormChanges,required:!0,error:!!this.state.errors.LastName,helperText:this.state.errors.LastName})),t.createElement(s.Grid,{item:!0,sm:12},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"Line1",label:"Address Line 1",value:this.props.address.Line1||"",onChange:this.handleFormChanges,required:!0,error:!!this.state.errors.Line1,helperText:this.state.errors.Line1})),t.createElement(s.Grid,{item:!0,sm:12},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"Line2",label:"Address Line 2",value:this.props.address.Line2||"",onChange:this.handleFormChanges,error:!!this.state.errors.Line2,helperText:this.state.errors.Line2})),t.createElement(s.Grid,{item:!0,sm:12,md:6},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"City",label:"City",value:this.props.address.City||"",onChange:this.handleFormChanges,required:!0,error:!!this.state.errors.City,helperText:this.state.errors.City})),t.createElement(s.Grid,{item:!0,sm:12,md:6},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"PostalCode",label:"ZIP / PostalCode",value:this.props.address.PostalCode||"",onChange:this.handleFormChanges,error:!!this.state.errors.PostalCode,helperText:this.state.errors.PostalCode})),t.createElement(s.Grid,{item:!0,sm:12,md:6},t.createElement(_t,{fullWidth:!0,required:!0,label:"Country",value:this.props.address.CountryCode||"",options:this.state.countryOptions,onChange:function(t){return e.handleCountryChanged(t)}}),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.CountryCode)),t.createElement(s.Grid,{item:!0,sm:12,md:6},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"RegionCode",label:"State / Province / Region",value:this.props.address.RegionCode||"",onChange:this.handleFormChanges,error:!!this.state.errors.RegionCode,helperText:this.state.errors.RegionCode})),t.createElement(s.Grid,{item:!0,sm:12,md:6},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"DaytimePhoneNumber",label:"Phone Number",value:this.props.address.DaytimePhoneNumber||"",onChange:this.handleFormChanges,error:!!this.state.errors.DaytimePhoneNumber,helperText:this.state.errors.DaytimePhoneNumber})),t.createElement(s.Grid,{item:!0,sm:12,md:6},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",name:"Email",label:"E-mail",value:this.props.address.Email||"",onChange:this.handleFormChanges,error:!!this.state.errors.Email,helperText:this.state.errors.Email})))},r}(t.Component),Ht=function(e){function t(){var t=e.call(this)||this;return t.get=function(e){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/customers/"+e,[4,C.get(t)];case 1:return[2,r.sent().data]}}))}))},t.list=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/customers",r={filter:e},[4,C.get(t,{params:r})];case 1:return[2,n.sent().data]}}))}))},t.getCustomerGroups=function(){return Pe(t,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/customergroups",[4,C.get(e)];case 1:return[2,t.sent().data]}}))}))},t.updatePersonalInformation=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/customers/"+e.Id,r=new Ft(e),[4,C.put(t,r)];case 1:return[2,n.sent().data]}}))}))},t.createContact=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/customers",r=new Mt(e),[4,C.post(t,r)];case 1:return[2,n.sent().data]}}))}))},t.addContactAddress=function(e,r){return Pe(t,void 0,void 0,(function(){var t,n;return Ne(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=[Ge({},r)],[4,Ut.validate(r)];case 1:return r=Ge.apply(void 0,t.concat([s.sent()])),[3,3];case 2:throw s.sent(),new Error("The address is invalid!");case 3:return n=this.baseApiUrl+"/customers/"+e+"/addresses",[4,C.post(n,r)];case 4:return[2,s.sent()]}}))}))},t.updateContactAddress=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t,s;return Ne(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),t=[Ge({},n)],[4,Ut.validate(n)];case 1:return n=Ge.apply(void 0,t.concat([a.sent()])),[3,3];case 2:throw a.sent(),new Error("The address is invalid!");case 3:return s=this.baseApiUrl+"/customers/"+e+"/addresses/"+encodeURIComponent(r),[4,C.put(s,n)];case 4:return[2,a.sent()]}}))}))},t.deleteContactAddress=function(e,r){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(n){switch(n.label){case 0:return t=this.baseApiUrl+"/customers/"+e+"/addresses/"+encodeURIComponent(r),[4,C.delete(t)];case 1:return[2,n.sent()]}}))}))},t}return Te(t,e),t}(Dt),qt=function(e){function t(){var t=e.call(this)||this;return t.getMarkets=function(){return Pe(t,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/markets",[4,C.get(e)];case 1:return[2,t.sent().data]}}))}))},t}return Te(t,e),t}(Dt),Wt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.updateOrderGroupMetaFields=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(s){switch(s.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(r)+"/"+e+"/metaFields",[4,C.patch(t,n)];case 1:return[2,s.sent().data]}}))}))},t.updateOrderShipmentMetaFields=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){switch(a.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(r)+"/"+e+"/shipments/"+n+"/metaFields",[4,C.patch(t,s)];case 1:return[2,a.sent().data]}}))}))},t.updateOrderLineItemMetaFields=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){switch(a.label){case 0:return t=this.baseApiUrl+"/"+this.getOrderGroupRouting(r)+"/"+e+"/lineitems/"+n+"/metaFields",[4,C.patch(t,s)];case 1:return[2,a.sent().data]}}))}))},t}return Te(t,e),t}(Dt),jt=function(e){function t(){var t=e.call(this)||this;return t.getPaymentMethods=function(e){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/paymentmethods/"+(e||""),[4,C.get(t)];case 1:return[2,r.sent().data]}}))}))},t}return Te(t,e),t}(Dt),Yt=function(e){function t(){var t=e.call(this)||this;return t.getShippingMethods=function(e,r){return Pe(t,void 0,void 0,(function(){var t,n;return Ne(this,(function(s){switch(s.label){case 0:return t={marketId:e,countryCode:r},n=this.baseApiUrl+"/shippingMethods",[4,C.get(n,{params:t})];case 1:return[2,s.sent().data]}}))}))},t.getShipmentStatuses=function(){return Pe(t,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/shipmentstatuses/",[4,C.get(e)];case 1:return[2,t.sent().data]}}))}))},t.updateShipmentStatus=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){return t=""+this.baseApiUrl+vt+"/"+e+"/forms/"+r+"/shipments/"+n+"/shipmentstatus/"+s,[2,C.patch(t)]}))}))},t.addToPickList=function(e,r,n){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(s){return t=""+this.baseApiUrl+vt+"/"+e+"/forms/"+r+"/shipments/"+n+"/addToPickList",[2,C.post(t)]}))}))},t.updateShipmentTrackingNumber=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){return t=""+this.baseApiUrl+vt+"/"+e+"/forms/"+r+"/shipments/"+n+"/trackingNumber",[2,C.patch(t,null,{params:{trackingNumber:s}})]}))}))},t}return Te(t,e),t}(Dt),zt=function(e){function t(){var t=e.call(this)||this;return t.search=function(e){return Pe(t,void 0,void 0,(function(){var t,r,n,s,a,i;return Ne(this,(function(o){switch(o.label){case 0:return t=nt.getState().orderGroup.currentOrderGroup,r=t.MarketId,n=t.Customer.Id,s=t.Total.Currency,a=this.baseApiUrl+"/entries",i={keyword:e,marketId:r,customerId:n,currencyCode:s},[4,C.get(a,{params:i})];case 1:return[2,o.sent().data]}}))}))},t.getEntryDetail=function(e){return Pe(t,void 0,void 0,(function(){var t,r,n;return Ne(this,(function(s){switch(s.label){case 0:return t=nt.getState().orderGroup.currentOrderGroup,r=this.baseApiUrl+"/entries/"+e,n={marketId:t.MarketId,currencyCode:t.Total.Currency,customerId:t.Customer.Id},[4,C.get(r,{params:n})];case 1:return[2,s.sent().data]}}))}))},t}return Te(t,e),t}(Dt),Qt=function(e){function t(){var t=e.call(this)||this;return t.getCurrencies=function(e){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return t=this.baseApiUrl+"/currencies/"+e,[4,C.get(t)];case 1:return[2,r.sent().data]}}))}))},t}return Te(t,e),t}(Dt),Kt=[];Object.keys(G.countries).forEach((function(e){var t=G.countries[e.toString()];Kt.push({countryCode:e,name:t.name,phoneCode:t.phone})}));var Xt=function(e){function t(){var t=e.call(this)||this;return t.getCountries=function(){return Pe(t,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return e=this.baseApiUrl+"/countries",[4,C.get(e)];case 1:return[2,t.sent().data.map((function(e){return function(e){var t=Kt.find((function(t){return t.name===e.Name}));return t?Ge(Ge({},e),{CallingCode:t.phoneCode?"+"+t.phoneCode:"",FlagSvgImage:require("flag-icon-css/flags/4x3/"+t.countryCode.toLowerCase()+".svg")}):e}(e)}))]}}))}))},t}return Te(t,e),t}(Dt),Jt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.getOrdersByCustomerId=function(e,r,n,s){return Pe(t,void 0,void 0,(function(){var t;return Ne(this,(function(a){switch(a.label){case 0:return t=this.baseApiUrl+"/orderhistory?customerId="+e+"&startingIndex="+r+"&numberOfRecords="+n+"&returnTotalCount="+s,[4,C.get(t)];case 1:return[2,a.sent().data]}}))}))},t}return Te(t,e),t}(Dt),Zt={Cart:new Rt,OrderGroup:new Nt,PaymentPlan:new xt,Contact:new Ht,MetaField:new Wt,PaymentMethod:new jt,Shipment:new Yt,Catalog:new zt,Market:new qt,Currency:new Qt,Geographics:new Xt,OrderHistory:new Jt},$t=function(e){var r=e.classes;return e.text?t.createElement("div",{className:r.optionalTypography},e.icon,t.createElement(x,{gutterBottom:!0},e.text)):null},er={marginDefault:20,paddingDefault:20,addressBoxMinWidth:325,addressBoxMinHeight:256},tr={light:"#f8f8f8",hoveredList:"#ededed"},rr={paddingTop:4,paddingBottom:4},nr=o.withStyles((function(e){e.palette;var t=e.spacing;e.breakpoints;return s.createStyles({root:{minWidth:er.addressBoxMinWidth,height:"100%"},header:{borderBottom:"solid 1px",borderBottomColor:tr.hoveredList},content:{padding:er.paddingDefault},address:{marginTop:t.unit,marginBottom:2*t.unit},optionalTypography:{display:"flex"},optionalTypographyIcon:{marginRight:t.unit}})}))(n.connect((function(e,t){return{address:t.address,classes:t.classes,isReadonly:t.isReadonly}}))((function(e){var r,n=e.classes,s=(r=e.address).IsPreferredBillingAddress&&r.IsPreferredShippingAddress?"Preferred Shipping & Billing Address":r.IsPreferredShippingAddress?"Preferred Shipping Address":r.IsPreferredBillingAddress?"Preferred Billing Address":void 0,a="";e.address.City&&(a+=e.address.City),e.address.RegionCode&&(a+=", "+e.address.RegionCode),e.address.PostalCode&&(a+=", "+e.address.PostalCode);return t.createElement(P,{className:n.root},t.createElement(N,{className:n.header,title:s,titleTypographyProps:{variant:"body2"},action:!e.isReadonly&&t.createElement("div",null,t.createElement(f.IconButton,{"area-label":"Edit",onClick:function(){return function(t){e.dispatch(rt.ContactActions.setCurrentAddress(t)),e.dispatch(rt.AddressFormActions.initializeAddressForm(t)),e.dispatch(rt.ContactActions.setAddressDetailsViewMode(_e.Edit))}(e.address)}},t.createElement(f.EditIcon,null)),t.createElement(f.IconButton,{"aria-label":"Delete",onClick:function(){return function(t){e.dispatch(rt.ContactActions.setCurrentAddress(t)),e.dispatch(rt.ApplicationActions.setCurrentDialog(Le.DeleteAddress))}(e.address)}},t.createElement(f.DeleteIcon,null)))}),t.createElement(R,{className:n.content},t.createElement(x,{variant:"body2",gutterBottom:!0},e.address.Name),t.createElement(d,{container:!0,spacing:8},t.createElement(d,{item:!0},t.createElement($t,{text:e.address.FirstName,classes:n})),t.createElement(d,{item:!0},t.createElement($t,{text:e.address.LastName,classes:n}))),t.createElement("div",{className:n.address},t.createElement(x,{gutterBottom:!0},e.address.Line1),t.createElement(x,{gutterBottom:!0},e.address.Line2),t.createElement($t,{text:a,classes:n}),t.createElement(x,{gutterBottom:!0},e.address.CountryName)),t.createElement($t,{text:e.address.DaytimePhoneNumber,classes:n,icon:t.createElement(M,{fontSize:"small",className:n.optionalTypographyIcon})}),t.createElement($t,{text:e.address.Email,classes:n,icon:t.createElement(L,{fontSize:"small",className:n.optionalTypographyIcon})})))}))),sr=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({root:{height:"100%",minWidth:er.addressBoxMinWidth},actionArea:{height:"100%"}})}))(n.connect((function(e,t){return{classes:t.classes,customer:e.orderGroup.currentOrderGroup?e.orderGroup.currentOrderGroup.Customer:void 0}}))((function(e){var r=e.classes;return t.createElement(P,{className:r.root},t.createElement(k,{className:r.actionArea,onClick:function(){var t,r={};e.customer&&(r.FirstName=e.customer.FirstName,r.LastName=e.customer.LastName),t=r,e.dispatch(rt.ContactActions.setCurrentAddress(t)),e.dispatch(rt.ContactActions.setAddressDetailsViewMode(_e.Add))}},t.createElement(d,{container:!0,direction:"column",alignItems:"center"},t.createElement(d,{item:!0},t.createElement(F,{fontSize:"large"})),t.createElement(d,{item:!0},t.createElement(x,{variant:"button"},"New Address")))))}))),ar=function(e){return t.createElement(s.Dialog,{open:e.open,onClose:e.onClose,style:{zIndex:1e4,margin:"0 auto"},maxWidth:e.large?"md":"sm",fullWidth:!0},t.createElement(s.DialogTitle,null,e.title),t.createElement(s.DialogContent,{style:{paddingTop:"5px"}},e.children),t.createElement(s.DialogActions,null,t.createElement(f.TextButton,{onClick:e.onClose},e.closeLabel),e.onOK&&t.createElement(f.TextButton,{onClick:e.onOK},e.okLabel)))};ar.defaultProps={okLabel:"OK",closeLabel:"Close"};var ir=function(e){return t.createElement(ar,{open:!0,title:e.title,onClose:e.onClose,closeLabel:e.closeButtonLabel,okLabel:e.confirmButtonLabel,onOK:e.onConfirm},e.children)},or=function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({root:{},item:{minHeight:256}})},cr=o.withStyles(or)((function(e){if(!e.address)return t.createElement(t.Fragment,null);var r=e.address.DisplayName;return r||(r=e.address?[e.address.Line1,e.address.Line2,e.address.City,e.address.RegionCode,e.address.PostalCode,e.address.CountryName,e.address.CountryCode].filter((function(e){return e})).join(", "):""),t.createElement("div",null,t.createElement(x,{variant:"body2"},r))})),lr=n.connect((function(e,t){return{address:e.contact.currentAddress,contact:e.contact.currentContact}}))((function(e){var r=function(){e.dispatch(rt.ContactActions.setCurrentAddress(null)),e.dispatch(rt.ApplicationActions.setCurrentDialog(Le.None))};return null==e.address?null:t.createElement(ir,{title:"Delete address?",closeButtonLabel:"Cancel",confirmButtonLabel:"Delete",onConfirm:function(){return Pe(void 0,void 0,void 0,(function(){var t,n;return Ne(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,Zt.Contact.deleteContactAddress(e.contact.Id,e.address.AddressId)];case 1:return s.sent(),[4,Zt.Contact.get(e.contact.Id)];case 2:return t=s.sent(),e.dispatch(rt.ContactActions.setCurrentContact(t)),[3,4];case 3:return n=s.sent(),e.dispatch(rt.ApplicationActions.showNotification(n.message)),[3,4];case 4:return r(),[2]}}))}))},onClose:r},t.createElement(cr,{address:e.address}))})),ur=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({root:{},container:{display:"flex",flexWrap:"wrap"}})}))(n.connect((function(e,t){return{mode:e.contact.addressDetailsViewMode,address:t.address,classes:t.classes,country:e.geographics.countries.find((function(t){return t.Code===e.contact.currentAddress.CountryCode})),availableCountries:e.geographics.countries,currentAddress:e.contact.currentAddress,validator:t.validator}}))(Bt)),dr=function(e){function r(t){var r=e.call(this,t)||this;return r.state={loaded:!1},r.validator={validate:function(){return null}},r.closeView=function(){r.props.dispatch(rt.ContactActions.setAddressDetailsViewMode(_e.Hide)),r.props.dispatch(rt.AddressFormActions.clearAddressForm()),r.props.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!1))},r.setCurrentAddress=function(e){r.props.dispatch(rt.ContactActions.setCurrentAddress(e)),r.props.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!0))},r.handleFormChanges=function(e){var t=Object.assign({},r.props.address),n="checkbox"===e.target.type?e.target.checked:e.target.value;t[e.target.name]=n,r.setCurrentAddress(t)},r.saveChanges=function(){return Pe(r,void 0,void 0,(function(){var e,t,r,n,s;return Ne(this,(function(a){switch(a.label){case 0:if(null==(e=this.validator.validate()))return[2];t=Ge(Ge({},this.props.address),e),a.label=1;case 1:return a.trys.push([1,9,,10]),this.props.mode!==_e.Add?[3,3]:[4,Zt.Contact.addContactAddress(this.props.currentContactId,t)];case 2:return a.sent(),[3,5];case 3:return[4,Zt.Contact.updateContactAddress(this.props.currentContactId,t.AddressId.trim(),t)];case 4:a.sent(),a.label=5;case 5:return(r=this.props.orderGroup.currentOrderGroup)?[4,this.updateOrderGroup(r)]:[3,7];case 6:a.sent(),a.label=7;case 7:return[4,Zt.Contact.get(this.props.currentContactId)];case 8:return n=a.sent(),this.props.dispatch(rt.ContactActions.setCurrentContact(n)),this.closeView(),[3,10];case 9:return s=a.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(s.message)),[3,10];case 10:return[2]}}))}))},r}return Te(r,e),r.prototype.componentDidMount=function(){this.setState({loaded:!0})},r.prototype.updateOrderGroup=function(e){return Pe(this,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return e.IsDraft?[3,2]:[4,Zt.OrderGroup.getSingleOrderGroup(e.Type,e.OrderGroupId)];case 1:return t=n.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(t)),[3,4];case 2:return[4,Zt.OrderGroup.calculateOrder(e)];case 3:r=n.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(r)),n.label=4;case 4:return[2]}}))}))},r.prototype.render=function(){return t.createElement(ar,{open:!0,title:this.props.mode===_e.Edit?"Edit Address":"Add New Address",okLabel:"Save",onOK:this.saveChanges,closeLabel:"Cancel",onClose:this.closeView},this.state.loaded&&t.createElement(s.Grid,{container:!0,spacing:16},t.createElement(s.Grid,{item:!0,sm:12},t.createElement(ur,{address:this.props.address,validator:this.validator})),t.createElement(s.Grid,{item:!0,sm:12},t.createElement(s.FormControlLabel,{control:t.createElement(f.Checkbox,{name:"IsPreferredShippingAddress",checked:this.props.address.IsPreferredShippingAddress,onChange:this.handleFormChanges}),label:"Preferred Shipping Address"})),t.createElement(s.Grid,{item:!0,sm:12},t.createElement(s.FormControlLabel,{control:t.createElement(f.Checkbox,{name:"IsPreferredBillingAddress",checked:this.props.address.IsPreferredBillingAddress,onChange:this.handleFormChanges}),label:"Preferred Billing Address"}))))},r}(t.Component),pr=o.withStyles((function(e){e.spacing;return s.createStyles({actions:{marginTop:15}})}))(n.connect((function(e,t){return{mode:e.contact.addressDetailsViewMode,address:e.contact.currentAddress,classes:t.classes,currentContactId:e.contact.currentContact.Id,orderGroup:e.orderGroup}}))(dr)),hr=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Te(r,e),r.prototype.componentWillMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.initData()];case 1:return e.sent(),[2]}}))}))},r.prototype.shouldComponentUpdate=function(e,t){var r=this;return e.contactId!==this.props.contactId&&setTimeout((function(){r.initData()}),200),!0},r.prototype.initData=function(){return Pe(this,void 0,void 0,(function(){var e,t,r,n,s,a,i;return Ne(this,(function(o){switch(o.label){case 0:this.props.dispatch(rt.ContactActions.setAddressDetailsViewMode(_e.Hide)),this.props.dispatch(rt.AddressFormActions.clearAddressForm()),this.props.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!1)),o.label=1;case 1:return o.trys.push([1,7,,8]),e=new URLSearchParams(this.props.location.search),t=parseInt(e.get("orderId"),10),r=e.get("orderType"),this.props.orderGroup||NaN===t||!r?[3,3]:[4,Zt.OrderGroup.getSingleOrderGroup(r,t)];case 2:n=o.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(n)),o.label=3;case 3:return[4,Zt.Contact.get(this.props.contactId)];case 4:return s=o.sent(),this.props.dispatch(rt.ContactActions.setCurrentContact(s)),0!==this.props.availableCountries.length?[3,6]:[4,(new Xt).getCountries()];case 5:a=o.sent(),this.props.dispatch(rt.GeographicsActions.setCountries(a)),o.label=6;case 6:return[3,8];case 7:return i=o.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(i.message)),[3,8];case 8:return[2]}}))}))},r.prototype.render=function(){var e=this,r=this.props.classes;return this.props.contact&&t.createElement("div",null,t.createElement(d,{container:!0,spacing:24,className:r.root},this.props.contact.Addresses.map((function(n,s){return t.createElement(d,{item:!0,key:s,className:r.item},t.createElement(nr,{address:n,isReadonly:e.props.isReadonly}))})),!this.props.isReadonly&&t.createElement(d,{item:!0,className:r.item},t.createElement(sr,null))),this.props.addressDetailsViewMode!==_e.Hide&&t.createElement(pr,null),this.props.addressDeleteDialogIsVisible&&t.createElement(lr,null))},r}(t.Component),mr=o.withStyles(or)(n.connect((function(e,t){return Ge({contact:e.contact.currentContact,addressDeleteDialogIsVisible:e.application.currentDialog===Le.DeleteAddress,addressDetailsViewMode:e.contact.addressDetailsViewMode,orderGroup:e.orderGroup.currentOrderGroup,availableCountries:e.geographics.countries},t)}))(hr)),gr=function(e){return t.createElement(_,Ge({direction:"left"},e))},fr=o.withStyles((function(e){var t=e.palette,r=(e.spacing,e.breakpoints,e.zIndex);return s.createStyles({root:{},content:{marginTop:20},title:{flexGrow:1},appBar:{position:"relative",zIndex:r.drawer+1},appBarIcon:{color:t.common.white}})}))(n.connect((function(e,t){return{title:t.title,children:t.children,showDialogActions:t.showDialogActions,classes:t.classes,closeView:t.closeView,menuAction:t.menuAction}}))((function(e){var r=e.classes,n=e.children;return t.createElement(h,{className:r.root,open:!0,fullScreen:!0,onClose:e.closeView,TransitionComponent:gr},t.createElement(U,{className:r.appBar},t.createElement(B,null,t.createElement(f.IconButton,{onClick:e.closeView,"aria-label":"Close"},t.createElement(f.CloseIcon,{className:r.appBarIcon})),t.createElement(x,{variant:"h6",color:"inherit",className:r.title},e.title),e.menuAction&&t.createElement(V,{smUp:!0,implementation:"js"},t.createElement(f.IconButton,{onClick:e.menuAction},t.createElement(H,{className:r.appBarIcon}))))),t.createElement(g,{className:r.content},n),e.showDialogActions&&t.createElement(m,null,t.createElement(f.TextButton,{unelevated:!0,onClick:e.closeView},"Close")))}))),yr=n.connect((function(e,t){return{discardChanges:t.discardChanges}}))((function(e){return t.createElement(ir,{title:"Leave page?",closeButtonLabel:"Cancel",confirmButtonLabel:"Leave",onConfirm:function(){e.discardChanges(),e.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!1))},onClose:function(){e.dispatch(rt.ApplicationActions.setCurrentDialog(Le.None)),e.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!0))}},t.createElement(x,{variant:"body1"},"You have unsaved changes. Do you want to leave the page without saving?"))}));function Er(){return(Er=Object.assign||function(e){for(var t=1;t=0;u--){var d=s[u];"."===d?Ar(s,u):".."===d?(Ar(s,u),l++):l&&(Ar(s,u),l--)}if(!o)for(;l--;l)s.unshift("..");!o||""===s[0]||s[0]&&br(s[0])||s.unshift("");var p=s.join("/");return r&&"/"!==p.substr(-1)&&(p+="/"),p},Tr=vr((function(e){"production"===process.env.NODE_ENV?e.exports=Ir:e.exports=Or}));function wr(e){return e.valueOf?e.valueOf():Object.prototype.valueOf.call(e)}var Gr=function e(t,r){if(t===r)return!0;if(null==t||null==r)return!1;if(Array.isArray(t))return Array.isArray(r)&&t.length===r.length&&t.every((function(t,n){return e(t,r[n])}));if("object"!=typeof t&&"object"!=typeof r)return!1;var n=wr(t),s=wr(r);return n!==t||s!==r?e(n,s):Object.keys(Object.assign({},t,r)).every((function(n){return e(t[n],r[n])}))};function Dr(e){return e.valueOf?e.valueOf():Object.prototype.valueOf.call(e)}var Pr=function e(t,r){if(t===r)return!0;if(null==t||null==r)return!1;if(Array.isArray(t))return Array.isArray(r)&&t.length===r.length&&t.every((function(t,n){return e(t,r[n])}));if("object"==typeof t||"object"==typeof r){var n=Dr(t),s=Dr(r);return n!==t||s!==r?e(n,s):Object.keys(Object.assign({},t,r)).every((function(n){return e(t[n],r[n])}))}return!1},Nr=(vr((function(e){"production"===process.env.NODE_ENV?e.exports=Gr:e.exports=Pr})),"production"===process.env.NODE_ENV);function Rr(e,t){if(!Nr){if(e)return;var r="Warning: "+t;"undefined"!=typeof console&&console.warn(r);try{throw Error(r)}catch(e){}}}var xr="production"===process.env.NODE_ENV;function Lr(e,t){if(!e){if(xr)throw new Error("Invariant failed");throw new Error("Invariant failed: "+(t||""))}}function Mr(e){return"/"===e.charAt(0)?e:"/"+e}function Fr(e){return"/"===e.charAt(0)?e.substr(1):e}function kr(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}function _r(e){var t=e.pathname,r=e.search,n=e.hash,s=t||"/";return r&&"?"!==r&&(s+="?"===r.charAt(0)?r:"?"+r),n&&"#"!==n&&(s+="#"===n.charAt(0)?n:"#"+n),s}function Vr(e,t,r,n){var s;"string"==typeof e?(s=function(e){var t=e||"/",r="",n="",s=t.indexOf("#");-1!==s&&(n=t.substr(s),t=t.substr(0,s));var a=t.indexOf("?");return-1!==a&&(r=t.substr(a),t=t.substr(0,a)),{pathname:t,search:"?"===r?"":r,hash:"#"===n?"":n}}(e)).state=t:(void 0===(s=Er({},e)).pathname&&(s.pathname=""),s.search?"?"!==s.search.charAt(0)&&(s.search="?"+s.search):s.search="",s.hash?"#"!==s.hash.charAt(0)&&(s.hash="#"+s.hash):s.hash="",void 0!==t&&void 0===s.state&&(s.state=t));try{s.pathname=decodeURI(s.pathname)}catch(e){throw e instanceof URIError?new URIError('Pathname "'+s.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):e}return r&&(s.key=r),n?s.pathname?"/"!==s.pathname.charAt(0)&&(s.pathname=Tr(s.pathname,n.pathname)):s.pathname=n.pathname:s.pathname||(s.pathname="/"),s}var Ur=!("undefined"==typeof window||!window.document||!window.document.createElement);function Br(e,t){t(window.confirm(e))}var Hr={hashbang:{encodePath:function(e){return"!"===e.charAt(0)?e:"!/"+Fr(e)},decodePath:function(e){return"!"===e.charAt(0)?e.substr(1):e}},noslash:{encodePath:Fr,decodePath:Mr},slash:{encodePath:Mr,decodePath:Mr}};function qr(e){var t=e.indexOf("#");return-1===t?e:e.slice(0,t)}function Wr(){var e=window.location.href,t=e.indexOf("#");return-1===t?"":e.substring(t+1)}function jr(e){window.location.replace(qr(window.location.href)+"#"+e)}var Yr,zr=function(e){void 0===e&&(e={}),Ur||("production"!==process.env.NODE_ENV?Lr(!1,"Hash history needs a DOM"):Lr(!1));var t=window.history,r=-1===window.navigator.userAgent.indexOf("Firefox"),n=e,s=n.getUserConfirmation,a=void 0===s?Br:s,i=n.hashType,o=void 0===i?"slash":i,c=e.basename?function(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}(Mr(e.basename)):"",l=Hr[o],u=l.encodePath,d=l.decodePath;function p(){var e=d(Wr());return"production"!==process.env.NODE_ENV&&Rr(!c||kr(e,c),'You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "'+e+'" to begin with "'+c+'".'),c&&(e=function(e,t){return kr(e,t)?e.substr(t.length):e}(e,c)),Vr(e)}var h,m,g=(h=null,m=[],{setPrompt:function(e){return"production"!==process.env.NODE_ENV&&Rr(null==h,"A history supports only one prompt at a time"),h=e,function(){h===e&&(h=null)}},confirmTransitionTo:function(e,t,r,n){if(null!=h){var s="function"==typeof h?h(e,t):h;"string"==typeof s?"function"==typeof r?r(s,n):("production"!==process.env.NODE_ENV&&Rr(!1,"A history needs a getUserConfirmation function in order to use a prompt message"),n(!0)):n(!1!==s)}else n(!0)},appendListener:function(e){var t=!0;function r(){t&&e.apply(void 0,arguments)}return m.push(r),function(){t=!1,m=m.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,t=new Array(e),r=0;r0){for(t=e[0].DisplayName;t.length<120&&r1?"products":"product")}}return t},r.state.page<0&&(r.state.page=0),r}return Te(r,e),r.prototype.getPageParam=function(){var e=parseInt(this.query.get("page"),10)-1||0;return e<0&&(e=0),e},r.prototype.getRowsPerPageParam=function(){var e=parseInt(this.query.get("rowsPerPage"),10)||10;return an.indexOf(e)>=0?e:10},r.prototype.shouldComponentUpdate=function(e,t){var r=this;this.query=new URLSearchParams(zr.location.search);var n=this.getPageParam(),s=this.getRowsPerPageParam();return this.state.page===n&&this.state.rowsPerPage===s||this.setState({page:n,rowsPerPage:s},(function(){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.getData()];case 1:return e.sent(),[2]}}))}))})),!0},r.prototype.componentWillMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.getData()];case 1:return e.sent(),[2]}}))}))},r.prototype.render=function(){var e=this,r=this.props.classes;return t.createElement("div",{className:r.root},t.createElement(K,{className:r.paper},t.createElement("div",{className:r.tableWrapper},t.createElement(q,{className:r.table},t.createElement(Y,null,t.createElement(Q,null,sn.map((function(e){return t.createElement(j,{className:r.headerLable,key:e.id,align:e.numeric?"right":"left",padding:e.disablePadding?"none":"default",style:{minWidth:e.minWidth}},e.label)})))),t.createElement(W,null,this.state.orderList.map((function(n,s){return t.createElement(Q,{hover:!0,key:s},t.createElement(j,null,t.createElement(D.Link,{className:r.link,to:vt+"/"+n.OrderGroupId},n.OrderNumber)),t.createElement(j,null,X(n.Created).format("LLL")),t.createElement(j,null," ",e.getItemDescriptions(n.LineItems)),t.createElement(j,{align:"right"},n.Total.Amount.toFixed(n.Total.Fractions)+" "+n.Total.Currency),t.createElement(j,null,n.OrderStatus))}))))),t.createElement(z,{rowsPerPageOptions:an,component:"div",count:this.state.totalRecords,rowsPerPage:this.state.rowsPerPage,page:this.state.page,backIconButtonProps:{"aria-label":"previous page"},nextIconButtonProps:{"aria-label":"next page"},onChangePage:this.handleChangePage,onChangeRowsPerPage:this.handleChangeRowsPerPage})))},r}(t.Component),cn=o.withStyles((function(e){return o.createStyles({tableWrapper:{overflowX:"auto"},link:{textDecoration:"none",color:e.palette.primary.main+" !important"},headerLable:{fontWeight:"bold"}})}))(on);function ln(e){return t.createElement(cn,Ge({},e))}var un,dn=function(e){return t.createElement(d,{item:!0,xs:12,style:{minHeight:50}},t.createElement(d,{container:!0},t.createElement(d,{item:!0,xs:12,sm:3},t.createElement(x,{variant:"body1"},e.label,":")),t.createElement(d,{item:!0,xs:12,sm:9},t.createElement(x,{variant:"body1"},e.value))))},pn=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.classes=t.props.classes,t}return Te(r,e),r.prototype.componentWillMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.getData(this.props.contactId)];case 1:return e.sent(),[2]}}))}))},r.prototype.shouldComponentUpdate=function(e,t){return e.contactId!==this.props.contactId&&this.getData(e.contactId),!0},r.prototype.getData=function(e){return Pe(this,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return[4,Zt.Contact.get(e)];case 1:return t=r.sent(),this.props.dispatch(rt.ContactActions.setCurrentContact(t)),[2]}}))}))},r.prototype.openContactPersonalInformationEditView=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){try{this.props.dispatch(rt.ContactActions.showPersonalInformationEditView())}catch(e){this.props.dispatch(rt.ApplicationActions.showNotification(e.message))}return[2]}))}))},r.prototype.render=function(){return this.props.contact&&t.createElement(P,{className:this.classes.root},t.createElement(N,{className:this.classes.header,action:!this.props.isReadonly&&t.createElement(D.Link,{to:"./edit",className:this.classes.action,replace:!0},t.createElement(J,{title:"Edit the contact's personal information"},t.createElement(f.IconButton,null,t.createElement(f.EditIcon,{className:this.classes.icon})))),title:"Personal Information",titleTypographyProps:{className:this.classes.title,variant:"subheading"}}),t.createElement(R,null,t.createElement(d,{container:!0,direction:"column",spacing:8},t.createElement(dn,{label:"Full Name",value:this.props.contact.FullName}),t.createElement(dn,{label:"First Name",value:this.props.contact.FirstName}),t.createElement(dn,{label:"Middle Name",value:this.props.contact.MiddleName}),t.createElement(dn,{label:"Last Name",value:this.props.contact.LastName}),t.createElement(dn,{label:"E-mail",value:this.props.contact.Email}),t.createElement(dn,{label:"Customer Group",value:this.props.contact.CustomerGroup?this.props.contact.CustomerGroup:"None"}))))},r}(t.Component),hn=o.withStyles((function(e){var t=e.palette;e.spacing,e.breakpoints;return s.createStyles({root:{marginBottom:er.marginDefault},header:Ge(Ge({},rr),{height:48,background:t.primary.main}),title:{color:t.common.white},action:{display:"block",marginTop:"8px"},icon:{fill:t.common.white}})}))(n.connect((function(e,t){return{contactId:t.contactId,contact:e.contact.currentContact,isReadonly:t.isReadonly,classes:t.classes}}))(pn)),mn=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Te(r,e),r.prototype.render=function(){return t.createElement(hn,Ge({},this.props))},r}(t.Component),gn=function(e){function r(t){var r=e.call(this,t)||this;r.state={discardDialogOpen:!1},r.classes=r.props.classes,r.addressListLink="/customers/"+r.props.currentContactId+"/addresses",r.personalInfoLink="/customers/"+r.props.currentContactId+"/info",r.PeronalInfoEditLink="/customers/"+r.props.currentContactId+"/edit",r.addressSearchQuery="",r.customerInfoLink="/customers/"+r.props.currentContactId+"/info",r.customerAddressLink="/customers/"+r.props.currentContactId+"/addresses",r.customerOrderLink="/customers/"+r.props.currentContactId+"/orders",r.unListenHistory=zr.listen((function(e,t){r.forceUpdate()}));var n=new URLSearchParams(r.props.location.search);return null!==n.get("orderType")&&null!==n.get("orderId")&&(r.addressSearchQuery="?orderType="+n.get("orderType")+"&orderId="+n.get("orderId")),r}return Te(r,e),r.prototype.componentWillUnmount=function(){this.unListenHistory()},r.prototype.discardChanges=function(){return Pe(this,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:this.props.dispatch(rt.ApplicationActions.setCurrentDialog(Le.None)),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,Zt.Contact.get(this.props.currentContactId)];case 2:return e=r.sent(),this.props.dispatch(rt.ContactActions.setCurrentContact(e)),this.props.dispatch(rt.AddressFormActions.clearAddressForm()),this.props.drawerNextMenu!==Ve.None?this.displayMainContent(this.props.drawerNextMenu):this.props.dispatch(rt.ContactActions.setDrawerSelectedMenu(Ve.None)),[3,4];case 3:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,4];case 4:return[2]}}))}))},r.prototype.displayMainContent=function(e){e===Ve.PersonalInformation?this.props.dispatch(rt.ContactActions.showContactProfile()):e===Ve.AddressBook&&this.props.dispatch(rt.ContactActions.showAddressBook())},r.prototype.closeProfileOverview=function(){this.leavePage()},r.prototype.leavePage=function(){this.props.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!1));var e=Kr(mt);void 0!==e?zr.push(e):zr.push("/")},r.prototype.getMenuListItem=function(){var e=this;return t.createElement(s.MenuList,null,t.createElement(D.Link,{to:this.personalInfoLink,className:this.classes.menuItem+" "+(zr.location.pathname===this.personalInfoLink||zr.location.pathname===this.PeronalInfoEditLink?this.classes.menuItemActive:""),replace:!0},t.createElement(s.MenuItem,{button:!0,key:"Personal Information"},t.createElement(s.ListItemText,{classes:{primary:this.classes.primary},primary:"Personal Information"}))),t.createElement(D.Link,{to:this.addressListLink+this.addressSearchQuery,className:this.classes.menuItem+" "+(zr.location.pathname===this.addressListLink?this.classes.menuItemActive:""),replace:!0},t.createElement(s.MenuItem,{button:!0,key:"Address Book"},t.createElement(s.ListItemText,{classes:{primary:this.classes.primary},primary:"Address Book"}))),t.createElement(D.Link,{to:this.customerOrderLink,className:this.classes.menuItem+" "+(zr.location.pathname===this.customerOrderLink?this.classes.menuItemActive:""),replace:!0},t.createElement(s.MenuItem,{button:!0,key:"Orders"},t.createElement(s.ListItemText,{classes:{primary:this.classes.primary},primary:"Orders"}))),this.props.extraPages&&this.props.extraPages.map((function(r,n){var a="/customers/"+e.props.currentContactId+"/"+r.getLink({CustomerId:e.props.currentContactId});return t.createElement(D.Link,{key:n,to:a,className:e.classes.menuItem+" "+(zr.location.pathname===a?e.classes.menuItemActive:""),replace:!0},t.createElement(s.MenuItem,null,t.createElement(s.ListItemText,{classes:{primary:e.classes.primary},primary:r.title})))})))},r.prototype.render=function(){var e,r=this;return t.createElement(fr,{title:"Contact Details",showDialogActions:this.props.showDialogActions,closeView:function(){return r.closeProfileOverview()}},t.createElement(V,{smUp:!0,implementation:"js"},t.createElement(s.Drawer,{className:this.classes.drawer,variant:"temporary",classes:{paper:this.classes.drawerPaper},open:this.props.drawerIsExpanded,anchor:"right",onClose:function(){return r.props.dispatch(rt.ContactActions.setDrawerIsExpanded(!1))}},t.createElement("div",{className:this.classes.toolbar}),this.getMenuListItem())),t.createElement(V,{xsDown:!0,implementation:"js"},t.createElement(s.Drawer,{className:this.classes.drawer,variant:"permanent",classes:{paper:this.classes.drawerPaper},open:!0,anchor:"left"},t.createElement("div",{className:this.classes.toolbar}),this.getMenuListItem())),t.createElement("main",{className:this.classes.content},t.createElement("div",{className:this.classes.childContent},t.createElement(D.Switch,{location:zr.location},t.createElement(D.Route,{exact:!0,path:gt,render:function(e){return t.createElement(mn,{contactId:e.match.params.id})}}),t.createElement(D.Route,{exact:!0,path:ft,render:function(e){return t.createElement(nn,{contactId:e.match.params.id})}}),t.createElement(D.Route,{path:yt,render:function(e){return t.createElement(mr,Ge({contactId:e.match.params.id},e))}}),t.createElement(D.Route,{exact:!0,path:Et,render:function(e){return t.createElement(ln,{customerId:e.match.params.id})}}),this.props.extraPages&&(null===(e=this.props.extraPages)||void 0===e?void 0:e.map((function(e){return t.createElement(D.Route,{path:"/customers/"+r.props.currentContactId+e.path,exact:e.exact,render:function(t){return e.render({CustomerId:r.props.currentContactId})}})})))),this.props.discardChangesDialogIsVisible&&t.createElement(yr,{discardChanges:this.discardChanges}))),this.state.discardDialogOpen&&t.createElement(ir,{title:"Leave page?",closeButtonLabel:"Cancel",confirmButtonLabel:"Leave",onConfirm:function(){return r.leavePage()},onClose:function(){return r.setState({discardDialogOpen:!1})}},t.createElement(s.Typography,{variant:"body1"},"You have unsaved changes. Do you want to leave the page without saving?")))},r}(t.Component),fn=o.withStyles((function(e){var t,r,n=e.palette,a=e.spacing,i=e.zIndex,o=e.mixins,c=e.breakpoints;return s.createStyles({root:{display:"flex"},appBar:{zIndex:i.drawer+1},drawer:{width:240,flexShrink:0},drawerPaper:{width:240,background:tr.light},content:(t={flexGrow:1,padding:3*a.unit},t[c.down("xs")]={padding:0},t),childContent:(r={marginLeft:240},r[c.down("xs")]={marginLeft:0},r),toolbar:o.toolbar,menuItem:{display:"block",borderLeftWidth:5,borderLeftStyle:"solid",borderLeftColor:tr.light,textDecoration:"none"},menuItemActive:{backgroundColor:n.common.white,borderLeftColor:n.primary.main},selected:{},primary:{}})}))(n.connect((function(e,t){var r,n,s=e.setting.pageConfig.contactDetail;return Ge({isCurrentFormDirty:e.application.isCurrentFormDirty,showDialogActions:!e.contact.personalInformationEditViewIsVisible&&e.contact.addressDetailsViewMode===_e.Hide,currentContactId:t.customerId,drawerSelectedMenu:e.contact.drawerSelectedMenu,drawerNextMenu:e.contact.drawerNextMenu,drawerIsExpanded:e.contact.drawerIsExpanded,discardChangesDialogIsVisible:e.application.currentDialog===Le.DiscardChanges,extraPages:null===(n=null===(r=s)||void 0===r?void 0:r.config)||void 0===n?void 0:n.extraPages},t)}))(gn)),yn=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Te(r,e),r.prototype.render=function(){return t.createElement(fn,Ge({},this.props))},r}(t.Component),En=function(e){var r=e.amount;return t.createElement(x,Ge({variant:"body1",component:"span"},e),r.Amount.toFixed(r.Fractions)+" "+r.Currency)};!function(e){e[e.DateTime=4]="DateTime",e[e.Decimal=5]="Decimal",e[e.Float=6]="Float",e[e.Int=8]="Int",e[e.Money=9]="Money",e[e.Integer=26]="Integer",e[e.Boolean=27]="Boolean",e[e.Date=28]="Date",e[e.Email=29]="Email",e[e.URL=30]="URL",e[e.ShortString=31]="ShortString",e[e.LongString=32]="LongString",e[e.LongHtmlString=33]="LongHtmlString",e[e.DictionarySingleValue=34]="DictionarySingleValue",e[e.DictionaryMultiValue=35]="DictionaryMultiValue",e[e.EnumSingleValue=36]="EnumSingleValue",e[e.EnumMultiValue=37]="EnumMultiValue",e[e.StringDictionary=38]="StringDictionary",e[e.File=39]="File",e[e.ImageFile=40]="ImageFile"}(un||(un={}));var vn=un;T.ValidatorForm.addValidationRule(Vt.IsURL,Vt.isValidUrl),T.ValidatorForm.addValidationRule(Vt.IsInteger,Vt.isValidInteger),T.ValidatorForm.addValidationRule(Vt.IsMoney,Vt.isValidMoney);var Cn,Sn=function(e){function r(r){var n=e.call(this,r)||this;n.state={value:null===n.props.property.Value?"":n.props.property.Value},n.validators=[],n.errorMessages=[],n.inputRef=t.createRef(),n.isMultiLine=!1,n.maxRows=4,n.onChangeHandler=function(e){n.setState({value:e.currentTarget.value})},n.onBlurHandler=function(e){if(!0===n.inputRef.current.isValid()){if(!(n.state.value&&""!==n.state.value||n.props.property.Value&&""!==n.props.property.Value))return;if(n.state.value!==n.props.property.Value){var t=Object.assign({},n.props.property);t.Value=n.state.value,n.props.onPropertyChanged(t)}}};var s=n.props.property.DataType;if(n.props.property.AllowNulls||n.addValidation(Vt.Required),s===vn.Integer||s===vn.Int)n.addValidation(Vt.IsInteger);else if(s===vn.Float)n.addValidation(Vt.IsFloatRegex);else if(s===vn.Decimal){var a=parseInt(n.props.property.Attributes.mdpprecision,10),i=parseInt(n.props.property.Attributes.mdpscale,10),o="Decimal"+a+","+i;T.ValidatorForm.addValidationRule(o,(function(e){var t=new w.BigNumber(e);return""===e||!(t.isNaN()||t.decimalPlaces()>i||t.precision()>a)})),n.validators.push(o),n.errorMessages.push("Value is not valid decimal("+a+","+i+")")}else s===vn.Money?n.addValidation(Vt.IsMoney):s===vn.Email?n.addValidation(Vt.IsEmail):s===vn.URL?n.addValidation(Vt.IsURL):[vn.LongHtmlString,vn.LongString].indexOf(s)>=0&&(n.isMultiLine=!0);return n}return Te(r,e),r.prototype.shouldComponentUpdate=function(e,t){return e.property.Value!==this.props.property.Value&&e.property.Value!==t.value&&(t.value=null===e.property.Value?"":e.property.Value),!0},r.prototype.addValidation=function(e){this.validators.push(e),this.errorMessages.push(Vt.getValidationMessage(e))},r.prototype.render=function(){return t.createElement(T.TextValidator,{ref:this.inputRef,multiline:this.isMultiLine,rowsMax:this.maxRows,className:this.isMultiLine?"textarea-input-control":"",variant:"outlined",fullWidth:!0,name:this.props.property.Name,label:this.props.property.FriendlyName+(!0===this.props.property.AllowNulls?"":" *"),value:this.state.value,onChange:this.onChangeHandler,onBlur:this.onBlurHandler,validators:this.validators,errorMessages:this.errorMessages,withRequiredValidator:!0,disabled:this.props.isReadonly})},r}(t.Component),In=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={value:null===t.props.property.Value?null:X(t.props.property.Value)},t.onChangeHandler=function(e){var r=null!==t.props.property.Value?X(t.props.property.Value).toISOString():null,n=e?e.toISOString():null;if(t.props.property.DataType===vn.Date&&(r&&(r=X(r).startOf("day").toISOString()),n&&(n=X(n).startOf("day").toISOString())),n!==r){var s=Ge({},t.props.property);s.Value=n,t.props.onPropertyChanged(s)}t.setState({value:e})},t}return Te(r,e),r.prototype.shouldComponentUpdate=function(e,t){return e.property.Value!==this.props.property.Value&&e.property.Value!==t.value&&(t.value=null===e.property.Value?null:X(e.property.Value)),!0},r.prototype.render=function(){var e=this;return t.createElement("div",null,t.createElement("div",{className:"picker"},this.props.property.DataType===vn.Date&&t.createElement(a.DatePicker,{fullWidth:!0,variant:"outlined",keyboard:!1,clearable:this.props.property.AllowNulls&&null!==this.state.value,label:this.props.property.FriendlyName,format:"DD MMM YYYY",required:!this.props.property.AllowNulls,disableOpenOnEnter:!0,animateYearScrolling:!0,disabled:this.props.isReadonly,value:this.state.value,onChange:function(t){return e.onChangeHandler(t)}}),this.props.property.DataType===vn.DateTime&&t.createElement(a.DateTimePicker,{fullWidth:!0,variant:"outlined",keyboard:!1,clearable:this.props.property.AllowNulls&&null!==this.state.value,label:this.props.property.FriendlyName,format:"DD MMM YYYY hh:mm",required:!this.props.property.AllowNulls,disableOpenOnEnter:!0,animateYearScrolling:!0,disabled:this.props.isReadonly,value:this.state.value,onChange:function(t){return e.onChangeHandler(t)}})))},r}(t.Component),bn=function(e){return t.createElement("tr",{className:"mdc-data-table__row"+(e.isRowSelected?" mdc-data-table__row--selected":"")},e.selectableRows&&t.createElement("td",{className:"mdc-data-table__cell mdc-data-table__cell--checkbox"},t.createElement(f.Checkbox,{checked:e.isRowSelected,onChange:function(t){e.setRowSelected(e.rowIndex,!e.isRowSelected)}})),e.columns.map((function(r,n){if(r.hidden)return null;var s=r.selector?e.rowData[r.selector]:"";return r.render&&(s=r.render(e.rowData,e.rowIndex)),t.createElement("td",{className:"mdc-data-table__cell"+(r.hide?" hide-"+r.hide:"")+(r.right?" align-right":""),key:n,onClick:function(){e.onRowClicked()},onDoubleClick:function(){e.onRowDoubleClicked()}},t.createElement("div",{style:{whiteSpace:"pre-wrap"}},s))})))},An=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Te(r,e),r.prototype.render=function(){var e=this;return t.createElement("tr",{className:"mdc-data-table__header-row"},this.props.selectableRows&&t.createElement("th",{className:"mdc-data-table__header-cell mdc-data-table__header-cell--checkbox",role:"columnheader",scope:"col",style:{width:"60px"}},t.createElement(f.Checkbox,{checked:this.props.isSelectedAll,indeterminate:this.props.indeterminate,onChange:function(t){e.props.setHeaderRowChecked(!e.props.isSelectedAll)}})),this.props.columns.map((function(e,r){if(e.hidden)return null;var n={};return e.width&&(n.width=e.width+"px"),e.minWidth&&(n.minWidth=e.minWidth+"px"),e.maxWidth&&(n.maxWidth=e.maxWidth+"px"),t.createElement("th",{className:"mdc-data-table__header-cell epi-table__header-cell"+(e.hide?" hide-"+e.hide:"")+(e.right?" align-right":""),role:"columnheader",scope:"col",key:r,style:n},t.createElement("div",{className:"epi-table__header-title"},t.createElement("span",{className:"header-title"},e.name)))})))},r}(t.Component),On=function(){return t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},t.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),t.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}))},Tn=function(e){return t.createElement("div",{className:"epi-table__toolbar"},t.createElement("div",null,e.contextActions&&e.selectedCount>0?t.createElement("div",{className:"action-buttons"},e.contextActions.map((function(e,r){return t.createElement(f.TextButton,{outlined:!0,key:r,onClick:function(){e.clickHandler&&e.clickHandler()}},e.title)}))):t.createElement("div",null,e.buttons&&e.buttons.map((function(e,r){return t.createElement(f.TextButton,{key:r,outlined:!0,onClick:function(){e.clickHandler()}},e.title)})))),e.searchInput&&t.createElement("div",null,t.createElement("div",{className:"search-input"},t.createElement("div",{className:"search-icon"},t.createElement(On,null)),t.createElement(s.InputBase,{placeholder:e.searchInput.placeholder}))))},wn=function(e){function r(r){var n=e.call(this,r)||this;return n.foundation=new ne.MDCDataTableFoundation,n.rowElements=[],n.isSelectedAll=!1,n.isSelectedRows=new Array,n.selectedCount=0,n.tableInstance={getSelectedRows:function(){var e=new Array;return n.isSelectedRows.forEach((function(t,r){!0===t&&n.data[r]&&e.push(n.data[r])})),e},setRowSelected:function(e,t){n.isSelectedRows[e]!==t&&(!0===t?(n.selectedCount++,n.selectedCount===n.data.length&&(n.isSelectedAll=!0)):(n.selectedCount--,!0===n.isSelectedAll&&(n.isSelectedAll=!1))),n.isSelectedRows[e]=t,n.props.selectableRowsPreSelectedField&&(n.data[e][n.props.selectableRowsPreSelectedField]=t),n.props.onRowSelected&&n.props.onRowSelected(e,t),n.forceUpdate()},setHeaderRowChecked:function(e){n.isSelectedAll=e;for(var t=0;t0&&!this.isSelectedAll,setHeaderRowChecked:function(t){return e.tableInstance.setHeaderRowChecked(t)}})),t.createElement("tbody",{className:"mdc-data-table__content"},this.data.map((function(r,n){return t.createElement(bn,{key:n,rowData:r,rowIndex:n,columns:e.props.columns,isRowSelected:!!e.isSelectedRows[n],selectableRows:e.props.selectableRows,setRowSelected:function(t,r){return e.tableInstance.setRowSelected(t,r)},onRowClicked:function(){e.props.onRowClicked&&e.props.onRowClicked(r,n)},onRowDoubleClicked:function(){e.props.onRowDoubleClicked&&e.props.onRowDoubleClicked(r,n)}})}))))))},r}(t.Component),Gn=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={editingRowIndex:-1,currentEditingRowValue:""},r.onValueCellChange=function(e){r.setState({currentEditingRowValue:e.currentTarget.value})},r.renderValueCell=function(e,n){return e?t.createElement(T.TextValidator,{name:"valueInput",variant:"outlined",defaultValue:n,value:r.state.currentEditingRowValue,onChange:r.onValueCellChange,validators:[Vt.Required],errorMessages:[Vt.getValidationMessage(Vt.Required)],withRequiredValidator:!0}):n},r.renderActionsCell=function(e,n,s,a){return e?t.createElement(t.Fragment,null,t.createElement(J,{title:"Save"},t.createElement(Z,{onClick:function(){return r.saveItem(s)}},t.createElement(te,null))),t.createElement(J,{title:"Cancel"},t.createElement(Z,{onClick:r.cancelEditing},t.createElement(re,null)))):-1===r.state.editingRowIndex&&t.createElement(t.Fragment,null,t.createElement(J,{title:"Edit item"},t.createElement(Z,{onClick:function(){return r.editRow(n,a)}},t.createElement($,null))),t.createElement(J,{title:"Delete item"},t.createElement(Z,{onClick:function(){return r.deleteRow(s)}},t.createElement(ee,null))))},r.saveItem=function(e){if(r.state.currentEditingRowValue){var t=Object.assign({},r.props.itemsObject);t[e]=r.state.currentEditingRowValue,r.props.onItemsUpdated(t),r.cancelEditing()}},r.cancelEditing=function(){r.setState({editingRowIndex:-1})},r.editRow=function(e,t){r.setState({editingRowIndex:e,currentEditingRowValue:t})},r.deleteRow=function(e){var t=Object.assign({},r.props.itemsObject);delete t[e],r.props.onItemsUpdated(t)},r}return Te(r,e),r.prototype.render=function(){var e=this,r=Object.keys(this.props.itemsObject),n=[{name:"Key",width:300,render:function(e){return e.key}},{name:"Value",render:function(t,r){var n=e.state.editingRowIndex===r;return e.renderValueCell(n,e.props.itemsObject[t.key])}}];this.props.isReadonly||n.push({name:"Options",width:150,right:!0,render:function(t,r){var n=e.state.editingRowIndex===r;return e.renderActionsCell(n,r,t.key,t.value)}});var s=r.map((function(t){return{key:t,value:e.props.itemsObject[t]}}));return t.createElement(wn,{data:s,columns:n})},r}(t.Component),Dn=function(e){function r(t){var r=e.call(this,t)||this;return r.validators=[],r.errorMessages=[],r.state={isDetailsDialogOpen:!1,itemsObject:Object.assign({},r.props.property.Value),inputKey:"",inputValue:"",loaded:!1},r.openDetailsDialog=function(){r.setState({isDetailsDialogOpen:!0}),setTimeout((function(){r.setState({loaded:!0})}),100)},r.closeDetailsDialog=function(){r.setState({isDetailsDialogOpen:!1})},r.updateItemsObject=function(e){r.setState({itemsObject:e})},r.addItem=function(e){var t=r.state.inputKey.toLowerCase().trim(),n=r.state.inputValue;if(!r.state.itemsObject[t]){var s=Object.assign({},r.state.itemsObject);s[t]=n,r.setState({itemsObject:s})}},r.onInputKeyChange=function(e){r.setState({inputKey:e.currentTarget.value})},r.onInputValueChange=function(e){r.setState({inputValue:e.currentTarget.value})},r.saveProperty=function(){var e=Object.assign({},r.props.property);e.Value=r.state.itemsObject,r.props.onPropertyChanged(e),r.closeDetailsDialog()},r.handleClosingDetailsDialog=function(){var e=Object.assign({},r.props.property.Value);r.setState({itemsObject:e}),r.closeDetailsDialog()},r.validators.push(Vt.Required),r.errorMessages.push(Vt.getValidationMessage(Vt.Required)),r}return Te(r,e),r.prototype.shouldComponentUpdate=function(e,t){return e.property.Value!==this.props.property.Value&&e.property.Value!==t.itemsObject&&(t.itemsObject=Object.assign({},e.property.Value),t.inputKey="",t.inputValue=""),!0},r.prototype.render=function(){var e=this.props.isReadonly;return t.createElement("div",null,t.createElement(s.Typography,null,this.props.property.FriendlyName,this.props.property.AllowNulls?"":" *"),t.createElement(f.TextButton,{outlined:!0,onClick:this.openDetailsDialog},"View Details"),t.createElement(ar,{title:"Dictionary Items",open:this.state.isDetailsDialogOpen,okLabel:"Save",onOK:this.saveProperty,closeLabel:"Close",onClose:this.handleClosingDetailsDialog,large:!0},t.createElement(s.Grid,{container:!0,spacing:16},!e&&t.createElement(s.Grid,{item:!0,xs:12},this.state.loaded&&t.createElement(T.ValidatorForm,{onSubmit:this.addItem},t.createElement(s.Grid,{container:!0,spacing:24,alignItems:"center"},t.createElement(s.Grid,{item:!0,xs:12,sm:4},t.createElement(T.TextValidator,{fullWidth:!0,variant:"outlined",label:"Key",name:"inputKey",value:this.state.inputKey,onChange:this.onInputKeyChange,validators:this.validators,errorMessages:this.errorMessages,withRequiredValidator:!0})),t.createElement(s.Grid,{item:!0,xs:12,sm:4},t.createElement(T.TextValidator,{fullWidth:!0,variant:"outlined",label:"Value",name:"inputValue",value:this.state.inputValue,onChange:this.onInputValueChange,validators:this.validators,errorMessages:this.errorMessages,withRequiredValidator:!0})),t.createElement(s.Grid,{item:!0,xs:12,sm:4},t.createElement(f.TextButton,{unelevated:!0,type:"submit"},"Add item"))))),t.createElement(s.Grid,{item:!0,xs:12},t.createElement(Gn,{isReadonly:e,itemsObject:this.state.itemsObject,onItemsUpdated:this.updateItemsObject})))))},r}(t.Component),Pn=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={selectedIds:t.props.property.Value||[]},t.handleChange=function(e){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(t){return this.props.property.DataType===vn.DictionaryMultiValue||this.props.property.DataType===vn.EnumMultiValue?this.setState({selectedIds:e.target.value}):this.setState({selectedIds:[e.target.value]}),[2]}))}))},t.isSelectedItemsChanged=function(e,t){var r=!1;if(e.length!==t.length)r=!0;else for(var n=0,s=e;n=0?t.createElement(Sn,Ge({},r)):[vn.Date,vn.DateTime].indexOf(e.DataType)>=0?t.createElement(In,Ge({},r)):e.DataType===vn.DictionaryMultiValue||e.DataType===vn.EnumMultiValue||e.DataType===vn.DictionarySingleValue||e.DataType===vn.EnumSingleValue?t.createElement(Pn,Ge({},r)):e.DataType===vn.Boolean?t.createElement(Nn,Ge({},r)):e.DataType===vn.StringDictionary?t.createElement(Dn,Ge({},r)):t.createElement(s.Grid,null,t.createElement(s.Typography,null,e.FriendlyName),t.createElement(s.Typography,null,e.Value))},n}return Te(r,e),r.prototype.render=function(){return this.renderInput(this.props.property)},r}(t.Component),xn=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={isExpanded:!r.props.isCollapsible,hasShowAll:!0,propertiesBody:t.createRef()},r.togglePanelHandler=function(e){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(e){return this.setState({isExpanded:!this.state.isExpanded}),[2]}))}))},r}return Te(r,e),r.prototype.updateLayout=function(){this.state.propertiesBody.current&&(this.state.propertiesBody.current.clientHeight<140?this.setState({hasShowAll:!1}):this.setState({hasShowAll:!0}))},r.prototype.componentDidMount=function(){this.updateLayout(),window.addEventListener("resize",this.updateLayout.bind(this))},r.prototype.render=function(){var e=this;return t.createElement(T.ValidatorForm,{instantValidate:!0,onSubmit:function(){return null}},t.createElement(s.Card,null,t.createElement(s.Collapse,{in:this.state.isExpanded,collapsedHeight:"180px"},t.createElement("div",{ref:this.state.propertiesBody},t.createElement(s.CardContent,null,t.createElement(s.Grid,{container:!0,className:this.props.classes.expandableContainer},this.props.properties.map((function(r){return t.createElement(s.Grid,{key:r.Id,item:!0,xs:12,sm:6,lg:4,className:e.props.classes.expandableItem},t.createElement(Rn,{property:r,isReadonly:e.props.isReadonly||!r.IsEditable,onPropertyChanged:e.props.onPropertyChanged}))})))))),this.props.isCollapsible&&this.state.hasShowAll&&t.createElement(s.CardActions,null,t.createElement(f.TextButton,{outlined:!0,className:this.props.classes.toggleButton,onClick:this.togglePanelHandler},"Show ",this.state.isExpanded?"Less":"All"))))},r}(t.Component),Ln=s.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({expandableContainer:{overflowY:"hidden",paddingTop:"8px"},expandableItem:{marginBottom:10,padding:"0 20px 20px 0px"},toggleButton:{margin:"0 auto",width:"100%",maxWidth:"250px"}})}))(n.connect((function(e,t){return{isReadonly:void 0!==t.isReadonly&&t.isReadonly,isCollapsible:void 0===t.isCollapsible||t.isCollapsible,properties:t.properties,onPropertyChanged:t.onPropertyChanged,classes:t.classes}}))(xn)),Mn=function(e){return e?e.replace(/([A-Z])/g," $1").trim():""},Fn=0,kn=o.withStyles((function(e){return s.createStyles({root:{flexGrow:1},selectContainer:{display:"inline"},currency:{height:30}})}))(n.connect((function(e,t){return{currencies:e.orderGroup.currencies,selectedCurrency:e.orderGroup.currentOrderGroup.Currency,classes:t.classes,updateInputValue:t.updateInputValue}}))((function(e){var r=e.currencies.map((function(e){return{label:e.Code,value:e.Code}}));return e.currencies.length>0?t.createElement(_t,{label:"Currency","refresh-counter":Fn++,value:e.selectedCurrency,options:r,onChange:function(t){e.updateInputValue(t)}}):t.createElement(t.Fragment,null)}))),_n=n.connect((function(e,t){var r=e.orderGroup.currentOrderGroup;return{orderGroupType:r.Type,orderGroupId:r.OrderGroupId,newOrderCurrency:t.newOrderCurrency,close:t.onClose}}))((function(e){return t.createElement(ir,{title:"Update Currency",closeButtonLabel:"Cancel",confirmButtonLabel:"Update",onConfirm:function(){return Pe(void 0,void 0,void 0,(function(){var t,r,n,s;return Ne(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),t=e.orderGroupId,r=e.orderGroupType,[4,Zt.OrderGroup.updateCurrencyForOrder(r,t,e.newOrderCurrency)];case 1:return 200!==a.sent().status?[3,3]:[4,Zt.OrderGroup.getSingleOrderGroup(r,t)];case 2:n=a.sent(),e.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(n)),n.ValidationMessages.length>0&&e.dispatch(rt.ApplicationActions.showNotification(n.ValidationMessages)),a.label=3;case 3:return[3,5];case 4:return s=a.sent(),e.dispatch(rt.ApplicationActions.showNotification(s.message)),[3,5];case 5:return e.close(!0),[2]}}))}))},onClose:function(){return e.close(!1)}},t.createElement(s.Typography,{variant:"body1"},t.createElement("div",null,t.createElement("b",null,"Are you sure you want to change the currency?")),"Changing currency could affect shipping and payment methods, prices or searched items."))})),Vn=n.connect((function(e,t){return{orderGroupId:e.orderGroup.currentOrderGroup.OrderGroupId,newOrderMarket:t.newOrderMarket,close:t.onClose}}))((function(e){return t.createElement(ir,{title:"Update Market",closeButtonLabel:"Cancel",confirmButtonLabel:"Update",onConfirm:function(){return Pe(void 0,void 0,void 0,(function(){var t,r,n;return Ne(this,(function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),[4,Zt.Cart.updateMarketForCart(e.orderGroupId,e.newOrderMarket)];case 1:return 200!==s.sent().status?[3,4]:[4,Zt.OrderGroup.getSingleOrderGroup("Cart",e.orderGroupId)];case 2:return t=s.sent(),e.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(t)),t.ValidationMessages.length>0&&e.dispatch(rt.ApplicationActions.showNotification(t.ValidationMessages)),[4,Zt.Currency.getCurrencies(e.newOrderMarket)];case 3:r=s.sent(),e.dispatch(rt.OrderGroupActions.setCurrencies(r)),s.label=4;case 4:return[3,6];case 5:return n=s.sent(),e.dispatch(rt.ApplicationActions.showNotification(n.message)),[3,6];case 6:return e.close(!0),[2]}}))}))},onClose:function(){return e.close(!1)}},t.createElement(s.Typography,{variant:"body1"},t.createElement("div",null,t.createElement("b",null,"Are you sure you want to change the market?")),"Changing market could affect shipping and payment methods, prices and items that can be added to the cart."))})),Un=o.withStyles((function(e){return s.createStyles({})}))(n.connect((function(e,t){return{markets:e.market.markets,selectedMarket:t.selectedMarket,classes:t.classes,updateInputValue:t.updateInputValue}}))((function(e){var r=e.markets,n=e.selectedMarket,s=r.map((function(e){return{label:e.Name,value:e.Id}}));return t.createElement(_t,{label:"Choose Market",fullWidth:!0,options:s,value:n,onChange:function(t){return e.updateInputValue(t)}})}))),Bn=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={selectedCurrency:"",isUpdateCurrencyDialogOpen:!1,selectedMarket:"",isUpdateMarketDialogOpen:!1},t.customerEditLink="/customers/"+t.props.orderGroup.Customer.Id+"/info?orderType="+t.props.orderGroup.Type+"&orderId="+t.props.orderGroup.OrderGroupId,t.customPropertyChangedHandler=function(e){return Pe(t,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,Zt.MetaField.updateOrderGroupMetaFields(this.props.orderGroup.OrderGroupId,this.props.orderGroup.Type,e)];case 1:return n.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 2:return t=n.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(t)),[3,4];case 3:return r=n.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(r.message)),[3,4];case 4:return[2]}}))}))},t.updateMarketForCart=function(e){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(t){return e===this.props.orderGroup.MarketId||this.setState({selectedMarket:e,isUpdateMarketDialogOpen:!0}),[2]}))}))},t.updateCurrencyForOrder=function(e){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(t){return e===this.props.orderGroup.Currency||this.setState({selectedCurrency:e,isUpdateCurrencyDialogOpen:!0}),[2]}))}))},t.closeOrderMarketUpdateDialogHandler=function(e){t.setState({isUpdateMarketDialogOpen:!1}),e||t.setState({selectedMarket:t.props.orderGroup.MarketId})},t.closeOrderCurrencyUpdateDialogHandler=function(e){t.setState({isUpdateCurrencyDialogOpen:!1}),e||t.setState({selectedCurrency:t.props.orderGroup.Currency})},t}return Te(r,e),r.prototype.render=function(){return t.createElement(d,{container:!0,direction:"column",spacing:16},!this.props.createMode&&t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Order Number"),t.createElement(s.Typography,{className:this.props.classes.itemData},this.props.orderGroup.OrderNumber?this.props.orderGroup.OrderNumber:this.props.orderGroup.OrderGroupId)),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Created Date"),t.createElement(s.Typography,{className:this.props.classes.itemData},X(this.props.orderGroup.Created).format("LLL"))),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Status"),t.createElement(s.Typography,{className:this.props.classes.itemData},Mn(this.props.orderGroup.OrderStatus))),t.createElement(d,{item:!0},t.createElement(s.Divider,null)),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Items"),t.createElement(En,{amount:this.props.orderGroup.ItemsTotal,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Line Item Discounts"),t.createElement(En,{amount:this.props.orderGroup.LineItemDiscounts,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Order Level Discounts"),t.createElement(En,{amount:this.props.orderGroup.OrderLevelDiscounts,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Discount Total"),t.createElement(En,{amount:this.props.orderGroup.DiscountsTotal,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Taxes Total"),t.createElement(En,{amount:this.props.orderGroup.TaxTotal,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},this.props.orderGroup.PricesIncludeTax?"Total excluding shipping (includes tax)":"Total excluding shipping and tax"),t.createElement(En,{amount:this.props.orderGroup.TotalExcludingShippingAndTax,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Divider,null)),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Shipping Cost"),t.createElement(En,{amount:this.props.orderGroup.ShippingTotal,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Shipping Discounts"),t.createElement(En,{amount:this.props.orderGroup.ShippingDiscount,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Handling Total"),t.createElement(En,{amount:this.props.orderGroup.HandlingTotal,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Divider,null)),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Order Total"),t.createElement(En,{amount:this.props.orderGroup.Total,className:this.props.classes.itemData})),t.createElement(d,{item:!0},t.createElement(s.Divider,null)),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Market"),!0===this.props.createMode&&"PaymentPlan"===this.props.orderGroup.Type?t.createElement("span",{className:this.props.classes.itemData},t.createElement(Un,{selectedMarket:this.props.orderGroup.MarketId,updateInputValue:this.updateMarketForCart})):t.createElement(s.Typography,{className:this.props.classes.itemData},this.props.orderGroup.MarketName),this.state.isUpdateMarketDialogOpen&&t.createElement(Vn,{newOrderMarket:this.state.selectedMarket,onClose:this.closeOrderMarketUpdateDialogHandler})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Currency"),this.props.isReadonly?t.createElement(s.Typography,{className:this.props.classes.itemData},this.props.orderGroup.Currency):t.createElement("span",{className:this.props.classes.itemData},t.createElement(kn,{updateInputValue:this.updateCurrencyForOrder})),this.state.isUpdateCurrencyDialogOpen&&t.createElement(_n,{newOrderCurrency:this.state.selectedCurrency,onClose:this.closeOrderCurrencyUpdateDialogHandler})),!this.props.createMode&&this.props.orderGroup.Properties&&this.props.orderGroup.Properties.length>0&&t.createElement(d,{item:!0},t.createElement(s.Typography,{variant:"subtitle1"},"Custom Properties"),t.createElement(Ln,{properties:this.props.orderGroup.Properties,onPropertyChanged:this.customPropertyChangedHandler,isReadonly:this.props.isReadonly,isCollapsible:!1})))},r}(t.Component),Hn=s.withStyles((function(){return s.createStyles({itemLabel:{width:"200px",display:"inline-block",fontSize:14},itemData:{display:"inline-block",fontSize:14}})}))(n.connect()(Bn)),qn=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={isUpdateMarketDialogOpen:!1,isUpdateCurrencyDialogOpen:!1,selectedMarket:"",selectedCurrency:""},t.updateMarketForCart=function(e){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(t){return e===this.props.orderGroup.MarketId||this.setState({selectedMarket:e,isUpdateMarketDialogOpen:!0}),[2]}))}))},t.updateCurrencyForOrder=function(e){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(t){return e===this.props.orderGroup.Currency||this.setState({selectedCurrency:e,isUpdateCurrencyDialogOpen:!0}),[2]}))}))},t.closeOrderMarketUpdateDialogHandler=function(e){t.setState({isUpdateMarketDialogOpen:!1}),e||t.setState({selectedMarket:t.props.orderGroup.MarketId})},t.closeOrderCurrencyUpdateDialogHandler=function(e){t.setState({isUpdateCurrencyDialogOpen:!1}),e||t.setState({selectedCurrency:t.props.orderGroup.Currency})},t}return Te(r,e),r.prototype.render=function(){return t.createElement(d,{container:!0,direction:"column",spacing:16},t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel,variant:"caption"},"Cart Number"),t.createElement(s.Typography,{className:this.props.classes.itemData,variant:"caption"},this.props.orderGroup.OrderGroupId)),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel,variant:"caption"},"Created Date"),t.createElement(s.Typography,{className:this.props.classes.itemData,variant:"caption"},X(this.props.orderGroup.Created).format("LLL"))),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel,variant:"caption"},"Order Level Discounts"),t.createElement(En,{className:this.props.classes.itemData,amount:this.props.orderGroup.OrderLevelDiscounts,align:"left",variant:"caption"})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel,variant:"caption"},"Cart Total"),t.createElement(En,{className:this.props.classes.itemData,amount:this.props.orderGroup.Total,align:"left",variant:"caption"})),t.createElement(d,{item:!0},t.createElement(s.Divider,null)),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel,variant:"caption"},"Market"),t.createElement("span",{className:this.props.classes.itemData},t.createElement(Un,{selectedMarket:this.props.orderGroup.MarketId,updateInputValue:this.updateMarketForCart})),this.state.isUpdateMarketDialogOpen&&t.createElement(Vn,{newOrderMarket:this.state.selectedMarket,onClose:this.closeOrderMarketUpdateDialogHandler})),t.createElement(d,{item:!0},t.createElement(s.Typography,{className:this.props.classes.itemLabel,variant:"caption"},"Currency"),t.createElement("span",{className:this.props.classes.itemData},t.createElement(kn,{updateInputValue:this.updateCurrencyForOrder})),this.state.isUpdateCurrencyDialogOpen&&t.createElement(_n,{newOrderCurrency:this.state.selectedCurrency,onClose:this.closeOrderCurrencyUpdateDialogHandler})))},r}(t.Component),Wn=s.withStyles((function(e){e.spacing;return s.createStyles({itemLabel:{width:"200px",display:"inline-block",fontSize:14},itemData:{display:"inline-block",fontSize:14}})}))(qn),jn=function(e){var r="/customers/"+e.orderGroup.Customer.Id+"/info?orderType="+e.orderGroup.Type+"&orderId="+e.orderGroup.OrderGroupId;return t.createElement(d,{container:!0,direction:"column"},t.createElement(d,{item:!0},t.createElement(d,{container:!0,alignItems:"center"},t.createElement(d,{item:!0},t.createElement(s.Typography,{variant:"h6"},"Customer Information")),null!=e.orderGroup.Customer.Email&&t.createElement(d,{item:!0},t.createElement(J,{title:"Edit Customer Information"},t.createElement(D.Link,{to:r,onClick:function(){Qr(mt)}},t.createElement(f.IconButton,null,t.createElement(f.EditIcon,{style:{width:"16px"}}))))))),t.createElement(d,{item:!0},t.createElement(s.Card,null,t.createElement(s.CardContent,null,t.createElement(d,{container:!0,spacing:24},t.createElement(d,{item:!0},t.createElement(s.Typography,{variant:"subtitle1"},"Customer: ",e.orderGroup.Customer.FullName)),t.createElement(d,{item:!0},t.createElement(s.Typography,{variant:"subtitle1"},"Email Address: ",e.orderGroup.Customer.Email)))))))};!function(e){e.OnHold="OnHold",e.PartiallyShipped="PartiallyShipped",e.InProgress="InProgress",e.Completed="Completed",e.Cancelled="Cancelled",e.AwaitingExchange="AwaitingExchange"}(Cn||(Cn={}));var Yn,zn=Cn,Qn=[{label:"None",value:"None"},{label:"Days",value:"Days"},{label:"Weeks",value:"Weeks"},{label:"Months",value:"Months"},{label:"Years",value:"Years"},{label:"Custom1",value:"Custom1"},{label:"Custom2",value:"Custom2"}],Kn=b.object().shape({CycleMode:b.string().required(Vt.getValidationMessage(Vt.Required)),CycleLength:b.number().required(Vt.getValidationMessage(Vt.Required)).integer(Vt.getValidationMessage(Vt.IsInteger)).min(0),MaxCyclesCount:b.number().required(Vt.getValidationMessage(Vt.Required)).integer(Vt.getValidationMessage(Vt.IsInteger)).min(0),CompletedCyclesCount:b.number().required(Vt.getValidationMessage(Vt.Required)).integer(Vt.getValidationMessage(Vt.IsInteger)).min(0),StartDate:b.date().nullable(),EndDate:b.date().nullable().when("StartDate",(function(e,t){return e?t.min(e,"The End Date must greater than or equal to the Start Date."):t})),LastTransactionDate:b.date().nullable(),IsActive:b.boolean()}),Xn=function(e){function r(t){var r=e.call(this,t)||this;r.datetimeFormat="MMM DD, YYYY hh:mm A",r.initPaymentPlanSetting=function(){var e={CycleMode:"None",StartDate:null,EndDate:null,LastTransactionDate:null,IsActive:!1};return r.props.createMode?Object.assign(e,r.props.paymentPlanSetting):e={CycleMode:null==r.props.paymentPlan.CycleMode?"None":r.props.paymentPlan.CycleMode,CycleLength:r.props.paymentPlan.CycleLength,MaxCyclesCount:r.props.paymentPlan.MaxCyclesCount,CompletedCyclesCount:r.props.paymentPlan.CompletedCyclesCount,StartDate:r.props.paymentPlan.StartDate,EndDate:r.props.paymentPlan.EndDate,LastTransactionDate:r.props.paymentPlan.LastTransactionDate,IsActive:null!=r.props.paymentPlan.IsActive&&r.props.paymentPlan.IsActive},r.props.dispatch(rt.OrderGroupActions.setPaymentPlanSetting(e)),e},r.isEditable=function(){return r.props.paymentPlan.OrderStatus!==zn.Cancelled&&!r.props.createMode},r.isValid=function(){return r.validatePaymentPlanSetting(r.state.paymentPlanSetting,!0)},r.validatePaymentPlanSetting=function(e,t){var n={};try{return Kn.validateSync(e,{abortEarly:!1}),r.setState({errors:n}),!0}catch(s){return s.inner.map((function(r){(!t||null!==e[r.path]&&void 0!==e[r.path])&&(n[r.path]=r.message)})),r.setState({errors:n}),!1}},r.updatePaymentPlanSetting=function(e,t){return Pe(r,void 0,void 0,(function(){var r;return Ne(this,(function(n){switch(n.label){case 0:return(r=Ge({},this.state.paymentPlanSetting))[e]=t,[4,this.validatePaymentPlanSetting(r,!0)];case 1:return n.sent(),this.setState({paymentPlanSetting:r}),this.props.dispatch(rt.OrderGroupActions.setPaymentPlanSetting(r)),[2]}}))}))},r.saveChange=function(){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return this.validatePaymentPlanSetting(this.state.paymentPlanSetting)?[4,Zt.PaymentPlan.updatePaymentPlanSetting(this.props.paymentPlan.OrderGroupId,this.state.paymentPlanSetting)]:[3,2];case 1:e.sent(),this.setState({editMode:!1}),e.label=2;case 2:return[2]}}))}))},r.cancelEdit=function(){r.setState({editMode:!1,errors:{},paymentPlanSetting:r.initPaymentPlanSetting()})},r.props.validator&&(r.props.validator.validate=r.isValid);var n=r.initPaymentPlanSetting();return r.state={paymentPlanSetting:n,errors:{},editMode:r.props.editMode},r}return Te(r,e),r.prototype.render=function(){var e=this;return t.createElement(t.Fragment,null,t.createElement(d,{container:!0,direction:"column",className:this.props.classes.pageItem,spacing:16},t.createElement(d,{item:!0,className:this.props.classes.rowData},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Last Transaction Date"),t.createElement("div",{className:this.props.classes.itemData},t.createElement(a.DateTimePicker,{fullWidth:!0,clearable:!0,variant:"outlined",disabled:!this.state.editMode,format:this.datetimeFormat,value:null==this.state.paymentPlanSetting.LastTransactionDate?null:X(this.state.paymentPlanSetting.LastTransactionDate),onChange:function(t){return e.updatePaymentPlanSetting("LastTransactionDate",null==t?null:t.toDate())}}),t.createElement(s.Typography,{variant:"caption"},"The date of last transaction"),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.LastTransactionDate))),t.createElement(d,{item:!0,className:this.props.classes.rowData},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Completed Cycles*"),t.createElement("div",{className:this.props.classes.itemData},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",disabled:!this.state.editMode,required:!0,type:"number",className:this.props.classes.itemData,value:this.state.paymentPlanSetting.CompletedCyclesCount,onChange:function(t){var r=Number(t.target.value);isNaN(r)||e.updatePaymentPlanSetting("CompletedCyclesCount",r)}}),t.createElement(s.Typography,{variant:"caption"},"Number of completed cycles"),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.CompletedCyclesCount))),t.createElement(d,{item:!0,className:this.props.classes.rowData},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Cycle Length*"),t.createElement("div",{className:this.props.classes.itemData},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",disabled:!this.state.editMode,required:!0,type:"number",value:this.state.paymentPlanSetting.CycleLength,onChange:function(t){var r=Number(t.target.value);isNaN(r)||e.updatePaymentPlanSetting("CycleLength",r)}}),t.createElement(s.Typography,{variant:"caption"},"Cycle length in units of cycle mode"),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.CycleLength))),t.createElement(d,{item:!0,className:this.props.classes.rowData},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Plan Cycle"),t.createElement("div",{className:this.props.classes.itemData},t.createElement(_t,{fullWidth:!0,disabled:!this.state.editMode,value:this.state.paymentPlanSetting.CycleMode,options:Qn,onChange:function(t){return e.updatePaymentPlanSetting("CycleMode",t)}}),t.createElement(s.Typography,{variant:"caption"},"Cycles mode is used to define period of recurring payments. Can be day, week, month or custom"))),t.createElement(d,{item:!0,className:this.props.classes.rowData},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Max Cycles*"),t.createElement("div",{className:this.props.classes.itemData},t.createElement(s.TextField,{fullWidth:!0,variant:"outlined",disabled:!this.state.editMode,required:!0,type:"number",value:this.state.paymentPlanSetting.MaxCyclesCount,onChange:function(t){var r=Number(t.target.value);isNaN(r)||e.updatePaymentPlanSetting("MaxCyclesCount",r)}}),t.createElement(s.Typography,{variant:"caption"},"Number of maximum cycles to process"),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.MaxCyclesCount))),t.createElement(d,{item:!0,className:this.props.classes.rowData},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Start Date"),t.createElement("div",{className:this.props.classes.itemData},t.createElement(a.DateTimePicker,{clearable:!0,fullWidth:!0,variant:"outlined",format:this.datetimeFormat,disabled:!this.state.editMode,value:null==this.state.paymentPlanSetting.StartDate?null:X(this.state.paymentPlanSetting.StartDate),onChange:function(t){return e.updatePaymentPlanSetting("StartDate",null==t?null:t.toDate())},className:this.props.classes.itemData}),t.createElement(s.Typography,{variant:"caption"},"Plan start date"),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.StartDate))),t.createElement(d,{item:!0,className:this.props.classes.rowData},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"End Date"),t.createElement("div",{className:this.props.classes.itemData},t.createElement(a.DateTimePicker,{clearable:!0,fullWidth:!0,variant:"outlined",format:this.datetimeFormat,disabled:!this.state.editMode,value:null==this.state.paymentPlanSetting.EndDate?null:X(this.state.paymentPlanSetting.EndDate),onChange:function(t){return e.updatePaymentPlanSetting("EndDate",null==t?null:t.toDate())}}),t.createElement(s.Typography,{variant:"caption"},"Plan end date"),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.EndDate))),t.createElement(d,{item:!0,className:this.props.classes.rowData},t.createElement(s.Typography,{className:this.props.classes.itemLabel},"Is Active"),t.createElement(f.Checkbox,{disabled:!this.state.editMode,checked:this.state.paymentPlanSetting.IsActive,onChange:function(t){return e.updatePaymentPlanSetting("IsActive",t.target.checked)}}))),this.isEditable()&&t.createElement(d,{container:!0,spacing:8},!this.state.editMode&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.setState({editMode:!0})}},"Edit")),this.state.editMode&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:this.cancelEdit},"Cancel")),this.state.editMode&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:this.saveChange},"Save"))))},r}(t.Component),Jn=s.withStyles((function(e){var t=e.spacing;return s.createStyles({pageItem:{padding:1*t.unit},rowData:{width:"100%",cellPadding:1*t.unit,display:"flex",alignItems:"flex-start"},itemLabel:{padding:1*t.unit,width:"200px",display:"inline-block",fontSize:14},itemData:{width:"400px",display:"inline-block",fontSize:14}})}))(n.connect((function(e,t){return{paymentPlan:t.paymentPlan,editMode:t.editMode,createMode:t.createMode,validator:t.validator,paymentPlanSetting:e.orderGroup.paymentPlanSetting,classes:t.classes}}))(Xn)),Zn=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({})}))(n.connect((function(e,t){var r=e.orderGroup.currentOrderGroup;return{lineItemDeleteConfirmationIsVisible:e.application.lineItemDeleteConfirmationIsVisible,currentLineItemId:e.orderGroup.currentLineItemId,currentOrderGroupId:r.OrderGroupId,orderGroupType:r.Type,listedOrderGroups:e.orderGroup.listedOrderGroups,classes:t.classes}}))((function(e){var r=function(){e.dispatch(rt.ApplicationActions.closeDeleteLineItemConfirmationView())};return t.createElement("div",null,t.createElement(h,{open:e.lineItemDeleteConfirmationIsVisible,maxWidth:"sm",fullWidth:!0,onClose:r},t.createElement(ce,null,"Remove line item"),t.createElement(g,null,t.createElement(le,null,"This will remove the line item from the cart. This operation cannot be undone."),t.createElement(m,null,t.createElement(f.TextButton,{onClick:r},"Cancel"),t.createElement(f.TextButton,{unelevated:!0,onClick:function(){return Pe(void 0,void 0,void 0,(function(){var t,n,s;return Ne(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,Zt.OrderGroup.deleteLineItem(e.orderGroupType,e.currentOrderGroupId,e.currentLineItemId)];case 1:return(t=a.sent())&&t.data&&Array.isArray(t.data)&&t.data.length>0&&e.dispatch(rt.ApplicationActions.showNotification(t.data)),[4,Zt.OrderGroup.getSingleOrderGroup(e.orderGroupType,e.currentOrderGroupId)];case 2:return n=a.sent(),e.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(n)),r(),[3,4];case 3:return s=a.sent(),e.dispatch(rt.ApplicationActions.showNotification(s.message)),[3,4];case 4:return[2]}}))}))}},"Remove")))))})));function $n(e){return!!e&&(e.OrderStatus===zn.Cancelled||e.OrderStatus===zn.Completed||e.OrderStatus===zn.OnHold)}function es(e){var t=!1;if(e&&Array.isArray(e.Forms)&&e.Forms.length>0){var r=e.Forms[0];if(Array.isArray(r.Shipments)&&r.Shipments.length>0)for(var n=0;n0){t=!0;break}}return t}function ts(e){if(!(e&&Array.isArray(e.Forms)&&e.Forms.length>0))return!1;var t=e.Forms[0];if(!(Array.isArray(t.Shipments)&&t.Shipments.length>0))return!1;var r=t.Shipments[0];return!!(Array.isArray(r.LineItems)&&r.LineItems.length>0)&&(!!r.ShippingAddress&&!(!r.ShippingMethodId||"00000000-0000-0000-0000-000000000000"===r.ShippingMethodId))}!function(e){e.OrderNumber="OrderNumber",e.CustomerName="CustomerName",e.Email="Email"}(Yn||(Yn={}));var rs,ns=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={orderDialog:{isOpen:!1,title:"",message:"",closeButtonLabel:"",confirmButtonLabel:"",onConfirm:function(){return null}}},t.goToOriginalOrder=function(){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(e){return zr.push(vt+"/"+this.props.orderGroup.ParentOrderId),[2]}))}))},t}return Te(r,e),r.prototype.updateOrderStatus=function(e){return Pe(this,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,Zt.OrderGroup.updateOrderStatus(this.props.orderGroup.OrderGroupId,e)];case 1:return n.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 2:return t=n.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(t)),[3,4];case 3:return r=n.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(r.message)),[3,4];case 4:return this.closeOrderDialog(),[2]}}))}))},r.prototype.closeOrderDialog=function(){this.setState({orderDialog:{isOpen:!1}})},r.prototype.showCancelConfirmDialog=function(){var e=this;this.setState({orderDialog:{isOpen:!0,title:"Cancel Order",message:"Are you sure you want to cancel this order?",closeButtonLabel:"Close",confirmButtonLabel:"Cancel Order",onConfirm:function(){return e.updateOrderStatus(zn.Cancelled)}}})},r.prototype.canShowHoldButton=function(){return this.props.orderGroup.OrderStatus===zn.InProgress||this.props.orderGroup.OrderStatus===zn.PartiallyShipped},r.prototype.canShowCancelButton=function(){return this.props.orderGroup.OrderStatus===zn.InProgress},r.prototype.canShowReleaseHoldButton=function(){return this.props.orderGroup.OrderStatus===zn.OnHold},r.prototype.render=function(){var e=this;return t.createElement("div",null,t.createElement(d,{container:!0,justify:"flex-end",spacing:8},this.props.orderGroup.IsExchangeOrder&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:this.goToOriginalOrder},"Go to original order")),this.canShowHoldButton()&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.updateOrderStatus(zn.OnHold)}},"Hold")),this.canShowReleaseHoldButton()&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.updateOrderStatus(zn.InProgress)}},"Release OnHold")),this.canShowCancelButton()&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.showCancelConfirmDialog()}},"Cancel Order"))),this.state.orderDialog.isOpen&&t.createElement(ir,{title:this.state.orderDialog.title,closeButtonLabel:this.state.orderDialog.closeButtonLabel,confirmButtonLabel:this.state.orderDialog.confirmButtonLabel,onConfirm:this.state.orderDialog.onConfirm,onClose:function(){return e.setState({orderDialog:{isOpen:!1}})}},t.createElement(s.Typography,{variant:"body1"},this.state.orderDialog.message)))},r}(t.Component),ss=n.connect((function(e){return{orderGroup:e.orderGroup.currentOrderGroup}}))(ns),as=function(){return t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},t.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),t.createElement("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"}))},is=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.dropdownMenuAnchor=t.createRef(),r.dropdownOpen=!1,r.openActionDropdown=function(){r.dropdownOpen=!0,r.forceUpdate()},r.handleClose=function(){r.dropdownOpen=!1,r.forceUpdate()},r}return Te(r,e),r.prototype.render=function(){var e=this;return t.createElement("div",{className:"action-dropdown__container"},t.createElement("div",{className:"action-dropdown__anchor-icon mdc-ripple-surface",onClick:function(t){window.document.getElementsByTagName("body")[0].click(),t.stopPropagation(),e.openActionDropdown()},ref:this.dropdownMenuAnchor,"data-mdc-ripple-is-unbounded":!0},t.createElement(as,null)),t.createElement(f.MenuSurface,{anchorElement:this.dropdownMenuAnchor.current,anchorCorner:1,open:this.dropdownOpen,onClose:function(){return e.handleClose()},className:"epi-table-action-dropdown"},t.createElement(f.List,null,this.props.actions.map((function(r,n){return t.createElement(f.ListItem,{style:{cursor:"pointer"},key:n,onClick:function(t){t.stopPropagation(),e.handleClose(),r.clickHandler&&r.clickHandler(e.props.rowData,e.props.rowIndex)}},r.title)})))))},r}(t.Component);!function(e){e.Complete="Complete",e.Canceled="Canceled",e.AwaitingStockReturn="AwaitingStockReturn",e.AwaitingCompletion="AwaitingCompletion"}(rs||(rs={}));var os,cs=rs,ls=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={isLoadingResource:!0,returnForms:[],confirmDialog:{isOpen:!1,title:"",message:"",closeButtonLabel:"",confirmButtonLabel:"",onConfirm:function(){return null}},contextActionItems:Array()},r.tableInstance={},r.columns=[{name:"RETURN NO.",selector:"RMANumber"},{name:"CREATED DATE",selector:"Created",render:function(e){return X(e.Created).format("LLL")}},{name:"CREATED BY",selector:"Customer",render:function(e){return e.Customer.FullName}},{name:"STATUS",selector:"Status",render:function(e){return e.Status.Name}},{name:"RETURN TOTAL",selector:"Total",right:!0,render:function(e){return t.createElement(En,{amount:e.Total})}},{name:"",width:10,render:function(e,n){var s=[];return s.push({title:r.isReturnEditable(e)?"Edit":"View",clickHandler:function(t){r.goToDetail(e)}}),e.Status.Code!==cs.AwaitingStockReturn&&e.Status.Code!==cs.AwaitingCompletion||s.push({title:"Cancel",clickHandler:function(t){r.showCancelConfirmDialog(e.FormId)}}),e.Status.Code===cs.AwaitingStockReturn&&s.push({title:"Acknowledge Receipt Items",clickHandler:function(t){r.showAcknowledgeReceiptItemsConfirmDialog(e.FormId)}}),t.createElement(is,{actions:s,rowData:e,rowIndex:n})}}],r}return Te(r,e),r.prototype.componentWillMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.loadReturns()];case 1:return e.sent(),[2]}}))}))},r.prototype.loadReturns=function(){return Pe(this,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:this.setState({isLoadingResource:!0}),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,Zt.OrderGroup.getReturns(this.props.orderGroupId)];case 2:return e=r.sent(),this.setState({returnForms:e.Results}),[3,4];case 3:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,4];case 4:return this.setState({isLoadingResource:!1}),[2]}}))}))},r.prototype.goToDetail=function(e){zr.push(vt+"/"+this.props.orderGroupId+"/returns/"+e.FormId)},r.prototype.closeDialog=function(){this.setState({confirmDialog:{isOpen:!1}})},r.prototype.cancelReturn=function(e){return Pe(this,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,Zt.OrderGroup.cancelReturn(this.props.orderGroupId,e)];case 1:return r.sent(),[4,this.loadReturns()];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,4];case 4:return this.closeDialog(),[2]}}))}))},r.prototype.showCancelConfirmDialog=function(e){var t=this;this.setState({confirmDialog:{isOpen:!0,title:"Cancel Return",message:"Are you sure you want to cancel this return?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return t.cancelReturn(e)}}})},r.prototype.updateAcknowledgeReceiptItems=function(e){return Pe(this,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,Zt.OrderGroup.acknowledgeReceiptItems(this.props.orderGroupId,e)];case 1:return r.sent(),[4,this.loadReturns()];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,4];case 4:return this.closeDialog(),[2]}}))}))},r.prototype.showAcknowledgeReceiptItemsConfirmDialog=function(e){var t=this;this.setState({confirmDialog:{isOpen:!0,title:"Acknowledge Receipt Items",message:"Are you sure you want to acknowledge receipt items?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return t.updateAcknowledgeReceiptItems(e)}}})},r.prototype.isReturnEditable=function(e){return e.Status.Code===cs.AwaitingStockReturn},r.prototype.showConfirmReturnBatch=function(e){var t=this;this.setState({confirmDialog:{isOpen:!0,title:"Cancel Return(s)",message:"Are you sure you want to cancel return(s)?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return Pe(t,void 0,void 0,(function(){return Ne(this,(function(t){switch(t.label){case 0:return[4,this.cancelReturnBatch(e)];case 1:return t.sent(),[2]}}))}))}}})},r.prototype.cancelReturnBatch=function(e){return Pe(this,void 0,void 0,(function(){var t,r,n,s;return Ne(this,(function(a){switch(a.label){case 0:a.trys.push([0,6,,7]),t=0,r=e,a.label=1;case 1:return t0&&(r=!1),s.filter((function(e){return e.Status.Code!==cs.AwaitingStockReturn})).length>0&&(n=!1),r&&t.push({title:"Cancel Return(s)",clickHandler:function(){e.showConfirmReturnBatch(s)}}),n&&t.push({title:"Acknowledge Receipt Items",clickHandler:function(){e.showBatchAcknowledgeReceiptItemsConfirmDialog(s)}}),this.setState({contextActionItems:t})},r.prototype.render=function(){var e=this;return t.createElement("div",null,!this.state.isLoadingResource&&t.createElement(wn,{columns:this.columns,selectableRows:!0,onRowSelected:function(){return e.onRowSelected()},onHeaderRowSelected:function(){return e.onRowSelected()},contextActions:this.state.contextActionItems,data:this.state.returnForms,toolbar:{},tableInstance:this.tableInstance}),t.createElement(ar,{open:this.state.confirmDialog.isOpen,title:this.state.confirmDialog.title,closeLabel:this.state.confirmDialog.closeButtonLabel,okLabel:this.state.confirmDialog.confirmButtonLabel,onOK:this.state.confirmDialog.onConfirm,onClose:function(){return e.closeDialog()}},t.createElement(x,{variant:"body1"},this.state.confirmDialog.message)))},r}(t.Component),us=n.connect((function(e,t){return Ge({},t)}))(ls),ds=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={listedOrderGroups:Array()},r.columns=[{name:"No.",render:function(e){return t.createElement(x,null,"Order"===e.Type?e.OrderNumber:"# "+e.OrderGroupId)}},{name:"Created Date",render:function(e){return t.createElement(x,null,e.Created&&X(e.Created).format("LLL"))}},{name:"Amount",right:!0,render:function(e){return t.createElement(En,{amount:e.Total})}},{name:"Status",render:function(e){return t.createElement(x,null,Mn(e.OrderStatus))}},{width:50,render:function(e,n){var s=[{title:"View",clickHandler:function(t){r.goToDetail(e.OrderGroupId)}}];return t.createElement(is,{actions:s,rowData:e,rowIndex:n})}}],r}return Te(r,e),r.prototype.componentDidMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){return this.loadOrderGroups(),[2]}))}))},r.prototype.loadOrderGroups=function(){return Pe(this,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return e=this.props.paymentPlan.OrderGroupId,[4,Zt.PaymentPlan.getPurchaseOrders(e,0,500)];case 1:return t=r.sent(),this.setState({listedOrderGroups:t.Results}),[2]}}))}))},r.prototype.goToDetail=function(e){zr.push(vt+"/"+e+"?returnUrl="+Xr())},r.prototype.render=function(){return t.createElement("div",null,t.createElement(x,{variant:"h6"},"Orders History"),t.createElement("br",null),t.createElement(wn,{columns:this.columns,data:this.state.listedOrderGroups}))},r}(t.Component);!function(e){e.AwaitingInventory="AwaitingInventory",e.Cancelled="Cancelled",e.InventoryAssigned="InventoryAssigned",e.OnHold="OnHold",e.Packing="Packing",e.Released="Released",e.Shipped="Shipped"}(os||(os={}));var ps,hs=os,ms=function(e){function r(t){var r=e.call(this,t)||this;r.state={updateCustomerAddress:!1,loaded:!1,existCustomerAddress:!1,addToAddressBook:!1,customerAddressId:""},r.validator={validate:function(){return null}},r.setCurrentAddress=function(e){r.props.dispatch(rt.ContactActions.setCurrentAddress(e)),r.props.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!0))},r.handleFormChanges=function(e){var t=Object.assign({},r.props.address),n="checkbox"===e.target.type?e.target.checked:e.target.value;t[e.target.name]=n,r.setCurrentAddress(t)},r.saveChanges=function(){return Pe(r,void 0,void 0,(function(){var e,t,r,n,s,a,i,o,c,l=this;return Ne(this,(function(u){switch(u.label){case 0:if(null==(e=this.validator.validate()))return[2];t=Ge(Ge({},this.props.address),e),u.label=1;case 1:return u.trys.push([1,20,,21]),(r=this.props.orderGroup).IsDraft?(r.Forms[0].Shipments[0].ShippingAddress=Ge({},t),[4,Zt.OrderGroup.calculateOrder(r)]):[3,9];case 2:return n=u.sent(),a=n.Forms[0].Shipments[0].ShippingAddress,this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(n)),this.props.editMode?this.state.updateCustomerAddress?[4,this.updateContactAddress()]:[3,4]:[3,5];case 3:u.sent(),u.label=4;case 4:return this.props.onAddressChanged(a),[3,8];case 5:return this.state.addToAddressBook?[4,this.addContactAddress()]:[3,7];case 6:u.sent(),u.label=7;case 7:this.props.onAddressCreated(a),u.label=8;case 8:return[3,19];case 9:return this.props.editMode?this.state.updateCustomerAddress?[4,this.updateContactAddress()]:[3,11]:[3,14];case 10:u.sent(),u.label=11;case 11:return[4,Zt.OrderGroup.updateShippingAddress(r.Type,r.OrderGroupId,r.Forms[0].OrderFormId,this.props.shipment.ShipmentId,t)];case 12:return u.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(r.Type,r.OrderGroupId)];case 13:return i=u.sent(),s=i.Forms[0].Shipments.findIndex((function(e){return e.ShipmentId===l.props.shipment.ShipmentId})),a=i.Forms[0].Shipments[s].ShippingAddress,this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(i)),this.props.onAddressChanged(a),[3,19];case 14:return this.state.addToAddressBook?[4,this.addContactAddress()]:[3,16];case 15:u.sent(),u.label=16;case 16:return[4,Zt.OrderGroup.addShippingAddress(r.Type,r.OrderGroupId,r.Forms[0].OrderFormId,this.props.shipment.ShipmentId,t)];case 17:return u.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(r.Type,r.OrderGroupId)];case 18:i=u.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(i)),(o=i.Forms[0].Shipments.find((function(e){return l.props.shipment.ShipmentId===e.ShipmentId})))&&this.props.onAddressCreated(o.ShippingAddress),u.label=19;case 19:return this.props.onClose(),[3,21];case 20:return c=u.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(c.message)),[3,21];case 21:return[2]}}))}))},r.updateContactAddress=function(){return Pe(r,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return e=Ge({},this.props.address),this.state.customerAddressId&&(e.AddressId=this.state.customerAddressId),[4,Zt.Contact.updateContactAddress(this.props.orderGroup.Customer.Id,e.AddressId,e)];case 1:return t.sent(),[2]}}))}))},r.addContactAddress=function(){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,Zt.Contact.addContactAddress(this.props.orderGroup.Customer.Id,this.props.address)];case 1:return e.sent(),[2]}}))}))};var n=r.props.orderGroup.Customer.Addresses.find((function(e){return e.Name+e.DisplayName===r.props.address.Name+r.props.address.DisplayName}));return n&&(r.state.customerAddressId=n.AddressId,r.state.existCustomerAddress=!0,r.state.updateCustomerAddress=!0),r}return Te(r,e),r.prototype.componentDidMount=function(){this.setState({loaded:!0})},r.prototype.render=function(){var e=this;return t.createElement(ar,{open:!0,title:this.props.editMode?"Edit Address":"Add New Address",okLabel:"Save",onOK:this.saveChanges,closeLabel:"Cancel",onClose:this.props.onClose},this.state.loaded&&t.createElement(s.Grid,{container:!0,spacing:16},t.createElement(s.Grid,{item:!0,sm:12},t.createElement(ur,{address:this.props.address,validator:this.validator})),!this.props.orderGroup.Customer.IsAnonymous&&t.createElement(s.Grid,{item:!0,sm:12},this.props.editMode&&this.state.existCustomerAddress&&t.createElement(s.FormControlLabel,{control:t.createElement(f.Checkbox,{name:"UpdateCustomerAddress",checked:this.state.updateCustomerAddress,onChange:function(t){e.setState({updateCustomerAddress:t.target.checked})}}),label:"Also update customer's address"}),!this.props.editMode&&t.createElement(s.FormControlLabel,{control:t.createElement(f.Checkbox,{name:"AddToAddressBook",checked:this.state.addToAddressBook,onChange:function(t){e.setState({addToAddressBook:t.target.checked})}}),label:"Add to customer's address book"}))))},r}(t.Component),gs=n.connect((function(e,t){return{address:e.contact.currentAddress,orderGroup:e.orderGroup.currentOrderGroup,editMode:t.editMode,shipment:t.shipment,onClose:t.onClose,onAddressChanged:t.onAddressChanged,onAddressCreated:t.onAddressCreated}}))(ms),fs=function(e){function r(t){var r,n=e.call(this,t)||this;return n.shipmentForm={},n.shippingMethodRefreshCount=0,n.loadShippingMethods=function(e){return Pe(n,void 0,Promise,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return[4,Zt.Shipment.getShippingMethods(this.props.orderGroup.MarketId,e)];case 1:return t=r.sent(),this.setState({shippingMethods:t}),[2,t]}}))}))},n.customPropertyChangedHandler=function(e){return Pe(n,void 0,void 0,(function(){var t;return Ne(this,(function(r){return(t=this.state.properties.findIndex((function(t){return t.Name===e.Name})))>=0&&(this.state.properties[t]=Ge({},e),this.setState({properties:Re(this.state.properties)}),this.forceUpdate()),[2]}))}))},n.handleAddressChange=function(e){return Pe(n,void 0,void 0,(function(){var t,r,n=this;return Ne(this,(function(s){switch(s.label){case 0:return this.setState({addressId:e}),(t=this.props.orderGroup.OrderAddresses.find((function(t){return t.AddressId===e})))?[4,this.loadShippingMethods(t.CountryCode)]:(this.props.dispatch(rt.ApplicationActions.showNotification("AddressData not found")),[2]);case 1:return(r=s.sent()).length>0&&void 0===r.find((function(e){return e.ShippingMethodId===n.state.shippingMethodId}))&&this.setState({shippingMethodId:r[0].ShippingMethodId}),0===r.length&&this.setState({shippingMethodId:""}),[2]}}))}))},n.openEditAddressDialog=function(){var e=n.props.orderGroup.OrderAddresses.find((function(e){return e.AddressId===n.state.addressId}));e&&(n.props.dispatch(rt.ContactActions.setCurrentAddress(e)),n.setState({isShowAddressForm:!0,orderAddressEditMode:!0}))},n.openAddAddressDialog=function(){n.props.dispatch(rt.ContactActions.setCurrentAddress({})),n.setState({isShowAddressForm:!0,orderAddressEditMode:!1})},n.onAddressChanged=function(e){return Pe(n,void 0,void 0,(function(){return Ne(this,(function(t){return this.props.orderGroup.IsDraft&&this.setState({shipment:Ge(Ge({},this.state.shipment),{ShippingAddress:e})}),this.setState({addressId:e.AddressId}),[2]}))}))},n.onAddressCreated=function(e){return Pe(n,void 0,void 0,(function(){return Ne(this,(function(t){switch(t.label){case 0:return this.props.orderGroup.IsDraft&&this.setState({shipment:Ge(Ge({},this.state.shipment),{ShippingAddress:e})}),[4,this.handleAddressChange(e.AddressId)];case 1:return t.sent(),[2]}}))}))},n.state={shippingAddressDropdownIsExpanded:!1,shippingAddressFormVisible:!1,shippingMethodId:n.props.shipment.ShippingMethodId,addressId:(null===(r=n.props.shipment.ShippingAddress)||void 0===r?void 0:r.AddressId)||"",trackingNumber:n.props.shipment.ShipmentTrackingNumber,loaded:!1,errorMessage:"",shipment:JSON.parse(JSON.stringify(n.props.shipment)),selectedAddress:t.shipment.ShippingAddress,properties:Re(t.shipment.Properties),shippingMethods:[],isShowAddressForm:!1,orderAddressEditMode:!0},n}return Te(r,e),r.prototype.componentWillReceiveProps=function(e){var t,r,n,s;return Pe(this,void 0,void 0,(function(){return Ne(this,(function(a){return(null===(t=e.shipment.ShippingAddress)||void 0===t?void 0:t.AddressId)===(null===(r=this.props.shipment.ShippingAddress)||void 0===r?void 0:r.AddressId)&&(null===(n=e.shipment.ShippingAddress)||void 0===n?void 0:n.AddressId)!==this.state.addressId&&this.setState({addressId:(null===(s=e.shipment.ShippingAddress)||void 0===s?void 0:s.AddressId)||""}),[2]}))}))},r.prototype.componentDidMount=function(){var e;return Pe(this,void 0,void 0,(function(){return Ne(this,(function(t){switch(t.label){case 0:return this.setState({loaded:!0}),[4,this.loadShippingMethods(null===(e=this.state.selectedAddress)||void 0===e?void 0:e.CountryCode)];case 1:return t.sent(),[2]}}))}))},r.prototype.updateShipmentTrackingNumber=function(e){return Pe(this,void 0,void 0,(function(){var t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Zt.Shipment.updateShipmentTrackingNumber(this.props.orderGroup.OrderGroupId,this.props.orderFormId,this.props.shipment.ShipmentId,e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.prototype.setDropdownIsExpanded=function(){this.setState({shippingAddressDropdownIsExpanded:!this.state.shippingAddressDropdownIsExpanded})},r.prototype.changeShippingMethodHandler=function(e){this.setState({shippingMethodId:e})},r.prototype.changeTrackingNumber=function(e){this.setState({trackingNumber:e})},r.prototype.validateForm=function(){var e="";return this.state.shippingMethodId&&"00000000-0000-0000-0000-000000000000"!==this.state.shippingMethodId||(e="Shipping Method is required."),this.state.addressId||(e="Shipping Address is required."),this.setState({errorMessage:e}),e},r.prototype.updateShipmentProperties=function(){return Pe(this,void 0,void 0,(function(){var e,t,r;return Ne(this,(function(n){switch(n.label){case 0:if(this.props.orderGroup.IsDraft)return this.setState({shipment:Ge(Ge({},this.state.shipment),{Properties:this.state.properties})}),[2];e=0,n.label=1;case 1:if(!(e=0},r.prototype.render=function(){var e,r,n=this,a={title:this.isEditable()?"Edit Shipment":"View Shipment",open:!0,onClose:function(){n.props.onClose()}};this.isEditable()&&(a.onOK=function(){return Pe(n,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.saveForm()];case 1:return e.sent(),[2]}}))}))},a.okLabel="Save");var i=this.props.orderGroup.OrderAddresses.map((function(e,t){return{label:e.DisplayName,value:e.AddressId}})),o=this.state.shippingMethods.map((function(e){return{label:e.DisplayName,value:e.ShippingMethodId}})),c=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,l=null===(r=this.props.extendUI)||void 0===r?void 0:r.bottomPlaceHolder;return t.createElement(ar,Ge({},a),this.state.loaded&&t.createElement("div",null,c&&t.createElement(c,null),t.createElement(T.ValidatorForm,{instantValidate:!0,onSubmit:function(){return null},ref:function(e){return n.shipmentForm=e}},t.createElement(s.Grid,{container:!0,spacing:16,direction:"row"},t.createElement(s.Grid,{item:!0,sm:12},t.createElement("span",{style:{color:"red"}},this.state.errorMessage)),t.createElement(s.Grid,{item:!0,sm:12},t.createElement(_t,{label:"Choose Shipping Address *",fullWidth:!0,value:this.state.addressId,onChange:function(e){return n.handleAddressChange(e)},disabled:!this.isEditable(),options:i}),this.isEditable()&&t.createElement(s.Grid,{container:!0,spacing:16,justify:"flex-end"},t.createElement(s.Grid,{item:!0},t.createElement(s.Typography,{variant:"subtitle1",color:"primary",onClick:this.openAddAddressDialog,style:{cursor:"pointer",fontSize:"13px"}},"Add Address")),this.state.addressId&&t.createElement(s.Grid,{item:!0},t.createElement(s.Typography,{variant:"subtitle1",color:"primary",onClick:this.openEditAddressDialog,style:{cursor:"pointer",fontSize:"13px"}},"Edit Address")))),t.createElement(s.Grid,{item:!0,sm:12},t.createElement(_t,{fullWidth:!0,key:this.shippingMethodRefreshCount++,disabled:!this.isEditable(),label:"Choose Shipping Method *",value:this.state.shippingMethodId,onChange:function(e){return n.changeShippingMethodHandler(e)},options:o})),t.createElement(s.Grid,{item:!0,sm:12},"Order"===this.props.orderGroup.Type&&t.createElement(s.TextField,{label:"Tracking number",variant:"outlined",value:this.state.trackingNumber,fullWidth:!0,onChange:function(e){return n.changeTrackingNumber(e.currentTarget.value)},disabled:this.props.shipment.OrderShipmentStatus.Name!==hs.Packing})),this.props.properties&&this.props.properties.map((function(e,r){return t.createElement(s.Grid,{item:!0,sm:12,key:r},t.createElement(Rn,{key:r,property:e,isReadonly:!e.IsEditable,onPropertyChanged:n.customPropertyChangedHandler}))})))),l&&t.createElement(l,null)),this.state.isShowAddressForm&&t.createElement(gs,{onClose:function(){return n.setState({isShowAddressForm:!1})},editMode:this.state.orderAddressEditMode,shipment:this.state.shipment,onAddressChanged:this.onAddressChanged,onAddressCreated:this.onAddressCreated}))},r}(t.Component),ys=n.connect((function(e,t){var r,n,s=t.shipment,a=e.orderGroup.currentOrderGroup;return{shipment:s,orderFormId:a.Forms[e.orderGroup.selectedFormIndex].OrderFormId,orderGroup:a,createOrderAddressFormIsVisible:e.createOrderAddressForm.isVisible,properties:s.Properties,shipmentStatusUpdateDialogVisible:e.application.currentDialog===Le.UpdateShipmentStatus,customerAddresses:Re(a.Customer.Addresses),onClose:t.onClose,extendUI:null===(n=null===(r=e.setting.general)||void 0===r?void 0:r.editShipmentDialog)||void 0===n?void 0:n.extendUI}}))(fs),Es=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={shipmentDialogOpen:!1,currentShipmentIndex:0,shipmentDialog:{isOpen:!1,title:"",message:"",closeButtonLabel:"",confirmButtonLabel:"",onConfirm:function(){return null}}},r.columns=[{name:"No",right:!0,render:function(e,t){return t+1}},{name:"Recipient Name",render:function(e){var t="";return e.ShippingAddress&&(t=[e.ShippingAddress.FirstName,e.ShippingAddress.LastName].filter((function(e){return e})).join(" ")),t}},{name:"Shipping Address",render:function(e){return e.ShippingAddress?e.ShippingAddress.DisplayName:null}},{name:"Shipping Method",render:function(e){return r.getShippingMethodName(e.ShippingMethodId)}},{name:"Tracking No",selector:"ShipmentTrackingNumber"},{name:"Shipment Status",render:function(e){return Mn(e.OrderShipmentStatus.Name)}},{name:"Shipping Cost",right:!0,render:function(e){return e.ShippingCost.Amount.toFixed(e.ShippingCost.Fractions)}},{name:"Shipping Tax",right:!0,render:function(e){return e.ShippingTax.Amount.toFixed(e.ShippingTax.Fractions)}},{name:"Total (Incl tax)",right:!0,render:function(e){return e.ShipmentTotal.Amount.toFixed(e.ShipmentTotal.Fractions)+" "+e.ShipmentTotal.Currency}},{name:"",width:50,hideOnColumnsSelection:!0,render:function(e,n){var s=[{title:r.isEditableShipment(e)?"Edit":"View",clickHandler:function(e){r.openEditShipmentDialog(n)}}];return r.props.orderGroup.IsDraft||"Order"!==r.props.orderGroup.Type||(r.canReleaseShipment(e)&&s.push({title:"Release",clickHandler:function(e){r.showReleaseShipmentConfirmDialog(e.ShipmentId)}}),r.canShowAddToPickListButton(e)&&s.push({title:"Add to Picklist",clickHandler:function(e){r.showAddToPickListConfirmDialog(e.ShipmentId)}}),r.canShowCompleteButton(e)&&s.push({title:"Complete",clickHandler:function(e){r.showCompleteShipmentConfirmDialog(e.ShipmentId)}}),!r.props.orderGroup.IsDraft&&r.canShowCancelButton(e)&&s.push({title:"Cancel",clickHandler:function(e){r.showCancelShipmentConfirmDialog(e.ShipmentId)}})),t.createElement(is,{actions:s,rowData:e,rowIndex:n})}}],r}return Te(r,e),r.prototype.canReleaseShipment=function(e){return!(this.props.orderGroup.OrderStatus===zn.AwaitingExchange||!e.ShippingAddress||"00000000-0000-0000-0000-000000000000"===e.ShippingMethodId)&&this.canShowReleaseButton(e)},r.prototype.canShowReleaseButton=function(e){return e.OrderShipmentStatus.Name===hs.AwaitingInventory||e.OrderShipmentStatus.Name===hs.InventoryAssigned},r.prototype.canShowCompleteButton=function(e){return this.props.orderGroup.OrderStatus!==zn.AwaitingExchange&&e.OrderShipmentStatus.Name===hs.Packing},r.prototype.canShowCancelButton=function(e){return this.props.orderGroup.OrderStatus!==zn.AwaitingExchange&&e.OrderShipmentStatus.Name!==hs.Shipped&&e.OrderShipmentStatus.Name!==hs.OnHold&&e.OrderShipmentStatus.Name!==hs.Cancelled},r.prototype.canShowAddToPickListButton=function(e){return e.OrderShipmentStatus.Name===hs.Released},r.prototype.showCancelShipmentConfirmDialog=function(e){var t=this;this.setState({shipmentDialog:{isOpen:!0,title:"Cancel Shipment",message:"Are you sure you want to cancel this shipment?",closeButtonLabel:"Close",confirmButtonLabel:"Cancel Shipment",onConfirm:function(){return t.updateShipmentStatus(e,hs.Cancelled)}}})},r.prototype.showReleaseShipmentConfirmDialog=function(e){var t=this;this.setState({shipmentDialog:{isOpen:!0,title:"Release Shipment",message:"Are you sure you want to release this shipment?",closeButtonLabel:"Close",confirmButtonLabel:"Release Shipment",onConfirm:function(){return t.updateShipmentStatus(e,hs.Released)}}})},r.prototype.showAddToPickListConfirmDialog=function(e){var t=this;this.setState({shipmentDialog:{isOpen:!0,title:"Add to PickList",message:"Are you sure you want to add this shipment to a new picklist?",closeButtonLabel:"Close",confirmButtonLabel:"Add to PickList",onConfirm:function(){return t.addShipmentToPickList(e)}}})},r.prototype.closeShipmentDialog=function(){this.setState({shipmentDialog:{isOpen:!1}})},r.prototype.addShipmentToPickList=function(e){return Pe(this,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:this.closeShipmentDialog(),this.props.dispatch(rt.ApplicationActions.setLoadingOverlayState(!0)),n.label=1;case 1:return n.trys.push([1,4,,5]),[4,Zt.Shipment.addToPickList(this.props.orderGroup.OrderGroupId,this.props.orderFormId,e)];case 2:return n.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 3:return t=n.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(t)),this.props.dispatch(rt.ApplicationActions.setLoadingOverlayState(!1)),[3,5];case 4:return r=n.sent(),this.props.dispatch(rt.ApplicationActions.setLoadingOverlayState(!1)),this.props.dispatch(rt.ApplicationActions.showNotification(r.message)),[3,5];case 5:return[2]}}))}))},r.prototype.showCompleteShipmentConfirmDialog=function(e){var t=this;this.setState({shipmentDialog:{isOpen:!0,title:"Complete Shipment",message:"Are you sure you want to complete this shipment?",closeButtonLabel:"Close",confirmButtonLabel:"Complete Shipment",onConfirm:function(){return t.updateShipmentStatus(e,hs.Shipped)}}})},r.prototype.updateShipmentStatus=function(e,t){return Pe(this,void 0,void 0,(function(){var r,n;return Ne(this,(function(s){switch(s.label){case 0:this.closeShipmentDialog(),this.props.dispatch(rt.ApplicationActions.setLoadingOverlayState(!0)),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,Zt.Shipment.updateShipmentStatus(this.props.orderGroup.OrderGroupId,this.props.orderFormId,e,t)];case 2:return s.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 3:return r=s.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(r)),this.props.dispatch(rt.ApplicationActions.setLoadingOverlayState(!1)),[3,5];case 4:return n=s.sent(),this.props.dispatch(rt.ApplicationActions.setLoadingOverlayState(!1)),this.props.dispatch(rt.ApplicationActions.showNotification(n.message)),[3,5];case 5:return[2]}}))}))},r.prototype.openEditShipmentDialog=function(e){this.setState({shipmentDialogOpen:!0,currentShipmentIndex:e})},r.prototype.isEditableShipment=function(e){var t=e.OrderShipmentStatus.Name;return!(t===hs.Cancelled||t===hs.OnHold||t===hs.Shipped)},r.prototype.getShippingMethodName=function(e){var t;return null===(t=this.props.shippingMethods.filter((function(t){return t.ShippingMethodId===e}))[0])||void 0===t?void 0:t.DisplayName},r.prototype.render=function(){var e=this;return t.createElement("div",null,t.createElement(s.Typography,{variant:"h6"},"Shipments"),t.createElement("br",null),t.createElement(wn,{columns:this.columns,data:this.props.shipments}),this.state.shipmentDialogOpen&&t.createElement(ys,{shipment:this.props.shipments[this.state.currentShipmentIndex],isShipmentReadonly:this.isEditableShipment(this.props.shipments[this.state.currentShipmentIndex]),onClose:function(){e.setState({shipmentDialogOpen:!1})}}),this.state.shipmentDialog.isOpen&&t.createElement(ir,{title:this.state.shipmentDialog.title,closeButtonLabel:this.state.shipmentDialog.closeButtonLabel,confirmButtonLabel:this.state.shipmentDialog.confirmButtonLabel,onConfirm:this.state.shipmentDialog.onConfirm,onClose:function(){e.setState({shipmentDialog:{isOpen:!1}})}},t.createElement(s.Typography,{variant:"body1"},this.state.shipmentDialog.message)))},r}(t.Component),vs=o.withStyles((function(e){e.palette;var t,r=e.spacing,n=e.breakpoints;return s.createStyles({root:{},paper:(t={padding:2*r.unit,marginBottom:2*r.unit},t[n.down("xs")]={padding:10},t)})}))(n.connect((function(e,t){var r=e.orderGroup.currentOrderGroup,n=r.Forms[e.orderGroup.selectedFormIndex];return{shipments:t.shipments,orderGroup:r,shippingMethods:e.shipment.shippingMethods,orderFormId:n.OrderFormId,classes:t.classes}}))(Es)),Cs=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({root:{"&-inline":{display:"inline-block"}}})}))((function(e){var r=e.classes;return t.createElement("div",{className:r.root+" "+(e.renderInline?r.root+"-inline":"")},t.createElement(x,{variant:"body1",color:"textSecondary"},e.message))})),Ss=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={AddToAddressBook:!0},t.validator={validate:function(){return null}},t.handleCheckboxChange=function(e){t.setState({AddToAddressBook:e.target.checked})},t.saveChanges=function(){return Pe(t,void 0,void 0,(function(){var e,t,r,n,s;return Ne(this,(function(a){switch(a.label){case 0:if(null==(e=this.validator.validate()))return[2];t=Ge(Ge({},this.props.address),e),a.label=1;case 1:return a.trys.push([1,8,,9]),this.state.AddToAddressBook?[4,this.props.addContactAddress(this.props.currentContactId,t)]:[3,5];case 2:return a.sent(),[4,this.props.getContact(this.props.currentContactId)];case 3:return r=a.sent(),this.props.dispatch(rt.ContactActions.setCurrentContact(r)),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.currentOrderGroup.Type,this.props.currentOrderGroup.OrderGroupId)];case 4:(n=a.sent()).Customer=r,this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(n)),a.label=5;case 5:return this.props.processOnAddressCreation?[4,this.props.processOnAddressCreation(t,this.props.addressType)]:[3,7];case 6:a.sent(),a.label=7;case 7:return this.props.addressType===Fe.BillingAddress&&this.props.dispatch(rt.PaymentActions.setBillingAddress(t)),this.closeDialog(),[3,9];case 8:return s=a.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(s.message)),[3,9];case 9:return[2]}}))}))},t.closeView=function(){t.props.dispatch(rt.CreateOrderAddressFormAction.hideCreateOrderAddressForm()),t.props.dispatch(rt.AddressFormActions.clearAddressForm()),t.props.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!1))},t}return Te(r,e),r.prototype.closeDialog=function(){this.closeView(),this.props.onClose()},r.prototype.render=function(){var e=this;return t.createElement(s.Dialog,{open:!0,"aria-describedby":"alert-dialog-description",className:this.props.classes.root,fullWidth:!0},t.createElement(ce,null,"Add New Address"),t.createElement(g,{id:"alert-dialog-description"},t.createElement(ur,{address:this.props.address,validator:this.validator}),"Order"===this.props.currentOrderGroup.Type&&t.createElement(s.FormControlLabel,{control:t.createElement(f.Checkbox,{name:"AddToAddressBook",checked:this.state.AddToAddressBook,onChange:this.handleCheckboxChange}),label:"Add to customer's address book"})),t.createElement(m,null,t.createElement(f.TextButton,{onClick:function(){return e.closeDialog()}},"Cancel"),t.createElement(f.TextButton,{unelevated:!0,type:"submit",onClick:this.saveChanges},"Add as ",this.props.addressType)))},r}(t.Component),Is=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({root:{}})}))(n.connect((function(e,t){var r=e.orderGroup.currentOrderGroup;return{addContactAddress:Zt.Contact.addContactAddress,address:e.contact.currentAddress,currentContactId:e.contact.currentContact.Id,currentOrderGroup:r,addressType:e.createOrderAddressForm.addressType,classes:t.classes,getContact:Zt.Contact.get,onClose:t.onClose,processOnAddressCreation:t.processOnAddressCreation}}))(Ss)),bs=function(e){function r(t){var r=e.call(this,t)||this;r.state={updateCustomerAddress:!1,loaded:!1,existCustomerAddress:!1,addToAddressBook:!1,customerAddressId:""},r.validator={validate:function(){return null}},r.setCurrentAddress=function(e){r.props.dispatch(rt.ContactActions.setCurrentAddress(e)),r.props.dispatch(rt.ApplicationActions.setIsCurrentFormDirty(!0))},r.handleFormChanges=function(e){var t=Object.assign({},r.props.address),n="checkbox"===e.target.type?e.target.checked:e.target.value;t[e.target.name]=n,r.setCurrentAddress(t)},r.saveChanges=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:if(null==this.validator.validate())return[2];r.label=1;case 1:return r.trys.push([1,10,,11]),this.props.editMode?this.state.updateCustomerAddress?[4,this.updateContactAddress()]:[3,3]:[3,5];case 2:r.sent(),r.label=3;case 3:return[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 4:return e=r.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(e)),this.props.onAddressChanged(Ge({},this.props.address)),[3,9];case 5:return this.state.addToAddressBook?[4,this.addContactAddress()]:[3,7];case 6:r.sent(),r.label=7;case 7:return[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 8:e=r.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(e)),this.props.onAddressCreated(this.props.address),r.label=9;case 9:return this.props.onClose(),[3,11];case 10:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,11];case 11:return[2]}}))}))},r.updateContactAddress=function(){return Pe(r,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return e=Ge({},this.props.address),this.state.customerAddressId&&(e.AddressId=this.state.customerAddressId),[4,Zt.Contact.updateContactAddress(this.props.orderGroup.Customer.Id,e.AddressId,e)];case 1:return t.sent(),[2]}}))}))},r.addContactAddress=function(){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,Zt.Contact.addContactAddress(this.props.orderGroup.Customer.Id,this.props.address)];case 1:return e.sent(),[2]}}))}))};var n=r.props.orderGroup.Customer.Addresses.find((function(e){return e.Name+e.DisplayName===r.props.address.Name+r.props.address.DisplayName}));return n&&(r.state.customerAddressId=n.AddressId,r.state.existCustomerAddress=!0,r.state.updateCustomerAddress=!0),r}return Te(r,e),r.prototype.componentDidMount=function(){this.setState({loaded:!0})},r.prototype.render=function(){var e=this;return t.createElement(ar,{open:!0,title:this.props.editMode?"Edit Address":"Add New Address",okLabel:"Save",onOK:this.saveChanges,closeLabel:"Cancel",onClose:this.props.onClose},this.state.loaded&&t.createElement(s.Grid,{container:!0,spacing:16},t.createElement(s.Grid,{item:!0,sm:12},t.createElement(ur,{address:this.props.address,validator:this.validator})),!this.props.orderGroup.Customer.IsAnonymous&&t.createElement(s.Grid,{item:!0,sm:12},this.props.editMode&&this.state.existCustomerAddress&&t.createElement(s.FormControlLabel,{control:t.createElement(f.Checkbox,{name:"UpdateCustomerAddress",checked:this.state.updateCustomerAddress,onChange:function(t){e.setState({updateCustomerAddress:t.target.checked})}}),label:"Also update customer's address"}),!this.props.editMode&&t.createElement(s.FormControlLabel,{control:t.createElement(f.Checkbox,{name:"AddToAddressBook",checked:this.state.addToAddressBook,onChange:function(t){e.setState({addToAddressBook:t.target.checked})}}),label:"Add to customer's address book"}))))},r}(t.Component),As=n.connect((function(e,t){return{address:e.contact.currentAddress,orderGroup:e.orderGroup.currentOrderGroup,editMode:t.editMode,onClose:t.onClose,onAddressChanged:t.onAddressChanged,onAddressCreated:t.onAddressCreated}}))(bs),Os=function(e){function r(t){var r=e.call(this,t)||this;return r.state={paymentInProcess:!1,paymentAddressFormVisible:!1,billingAddressId:"",paymentMethodId:"",selectedPayment:{},billingAddress:{},loaded:!1,errors:{BillingAddressId:"",PaymentMethodId:"",TransactionAmount:""},isShowAddressForm:!1,billingAddressEditMode:!0},r.validationSchema=b.object({BillingAddressId:b.string().required("Billing Address is required."),PaymentMethodId:b.string().required("Payment Method is required."),TransactionAmount:b.number().required("Transaction Amount is required.").min(0).lessThan(Number.MAX_SAFE_INTEGER,"This value is out of range.")}),r.validateForm=function(){return Pe(r,void 0,void 0,(function(){var e,t,r;return Ne(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.validationSchema.validate({BillingAddressId:this.state.billingAddressId,TransactionAmount:Number(null===(r=this.state.selectedPayment.Amount)||void 0===r?void 0:r.Amount)||void 0,PaymentMethodId:this.state.paymentMethodId},{abortEarly:!1})];case 1:return n.sent(),[2,!0];case 2:return e=n.sent(),t={},e.inner.map((function(e){t[e.path]=e.message})),this.setState({errors:t}),[2,!1];case 3:return[2]}}))}))},r.addPayment=function(){return Pe(r,void 0,void 0,(function(){var e,t,r,n,s=this;return Ne(this,(function(a){switch(a.label){case 0:return[4,this.validateForm()];case 1:if(!a.sent())return[2];if(this.setState({paymentInProcess:!0}),(e=this.props.orderGroup.OrderAddresses.find((function(e){return e.AddressId===s.state.billingAddressId})))||(e=this.state.billingAddress),!this.state.billingAddress)return[3,7];this.state.selectedPayment.BillingAddress=e,a.label=2;case 2:return a.trys.push([2,5,,6]),[4,Zt.OrderGroup.addPayment(this.props.orderGroup.Type,this.state.selectedPayment,this.props.orderGroup.OrderGroupId,this.props.orderForm.OrderFormId)];case 3:return t=a.sent(),this.props.orderForm.Payments.push(t.data),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 4:return r=a.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(r)),this.props.onClose(),[3,6];case 5:return n=a.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(n.message)),[3,6];case 6:return[3,8];case 7:this.props.dispatch(rt.ApplicationActions.showNotification("You need to choose a billing address.")),a.label=8;case 8:return this.setState({paymentInProcess:!1}),[2]}}))}))},r.changeTransactionAmountHandler=function(e){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(t){return this.updatePayment(this.state.selectedPayment,"Amount",{Currency:this.state.selectedPayment.Amount.Currency,Amount:e}),[2]}))}))},r.customPropertyChangedHandler=function(e){return Pe(r,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){for(t=this.state.selectedPayment.Properties,r=0;r=1&&(e=this.props.paymentMethods.find((function(e){return!0===e.IsDefault}))),void 0===e?[3,2]:[4,Zt.OrderGroup.getPaymentModel(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId,this.props.orderForm.OrderFormId,e.PaymentMethodId)];case 1:t=r.sent(),this.setState({paymentMethodId:e.PaymentMethodId,selectedPayment:t}),r.label=2;case 2:return[2]}}))}))},r.prototype.setDefaultBillingAddress=function(){return Pe(this,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){return null!==(e=this.props.orderGroup.OrderAddresses)&&(t=void 0,e.length>=1&&(t=e.find((function(e){return!0===e.IsPreferredBillingAddress}))),void 0!==t&&this.setState({billingAddress:t})),[2]}))}))},r.prototype.updatePayment=function(e,t,r){var n=Object.assign({},e);n[t]=r,this.setState({selectedPayment:n})},r.prototype.changePaymentMethod=function(e){return Pe(this,void 0,void 0,(function(){var t,r=this;return Ne(this,(function(n){switch(n.label){case 0:return[4,Zt.OrderGroup.getPaymentModel(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId,this.props.orderForm.OrderFormId,e)];case 1:return t=n.sent(),this.setState({paymentMethodId:e,selectedPayment:t},(function(){var e=r.getRemainTransactionAmount();r.changeTransactionAmountHandler(e)})),[2]}}))}))},r.prototype.getRemainTransactionAmount=function(){return(this.props.orderGroup.Total.Amount-(this.props.orderForm.AuthorizedPaymentTotal.Amount+this.props.orderForm.CapturedPaymentTotal.Amount)).toFixed(this.props.orderGroup.Total.Fractions)},r.prototype.render=function(){var e=this,r=this.props.paymentMethods.map((function(e){return{label:e.Name+" "+e.LanguageId,value:e.PaymentMethodId}})),n=Re(this.props.orderGroup.OrderAddresses);this.state.billingAddress.AddressId&&void 0===n.find((function(t){return t.DisplayName===e.state.billingAddress.DisplayName}))&&(n=Re([this.state.billingAddress],this.props.orderGroup.OrderAddresses));var a=n.map((function(e){return{label:e.DisplayName,value:e.AddressId}}));return t.createElement(ar,{open:!0,title:"Add Payment",onClose:this.props.onClose,okLabel:"Save",closeLabel:"Cancel",onOK:this.addPayment},this.state.paymentAddressFormVisible&&t.createElement(Is,{onClose:function(){e.setState({paymentAddressFormVisible:!1})}}),this.state.loaded&&t.createElement(s.Grid,{container:!0,spacing:16},t.createElement(s.Grid,{item:!0,xs:12},t.createElement(s.Grid,{container:!0,spacing:16},t.createElement(s.Grid,{item:!0,xs:12},t.createElement(_t,{label:"Billing Address",fullWidth:!0,options:a,value:this.state.billingAddressId,onChange:function(t){return e.billingAddressChange(t)}}),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.BillingAddressId),t.createElement(s.Grid,{container:!0,spacing:16,justify:"flex-end"},t.createElement(s.Grid,{item:!0},t.createElement(s.Typography,{variant:"subtitle1",color:"primary",onClick:this.openAddAddressDialog,style:{cursor:"pointer",fontSize:"13px"}},"Add Address")),this.state.billingAddressId&&t.createElement(s.Grid,{item:!0},t.createElement(s.Typography,{variant:"subtitle1",color:"primary",onClick:this.openEditAddressDialog,style:{cursor:"pointer",fontSize:"13px"}},"Edit Address")))),t.createElement(s.Grid,{item:!0,xs:12},t.createElement(_t,{label:"Payment Method",fullWidth:!0,options:r,value:this.state.paymentMethodId,onChange:function(t){return e.changePaymentMethod(t)}}),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.PaymentMethodId)),this.state.paymentMethodId&&t.createElement(s.Grid,{item:!0,xs:12},t.createElement(s.TextField,{id:"transactionAmount",name:"TransactionAmount",type:"number",label:"Transaction Amount",fullWidth:!0,variant:"outlined",defaultValue:this.getRemainTransactionAmount(),onChange:function(t){return e.changeTransactionAmountHandler(t.target.value)},error:!!this.state.errors.TransactionAmount,helperText:this.state.errors.TransactionAmount,inputProps:{step:.1,min:0}})))),this.state.paymentMethodId&&this.state.selectedPayment.Properties&&this.state.selectedPayment.Properties.length>0&&t.createElement(s.Grid,{item:!0,xs:12},t.createElement(Ln,{isCollapsible:!1,properties:this.state.selectedPayment.Properties,onPropertyChanged:this.customPropertyChangedHandler}))),this.state.isShowAddressForm&&t.createElement(As,{onClose:function(){return e.setState({isShowAddressForm:!1})},editMode:this.state.billingAddressEditMode,onAddressChanged:this.updateBillingAddress,onAddressCreated:this.updateBillingAddress}))},r}(t.Component),Ts=n.connect((function(e,t){var r=e.orderGroup.currentOrderGroup;return{paymentMethods:e.payment.paymentMethods,orderGroup:r,orderForm:r.Forms[e.orderGroup.selectedFormIndex],onClose:t.onClose}}))(Os),ws=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={isAddPaymentFormVisible:!1},r.columns=[{name:"Payment Method",render:function(e){return t.createElement(x,null,e.PaymentMethodName)}},{name:"Billing Address",render:function(e){return t.createElement(cr,{address:e.BillingAddress})}},{name:"Status",render:function(e){return t.createElement(x,null,Mn(e.Status))}},{name:"Transaction Amount",render:function(e){return t.createElement(En,{amount:e.Amount,variant:"body2"})}},{name:"Transaction Type",render:function(e){return t.createElement(x,null,Mn(e.TransactionType))}},{name:"Transaction ID",render:function(e){return t.createElement(x,null,Mn(e.TransactionID))}},{name:"Provider Transaction ID",render:function(e){return t.createElement(x,null,Mn(e.ProviderTransactionID))}}],r}return Te(r,e),r.prototype.render=function(){var e=this;return t.createElement(s.Grid,{container:!0,direction:"column",spacing:16},t.createElement(s.Grid,{item:!0},t.createElement(x,{variant:"h6"},"Transactions")),t.createElement(s.Grid,{item:!0},t.createElement(ue,null)),!this.state.isAddPaymentFormVisible&&this.props.canAcceptPayment&&t.createElement(s.Grid,{item:!0},t.createElement(f.TextButton,{unelevated:!0,onClick:function(){return e.setState({isAddPaymentFormVisible:!0})}},"Add Payment")),t.createElement(s.Grid,{item:!0},this.props.payments.length>0?t.createElement(wn,{columns:this.columns,data:this.props.payments}):t.createElement(Cs,{message:"No payments found."})),this.state.isAddPaymentFormVisible&&t.createElement(Ts,{onClose:function(){e.setState({isAddPaymentFormVisible:!1})}}))},r}(t.Component),Gs=function(e){var t=e.orderGroup.currentOrderGroup,r=!1;if("Cart"!==t.Type){var n=t.Forms[e.orderGroup.selectedFormIndex],s=n.AuthorizedPaymentTotal.Amount+n.CapturedPaymentTotal.Amount0&&Ns(e.orderGroupType,e.orderGroupId,e.orderForm.OrderFormId,e.couponTextFieldValue,n,s)},inputProps:{className:r.couponTextFieldFocus},InputProps:{className:r.couponTextFieldInput,endAdornment:t.createElement(he,{position:"end"},t.createElement(J,{title:"Add "+e.couponTextFieldValue+" as a coupon code"},t.createElement("div",null,t.createElement(f.IconButton,{disabled:0===e.couponTextFieldValue.length,onClick:function(){return Ns(e.orderGroupType,e.orderGroupId,e.orderForm.OrderFormId,e.couponTextFieldValue,n,s)}},t.createElement(F,null)))))}})),e.coupons.length>0?e.coupons.map((function(a,i){return t.createElement(d,{item:!0,key:i},t.createElement(de,{avatar:a.Applied?t.createElement(me,{className:r.chipAvatar},t.createElement(ge,null)):void 0,className:r.chip,label:a.Code,variant:a.Applied?"default":"outlined",onDelete:e.isReadonly?void 0:function(){return function(e,t,r,n,s,a){return Pe(void 0,void 0,void 0,(function(){var i;return Ne(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,Zt.OrderGroup.removeCoupon(e,t,r,a)];case 1:return o.sent(),Ps(e,t,n,s),[3,3];case 2:return i=o.sent(),s(i.message),[3,3];case 3:return[2]}}))}))}(e.orderGroupType,e.orderGroupId,e.orderForm.OrderFormId,n,s,a)}}))})):t.createElement(d,{item:!0},t.createElement(Cs,{message:Mn(e.orderGroupType)+" contains no coupons.",renderInline:!0}))))})));!function(e){e[e.None=0]="None",e[e.Money=1]="Money",e[e.Percentage=2]="Percentage",e[e.Free=3]="Free",e[e.FixedPrice=4]="FixedPrice",e[e.Gift=5]="Gift"}(ps||(ps={}));var xs,Ls=ps,Ms=function(e){return e.promotionInformation.RewardType===Ls.Gift?t.createElement(x,Ge({},e),"Gift"):t.createElement(En,Ge({},e.typographyProps,{amount:e.promotionInformation.SavedAmount}))},Fs=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({})}))((function(e){var r=[{name:"Discount",selector:"Name"},{name:"Description",selector:"Description"},{name:"Coupon Code",selector:"CouponCode"},{name:"Saved Amount",right:!0,render:function(e){return t.createElement(Ms,{promotionInformation:e,typographyProps:{variant:"body1"}})}}];return t.createElement(d,{direction:"column",spacing:16,container:!0},t.createElement(d,{item:!0},t.createElement(x,{variant:"h6",gutterBottom:!0},"Discounts")),t.createElement(d,{item:!0},t.createElement(s.Divider,null)),!e.isCreateNewOrder&&t.createElement(d,{item:!0},t.createElement(Rs,{isReadonly:e.isReadonly})),t.createElement(d,{item:!0},e.promotionInformation.length>0?t.createElement(wn,{columns:r,data:e.promotionInformation}):t.createElement(Cs,{message:"There are currently no discounts applied."})))})),ks=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({root:{width:48,height:48,display:"inline-flex",justifyContent:"center",alignItems:"center"},tooltip:{postition:"relative",height:"100%",width:"100%"}})}))((function(e){var r=e.classes,n=e.children;return t.createElement("div",{className:r.root},t.createElement(J,{classes:{tooltip:r.tooltip},title:e.tooltipMessage},t.createElement(Ee,{badgeContent:e.badgeContent,color:"primary"},n)))})),_s=function(e){var r=e.ThumbnailUrl?t.createElement(me,{src:e.ThumbnailUrl}):t.createElement(fe,null);return e.IsGift?t.createElement(ks,{tooltipMessage:"Gift",badgeContent:t.createElement(ye,{style:{width:"0.75em"}})},r):r},Vs=function(e){return t.createElement(s.Grid,{container:!0,direction:"row",justify:"flex-start",spacing:8},e.properties&&Object.keys(e.properties).map((function(r){return t.createElement(s.Grid,{item:!0,key:r},t.createElement(x,{color:"textSecondary",variant:"body2"},r,": ",t.createElement("strong",null,e.properties[r])))})))},Us=require("autosuggest-highlight/match"),Bs=require("autosuggest-highlight/parse"),Hs=function(e){e.classes;var r=De(e,["classes"]);return t.createElement(s.TextField,Ge({fullWidth:!0,label:"Product Variant",placeholder:"Search by catalog SKU code or name",variant:"outlined"},r))},qs=function(e){return e.Code},Ws=function(e){function r(r){var n=e.call(this,r)||this;return n.classes=n.props.classes,n.state={searchFieldValue:"",suggestions:[],isWaitingSuggestions:!1},n.requiredSearchStringLength=3,n.SuggestionsContainer=function(e){var r=e.containerProps,a=e.children;return t.createElement(s.Paper,Ge({},r,{className:n.classes.suggestionsContainerOpen,square:!0}),n.state.isWaitingSuggestions&&t.createElement("div",{className:n.classes.progressContainer},t.createElement(s.CircularProgress,{className:n.classes.progressIndicator})),a)},n.selectSuggestion=function(e,t){return Pe(n,void 0,void 0,(function(){return Ne(this,(function(e){return this.props.onSelected(t.suggestion),[2]}))}))},n.getSuggestions=function(e){var t=e.value;return Pe(n,void 0,void 0,(function(){var e,r,n;return Ne(this,(function(s){switch(s.label){case 0:return e=t.trim().toLowerCase(),r=[],this.props.dispatch(rt.ApplicationActions.setIsLoadingResource(!0)),e.length0&&(r=r.map((function(e){return e})),this.setState({suggestions:r})),[3,4];case 3:return n=s.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(n.message)),[3,4];case 4:return this.props.dispatch(rt.ApplicationActions.setIsLoadingResource(!1)),[2,r]}}))}))},n.clearSuggestions=function(){n.setState({suggestions:[]})},n.updateSearchFieldValue=function(e,t){t&&(n.setState({searchFieldValue:t.newValue}),n.props.onSearchFieldChanged&&n.props.onSearchFieldChanged(t.newValue))},n.renderEntrySuggestion=function(e,r){return function(e,r){var n=Us(e.DisplayName,r.query),a=Bs(e.DisplayName,n),i=Us(e.Code,r.query),o=Bs(e.Code,i),c=r.isHighlighted?tr.hoveredList:"#fff";return t.createElement(f.List,{style:{backgroundColor:c,paddingTop:0,paddingBottom:0}},t.createElement(f.ListItem,{style:{height:"auto"}},""!==e.ThumbnailUrl?t.createElement(s.Avatar,{src:e.ThumbnailUrl}):t.createElement(s.Avatar,null,t.createElement(fe,null)),t.createElement(f.ListItemText,{primaryText:t.createElement("div",{style:{textAlign:"left",minHeight:"50px",paddingLeft:"16px",width:"100%"}},t.createElement(s.Typography,{variant:"subtitle1"},a.map((function(e,r){return e.highlight?t.createElement("span",{key:String(r),style:{fontWeight:500}},e.text):t.createElement("strong",{key:String(r),style:{fontWeight:300}},e.text)}))),t.createElement(d,{container:!0,spacing:16,justify:"space-between"},t.createElement(d,{item:!0,xs:12,sm:6},t.createElement(s.Typography,{variant:"body1",color:"textSecondary"},o.map((function(e,r){return e.highlight?t.createElement("span",{key:String(r),style:{fontWeight:500}},e.text):t.createElement("strong",{key:String(r),style:{fontWeight:300}},e.text)})))),t.createElement(d,{item:!0,xs:12,sm:3},t.createElement(s.Typography,{variant:"body1",color:"textSecondary",style:{fontWeight:300}},"In Stock: ",e.InStock)),t.createElement(d,{item:!0,xs:12,sm:3},e.ProductUrl&&t.createElement("a",{href:e.ProductUrl,target:"_blank",rel:"noopener noreferrer",onClick:function(e){e.stopPropagation()}},t.createElement(s.Typography,null,"More Details"))),t.createElement(d,{item:!0,xs:12},t.createElement(Vs,{properties:e.CustomProperties}))))}),e.QuantityInShipment>0&&t.createElement("div",{style:{marginLeft:"-40px"}},t.createElement(ks,{badgeContent:e.QuantityInShipment,tooltipMessage:"The shipment already contains "+e.QuantityInShipment+" of this item."},t.createElement(Se,null)))),t.createElement(f.ListDivider,null))}(e,r)},n.getSuggestionsDebounce=ve.debounce(n.getSuggestions,1e3,{trailing:!0}),n}return Te(r,e),r.prototype.render=function(){return t.createElement("div",{className:this.classes.root},t.createElement(Ce,{suggestions:this.state.suggestions.slice(0,20),renderInputComponent:Hs,onSuggestionsFetchRequested:this.getSuggestionsDebounce,onSuggestionsClearRequested:this.clearSuggestions,renderSuggestionsContainer:this.SuggestionsContainer,getSuggestionValue:qs,renderSuggestion:this.renderEntrySuggestion,onSuggestionSelected:this.selectSuggestion,theme:{container:this.classes.container,suggestionsContainerOpen:this.classes.suggestionsContainerOpen,suggestionsList:this.classes.suggestionsList,suggestion:this.classes.suggestion},inputProps:{classes:this.classes,value:this.state.searchFieldValue,onChange:this.updateSearchFieldValue,type:"search"}}))},r}(t.Component),js=o.withStyles((function(e){var t=e.palette,r=e.spacing;e.breakpoints;return s.createStyles({root:{flexGrow:1},container:{position:"relative",textAlign:"center",minHeight:56},suggestionsContainerOpen:{position:"absolute",zIndex:2,marginTop:r.unit,left:0,right:0,width:"100%"},suggestion:{display:"block",cursor:"pointer"},suggestionsList:{margin:0,padding:0,listStyleType:"none"},divider:{height:2*r.unit},progressContainer:{marginTop:8},progressIndicator:{color:t.secondary.light,margin:8},noResultsFound:{fontStyle:"italic",textAlign:"center",padding:6,marginTop:8}})}))(n.connect((function(e,t){return{classes:t.classes,onSelected:t.onSelected,onSearchFieldChanged:t.onSearchFieldChanged}}))(Ws));!function(e){e[e.Percentage=1]="Percentage",e[e.Value=2]="Value"}(xs||(xs={}));var Ys=xs,zs=function(e){function r(t){var r=e.call(this,t)||this;if(r.state={lineItem:r.props.lineItem,openEntrySelectionView:!1,shipmentId:-1,quantity:1,placedPrice:r.props.lineItem.PlacedPrice?r.props.lineItem.PlacedPrice.Amount:0,defaultPlacedPrice:-1,entrySelectedSuggestion:{},editMode:!1,errorMessage:"",discountType:Ys.Value,discountValue:0,discountDescription:"",showDialog:!1,properties:new Array,shipmentOptions:[],isBundle:!1,isReadonly:r.props.isReadonly,originalLineItem:{},errors:{Quantity:"",PlacedPrice:"",DiscountValue:"",DiscountType:"",ShipmentId:"",LineItemCode:""}},r.customPropertiesForm={},r.validationSchema=b.object().shape({Quantity:b.number().required().positive().lessThan(Number.MAX_SAFE_INTEGER,"This value is out of range."),EditMode:b.bool(),PlacedPrice:b.number().min(0).lessThan(Number.MAX_SAFE_INTEGER,"This value is out of range."),ShipmentId:b.number().required("Please select a Shipment."),LineItemCode:b.string().when("EditMode",{is:!1,then:b.string().required("Product variant is required.")}),DiscountType:b.number(),DiscountValue:b.number().min(0).when("DiscountType",{is:1,then:b.number().max(100,"DiscountValue must be between 0-100."),otherwise:b.number().max(b.ref("PlacedPrice"),"DiscountValue can not exceed PlacedPrice.")})}),r.submitForm=function(){return Pe(r,void 0,void 0,(function(){var e,t,r,n,s,a,i,o,c,l,u,d,p,h,m;return Ne(this,(function(g){switch(g.label){case 0:return this.customPropertiesForm.isFormValid()?[4,this.validateForm()]:[2];case 1:return g.sent()?(e=this.getExistedLineItem(this.state.entrySelectedSuggestion.Code),this.state.editMode||e?(t=e?e.LineItemId:this.props.lineItem.LineItemId,r=e?e.Quantity:0,n=r+this.state.quantity,s={OrderGroupId:this.props.orderGroup.OrderGroupId,OrderGroupType:this.props.orderGroup.Type,LineItemId:t,Quantity:n,PlacedPrice:this.state.placedPrice},this.state.discountValue>0&&(s.DiscountType=this.state.discountType,s.DiscountValue=this.state.discountValue,s.DiscountDescription=this.state.discountDescription),this.state.editMode?[4,this.updateLineItemProperties()]:[3,3]):[3,10]):[2];case 2:g.sent(),g.label=3;case 3:return this.props.orderGroup.IsDraft?((a=e?JSON.parse(JSON.stringify(e)):this.state.lineItem).Quantity=s.Quantity,s.PlacedPrice&&(a.PlacedPrice.Amount=s.PlacedPrice),(i=s.DiscountValue?{ManualDiscountType:s.DiscountType,DiscountValue:s.DiscountValue,Description:s.DiscountDescription}:void 0)&&(a.ManualDiscount=i),o=JSON.parse(JSON.stringify(this.props.orderGroup)),c=o.Forms[0].Shipments[0].LineItems,l=c.findIndex((function(e){return e.LineItemId===t})),c[l]=a,[4,Zt.OrderGroup.calculateOrder(o)]):[3,5];case 4:return o=g.sent(),p=o.ValidationMessages,this.lineItemHasChangedPrice(e||this.state.originalLineItem,o)&&(h="The price for product "+a.Code+" has changed since it was added to your cart.",p.push(h)),p.length>0?this.props.dispatch(rt.ApplicationActions.showNotification(p.join("\n"))):this.props.dispatch(rt.ApplicationActions.showNotification("The line item was successfully updated.")),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(o)),[3,9];case 5:return g.trys.push([5,8,,9]),[4,Zt.OrderGroup.updateLineItem(s)];case 6:return u=g.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 7:return d=g.sent(),p=[],this.isValidationMessagesReturned(u)&&(p=u.data),this.lineItemHasChangedPrice(e||this.state.originalLineItem,d)&&(h="The price for product "+(e?e.Code:this.state.originalLineItem.Code)+" has changed since it was added to your cart.",p.push(h)),p.length>0?this.props.dispatch(rt.ApplicationActions.showNotification(p.join("\n"))):this.props.dispatch(rt.ApplicationActions.showNotification("The line item was successfully updated.")),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(d)),[3,9];case 8:return m=g.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(m.message)),[3,9];case 9:return this.props.onClose(),[3,12];case 10:return[4,this.addLineItemToOrderGroup()];case 11:g.sent()&&this.props.onClose(),g.label=12;case 12:return[2]}}))}))},r.lineItemHasChangedPrice=function(e,t){var r=t.Forms[0];if(t.IsDraft)for(var n=0;n=0&&this.setState({placedPrice:t},this.validateForm),[2]}))}))},r.updateDiscountPrice=function(e){return Pe(r,void 0,void 0,(function(){var t;return Ne(this,(function(r){return t=Number(e.target.value),!isNaN(t)&&t>=0&&this.setState({discountValue:t},this.validateForm),[2]}))}))},r.updateDiscountDescription=function(e){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(t){return this.setState({discountDescription:e.target.value}),[2]}))}))},r.quantityChangeHandler=function(e){return Pe(r,void 0,void 0,(function(){var t;return Ne(this,(function(r){return t=Number(e.target.value),isNaN(t)||this.setState({quantity:t},this.validateForm),[2]}))}))},r.quantityBluredHandler=function(){return Pe(r,void 0,void 0,(function(){var e,t,r;return Ne(this,(function(n){switch(n.label){case 0:return[4,this.validateForm()];case 1:if(!n.sent())return[2];e=this.state.editMode?this.props.lineItem.Code:this.state.entrySelectedSuggestion.Code,n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.getPlacedPrice(e,this.state.quantity)];case 3:return(t=n.sent())&&t.Amount!==this.state.defaultPlacedPrice&&this.setState({defaultPlacedPrice:t.Amount,placedPrice:t.Amount},this.validateForm),[3,5];case 4:return r=n.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(r.message)),[3,5];case 5:return[2]}}))}))},r.getPlacedPrice=function(e,t){return Pe(r,void 0,void 0,(function(){var r;return Ne(this,(function(n){switch(n.label){case 0:if(!e)return[2,null];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,Zt.OrderGroup.getPlacedPrice(e,t,this.props.orderGroup.MarketId,this.props.orderGroup.Currency,this.props.orderGroup.Customer.Id)];case 2:return[2,n.sent().data];case 3:return r=n.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(r.message)),404===r.response.status&&this.setState({isReadonly:!0}),[2,null];case 4:return[2]}}))}))},r.customPropertyChangedHandler=function(e){return Pe(r,void 0,void 0,(function(){var t;return Ne(this,(function(r){return(t=this.state.properties.findIndex((function(t){return t.Name===e.Name})))>=0&&(this.state.properties[t]=Ge({},e),this.setState({properties:Re(this.state.properties)}),this.forceUpdate()),[2]}))}))},void 0!==r.props.lineItem.LineItemId){if(r.state.editMode=!0,r.state.quantity=r.props.lineItem.Quantity,r.state.placedPrice=r.props.lineItem.PlacedPrice.Amount,r.state.shipmentId=r.props.orderForm.Shipments[r.props.lineItem.ShipmentNo-1].ShipmentId,r.props.lineItem.ManualDiscount){var n=r.props.lineItem.ManualDiscount;r.state.discountType=n.ManualDiscountType,r.state.discountValue=n.DiscountValue,r.state.discountDescription=n.Description}r.state.properties=Re(r.props.lineItem.Properties),r.state.originalLineItem=JSON.parse(JSON.stringify(r.props.lineItem))}else r.state.shipmentId=r.props.orderForm.Shipments[0].ShipmentId;return r}return Te(r,e),r.prototype.componentDidMount=function(){var e=this;this.props.lineItem.Code&&this.props.lineItem.IsEntryAvailable?this.getPlacedPrice(this.props.lineItem.Code,this.state.quantity).then((function(t){t?e.setState({defaultPlacedPrice:t.Amount,showDialog:!0}):e.setState({showDialog:!0})})):this.setState({showDialog:!0}),this.initData()},r.prototype.addLineItemToOrderGroup=function(){return Pe(this,void 0,void 0,(function(){var e,t,r,n,s,a;return Ne(this,(function(i){switch(i.label){case 0:e=this.createLineItemPostData(this.state.entrySelectedSuggestion,this.state.quantity,this.state.placedPrice),i.label=1;case 1:return i.trys.push([1,8,,9]),this.props.orderGroup.IsDraft?[4,Zt.OrderGroup.initLineItem(this.props.orderGroup.Currency,this.props.orderGroup.MarketId,this.props.orderGroup.Customer.Id,e)]:[3,4];case 2:return t=i.sent(),r=JSON.parse(JSON.stringify(this.props.orderGroup)),t.forEach((function(e){var t=r.Forms[0].Shipments[0].LineItems.find((function(t){return t.Code===e.Code}));t?t.Quantity+=e.Quantity:r.Forms[0].Shipments[0].LineItems.push(e)})),[4,Zt.OrderGroup.calculateOrder(r)];case 3:return(r=i.sent()).ValidationMessages.length>0&&this.props.dispatch(rt.ApplicationActions.showNotification(r.ValidationMessages.join("\n"))),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(r)),[3,7];case 4:return[4,Zt.OrderGroup.addLineItemToOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId,this.props.orderForm.OrderFormId,this.state.shipmentId,e)];case 5:return n=i.sent(),this.isValidationMessagesReturned(n)&&this.props.dispatch(rt.ApplicationActions.showNotification(n.data.join("\n"))),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 6:s=i.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(s)),i.label=7;case 7:return[3,9];case 8:return a=i.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(a.message)),[2,!1];case 9:return[2,!0]}}))}))},r.prototype.getExistedLineItem=function(e){var t,r=this,n=this.props.orderForm.Shipments.find((function(e){return e.ShipmentId===r.state.shipmentId}));return n&&(t=n.LineItems.find((function(t){return!t.IsGift&&t.Code===e}))),t},r.prototype.isValidationMessagesReturned=function(e){return e&&e.data&&Array.isArray(e.data)&&e.data.length>0},r.prototype.createLineItemPostData=function(e,t,r){return{code:e.Code,displayName:e.DisplayName,quantity:t,placedPrice:r}},r.prototype.validateForm=function(){return Pe(this,void 0,void 0,(function(){var e,t,r;return Ne(this,(function(n){switch(n.label){case 0:e=!0,t={},n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.validationSchema.validate({Quantity:this.state.quantity,PlacedPrice:this.state.placedPrice,DiscountValue:this.state.discountValue,DiscountType:this.state.discountType,ShipmentId:this.state.shipmentId,EditMode:this.state.editMode,LineItemCode:this.state.entrySelectedSuggestion.Code},{strict:!0,abortEarly:!1})];case 2:return n.sent(),[3,4];case 3:return r=n.sent(),e=!1,r.inner.map((function(e){t[e.path]=e.message})),[3,4];case 4:return this.setState({errors:t}),[2,e]}}))}))},r.prototype.updateLineItemProperties=function(){return Pe(this,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:if(this.props.orderGroup.IsDraft)return this.setState({lineItem:Ge(Ge({},this.state.lineItem),{Properties:this.state.properties})}),[2];e=0,r.label=1;case 1:if(!(e0?r[0].shipmentId:-1;e=this.state.editMode?t:r,this.setState({shipmentOptions:e}),this.state.editMode||n===this.state.shipmentId||this.setState({shipmentId:n})},r.prototype.render=function(){var e=this,r={title:this.state.isReadonly?"Line Item Details":this.state.editMode?"Edit Line Item":"Add Line Item",open:!0,onClose:function(){e.props.onClose()},closeLabel:this.state.isReadonly?"Close":"Cancel"};return this.state.isReadonly||(r.okLabel=this.state.editMode?"Save":"Add Line Item",r.onOK=function(){return Pe(e,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.submitForm()];case 1:return e.sent(),[2]}}))}))}),t.createElement(ar,Ge({},r),this.state.showDialog&&t.createElement(T.ValidatorForm,{instantValidate:!0,onSubmit:function(){return null},ref:function(t){return e.customPropertiesForm=t}},t.createElement(s.Grid,{container:!0,spacing:16,style:{marginTop:"5px"}},t.createElement(s.Grid,{item:!0,xs:12},this.state.editMode?t.createElement(s.TextField,{label:"Product variant",name:"productName",variant:"outlined",value:this.props.lineItem.DisplayName,fullWidth:!0,disabled:!0}):t.createElement(js,{onSelected:function(t){e.handleEntrySearchSelected(t)},onSearchFieldChanged:function(t){e.handleEntrySearchChanged(t)}}),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.LineItemCode)),this.props.orderForm.Shipments.length>1&&t.createElement(s.Grid,{item:!0,xs:12},t.createElement(_t,{label:"Shipment",fullWidth:!0,value:this.state.shipmentId,options:this.state.shipmentOptions,disabled:this.state.editMode,required:!0,onChange:function(t){e.setState({shipmentId:t})}}),t.createElement(s.Typography,{variant:"caption",color:"error"},this.state.errors.ShipmentId)),t.createElement(s.Grid,{item:!0,xs:12},t.createElement(s.TextField,{label:"Quantity",name:"Quantity",type:"number",variant:"outlined",value:this.state.quantity,onChange:this.quantityChangeHandler,onBlur:this.quantityBluredHandler,fullWidth:!0,error:!!this.state.errors.Quantity,helperText:this.state.errors.Quantity,required:!0,disabled:this.state.isReadonly,inputProps:{step:.1,min:0}})),this.state.editMode&&t.createElement(t.Fragment,null,t.createElement(s.Grid,{item:!0,xs:6},t.createElement(s.TextField,{label:"Discount",name:"DiscountValue",type:"number",variant:"outlined",value:this.state.discountValue,onChange:this.updateDiscountPrice,fullWidth:!0,disabled:this.state.isReadonly||"Cart"===this.props.orderGroup.Type,inputProps:{min:0},error:!!this.state.errors.DiscountValue,helperText:this.state.errors.DiscountValue})),t.createElement(s.Grid,{item:!0,xs:6},t.createElement(_t,{label:"Discount Type",value:this.state.discountType.toString(),options:[{label:"Percentage",value:"1"},{label:"Value",value:"2"}],onChange:function(t){e.setState({discountType:Number(t)},(function(){e.validateForm()}))},fullWidth:!0,disabled:this.state.isReadonly||"Cart"===this.props.orderGroup.Type})),t.createElement(s.Grid,{item:!0,xs:12},t.createElement(s.TextField,{label:"Discount Description",variant:"outlined",value:this.state.discountDescription,onChange:this.updateDiscountDescription,fullWidth:!0,disabled:this.state.isReadonly||"Cart"===this.props.orderGroup.Type}))),t.createElement(s.Grid,{item:!0,xs:12},t.createElement(s.TextField,{label:"Placed Price"+(this.props.orderGroup.Currency?"("+this.props.orderGroup.Currency+")":""),type:"number",name:"PlacedPrice",fullWidth:!0,variant:"outlined",value:this.state.placedPrice,onChange:this.updatePlacedPrice,error:!!this.state.errors.PlacedPrice,helperText:this.state.errors.PlacedPrice,inputProps:{min:0,step:.1},InputLabelProps:{shrink:!0},required:!0,disabled:this.state.isReadonly||"Cart"===this.props.orderGroup.Type||this.state.isBundle}),this.state.defaultPlacedPrice>=0&&this.state.defaultPlacedPrice!==this.state.placedPrice&&t.createElement(s.Typography,{variant:"caption",component:"h6"},"Default PlacedPrice is ",t.createElement("b",null,this.state.defaultPlacedPrice))),this.props.lineItem.Properties&&this.props.lineItem.Properties.map((function(r,n){return t.createElement(s.Grid,{item:!0,xs:12,key:n},t.createElement(Rn,{key:n,property:r,isReadonly:e.state.isReadonly||!r.IsEditable,onPropertyChanged:e.customPropertyChangedHandler}))})))))},r}(t.Component),Qs=n.connect((function(e,t){var r=e.orderGroup.currentOrderGroup,n=r.Forms[e.orderGroup.selectedFormIndex];return Ge({orderGroup:r,orderForm:n},t)}))(zs),Ks=function(){},Xs=function(e){function r(t){var r=e.call(this,t)||this;return r.handleReturnCommentChange=function(e){r.setState({returnComment:e.target.value})},r.state={isLoadingResource:!1,returnReasons:Array(),returnLineItems:Array(),returnComment:""},r}return Te(r,e),r.prototype.componentWillMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return this.initReturnLineItem(),[4,this.getData()];case 1:return e.sent(),[2]}}))}))},r.prototype.initReturnLineItem=function(){var e=this.props.lineItems.map((function(e){return Ge(Ge({},e),{OriginalLineItemId:e.LineItemId,ReturnQuantity:e.ReturnableQuantity,ReturnReason:""})}));this.setState({returnLineItems:e})},r.prototype.getData=function(){return Pe(this,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return this.setState({isLoadingResource:!0}),[4,Zt.OrderGroup.getReturnReasons()];case 1:return e=r.sent(),t=e.map((function(e){return{label:e.Label,value:e.Label}})),this.setState({returnReasons:t,isLoadingResource:!1}),[2]}}))}))},r.prototype.onCloseDialog=function(){this.props.closeView()},r.prototype.onCreateReturn=function(){return Pe(this,void 0,void 0,(function(){var e,t,r;return Ne(this,(function(n){switch(n.label){case 0:if(!this.validate())return this.props.dispatch(rt.ApplicationActions.showNotification("Please input valid return information!")),[2];(e=new Ks).LineItems=this.state.returnLineItems,e.ReturnComment=this.state.returnComment,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,Zt.OrderGroup.createReturn(this.props.orderGroupId,e)];case 2:return(t=n.sent()).ReturnFormId&&zr.push(vt+"/"+this.props.orderGroupId+"/returns/"+t.ReturnFormId),this.props.closeView(),[3,4];case 3:return r=n.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(r.message)),[3,4];case 4:return[2]}}))}))},r.prototype.validate=function(){return!!this.state.returnLineItems.every((function(e){return e.ReturnQuantity>0&&""!==e.ReturnReason}))},r.prototype.render=function(){var e=this;return t.createElement(ar,{title:"Create Return",open:!0,large:!0,onClose:function(){e.props.closeView()},onOK:function(){return Pe(e,void 0,void 0,(function(){return Ne(this,(function(e){return this.onCreateReturn(),[2]}))}))},okLabel:"Create",closeLabel:"Cancel"},t.createElement(d,{container:!0,spacing:16,direction:"column"},!this.state.isLoadingResource&&this.state.returnLineItems.map((function(r,n){return t.createElement(d,{item:!0,key:n},t.createElement(d,{container:!0,direction:"row",key:n,spacing:8},t.createElement(d,{item:!0,xs:7},t.createElement(d,{container:!0,direction:"row"},t.createElement(d,{item:!0,xs:2},t.createElement(_s,Ge({},r))),t.createElement(d,{item:!0,xs:10},t.createElement(s.Typography,{variant:"body1",color:"inherit"},r.DisplayName),t.createElement(d,{container:!0,direction:"row"},t.createElement(d,{item:!0,xs:6},t.createElement(s.Typography,{variant:"body2",color:"inherit",align:"left"},r.Code)),t.createElement(d,{item:!0,xs:6},t.createElement(s.Typography,{variant:"body2",color:"inherit",align:"right"},"Shipment No: ",r.ShipmentNo)))))),t.createElement(d,{item:!0,xs:2},t.createElement(be,{outlined:!0,style:{width:"100%"},label:"Return Quantity"},t.createElement(Ie.Input,{type:"number",step:"0.01",max:r.ReturnableQuantity,min:0,value:r.ReturnQuantity.toString(),onChange:function(t){r.ReturnQuantity=Number.parseFloat(t.currentTarget.value),e.setState({returnLineItems:e.state.returnLineItems})}}))),t.createElement(d,{item:!0,xs:3},t.createElement(_t,{label:"Return Reason",fullWidth:!0,value:r.ReturnReason,options:e.state.returnReasons,required:!0,onChange:function(t){r.ReturnReason=t,e.setState({returnLineItems:e.state.returnLineItems})}}))))}))),t.createElement(d,{container:!0,direction:"column",spacing:8},t.createElement(d,{item:!0},t.createElement(s.Typography,null,"Comment")),t.createElement(d,{item:!0},t.createElement(be,{textarea:!0,label:"Comment",size:5,fullWidth:!0},t.createElement(Ie.Input,{style:{height:"100px"},maxLength:1024,value:this.state.returnComment,onChange:this.handleReturnCommentChange})))))},r}(t.Component),Js=s.withStyles((function(e){e.spacing;return s.createStyles({})}))(n.connect((function(e,t){return Ge({},t)}))(Xs)),Zs={productRemoved:{textDecorationLine:"line-through"}},$s=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.state={isReturnDialogOpen:!1,selectedLineItems:[],isAddDialogOpen:!1,currentLineItem:{},contextAction:{isDeleteButtonVisible:!0,isCreateReturnButtonVisible:!1},delConfirmDialog:{isOpen:!1,onConfirm:function(){return null}}},r.tableInstance={},r.columns=[{name:"NAME",render:function(e,r){return t.createElement(s.Grid,{container:!0,direction:"row",alignItems:"center",wrap:"nowrap",spacing:8},t.createElement(s.Grid,{item:!0},t.createElement(_s,Ge({},e))),t.createElement(s.Grid,{item:!0,style:e.IsEntryAvailable?void 0:Zs.productRemoved},t.createElement(x,{variant:"body2",color:"inherit"},e.DisplayName),t.createElement(x,null,e.Code)))}},{name:"PLACED PRICE",right:!0,render:function(e,r){return t.createElement(x,null,e.PlacedPrice.Amount," ",e.PlacedPrice.Currency)}},{name:"SHIPMENT NO",selector:"ShipmentNo",right:!0},{name:"SHIPMENT STATUS",selector:"ShipmentStatus",render:function(e,t){return Mn(e.ShipmentStatus)}},{name:"TOTAL DISCOUNT",right:!0,render:function(e,r){var n,s,a;return t.createElement(x,null,null===(n=e.DiscountTotal)||void 0===n?void 0:n.Amount.toFixed(null===(s=e.DiscountTotal)||void 0===s?void 0:s.Fractions)," ",null===(a=e.DiscountTotal)||void 0===a?void 0:a.Currency)}},{name:"QUANTITY",selector:"Quantity",right:!0},{name:"TOTAL",right:!0,render:function(e,r){var n,s,a;return t.createElement(x,null,null===(n=e.DiscountedPrice)||void 0===n?void 0:n.Amount.toFixed(null===(s=e.DiscountedPrice)||void 0===s?void 0:s.Fractions)," ",null===(a=e.DiscountedPrice)||void 0===a?void 0:a.Currency)}},{width:50,render:function(e,n){var s=new Array;return r.isEditableLineItem(e)&&!e.IsGift&&e.IsEntryAvailable?(s.push({title:"Edit",clickHandler:function(t){r.setState({isAddDialogOpen:!0,currentLineItem:e})}}),s.push({title:"Delete",clickHandler:function(e){var t={isOpen:!0,onConfirm:function(){r.deleteLineItems([r.state.currentLineItem])}};r.setState({currentLineItem:e,delConfirmDialog:t})}})):s.push({title:"View",clickHandler:function(t){r.setState({isAddDialogOpen:!0,currentLineItem:e})}}),e.ReturnableQuantity>0&&s.push({title:"Create Return",clickHandler:function(e){r.openReturnDialog([e])}}),0===s.length?null:t.createElement(is,{actions:s,rowData:e,rowIndex:n})}}],r.deleteLineItems=function(e){return Pe(r,void 0,void 0,(function(){var t,r,n,s,a,i;return Ne(this,(function(o){switch(o.label){case 0:return this.setState({delConfirmDialog:{isOpen:!1}}),this.props.orderGroup.IsDraft?(t=JSON.parse(JSON.stringify(this.props.orderGroup)),r=e.map((function(e){return e.Code})),t.Forms[0].Shipments[0].LineItems=t.Forms[0].Shipments[0].LineItems.filter((function(e){return-1===r.indexOf(e.Code)})),[4,Zt.OrderGroup.calculateOrder(t)]):[3,2];case 1:return t=o.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(t)),[3,11];case 2:n=0,o.label=3;case 3:if(!(n '+s.message)),[3,8];case 7:return n++,[3,3];case 8:return o.trys.push([8,10,,11]),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 9:return a=o.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(a)),[3,11];case 10:return i=o.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(i.message)),[3,11];case 11:return[2]}}))}))},r.openReturnDialog=function(e){r.setState({isReturnDialogOpen:!0,selectedLineItems:e})},r.handleOnRowSelected=function(e,t){return Pe(r,void 0,void 0,(function(){var e,t,r,n,s;return Ne(this,(function(a){for(e=!0,t=!0,r=this.tableInstance.getSelectedRows(),n=0;n0&&t.buttons&&t.buttons.push({title:"Add Line Items",clickHandler:function(e){r.setState({isAddDialogOpen:!0,currentLineItem:{}})}});e.toolbar=t;var n=new Array;return!r.props.isReadonly&&r.state.contextAction.isDeleteButtonVisible&&n.push({title:"Delete",clickHandler:function(e){var t={isOpen:!0,onConfirm:function(){var e=r.tableInstance.getSelectedRows();r.deleteLineItems(e),r.tableInstance.setHeaderRowChecked(!1)}};r.setState({delConfirmDialog:t})}}),r.state.contextAction.isCreateReturnButtonVisible&&n.push({title:"Create Return",clickHandler:function(e){var t=r.tableInstance.getSelectedRows();r.openReturnDialog(t),r.tableInstance.setHeaderRowChecked(!1)}}),n.length>0&&(e.contextActions=n),e},r}return Te(r,e),r.prototype.componentDidMount=function(){var e=this.props.lineItems.filter((function(e){return!e.IsEntryAvailable})).map((function(e){return e.Code}));if(e.length>0){var t="You can not edit line items "+e.join(", ")+" because their entries have been removed or their code have been changed.";this.props.dispatch(rt.ApplicationActions.showNotification(t))}},r.prototype.isEditableLineItem=function(e){return!e.Code||!!e.IsEntryAvailable&&(!e.IsGift&&this.isShipmentEditable(e.ShipmentStatus))},r.prototype.render=function(){var e=this,r=this.buildTableProps();return t.createElement("div",null,t.createElement(x,{variant:"h6",gutterBottom:!0},"Line Items"),t.createElement(wn,Ge({},r)),this.state.isAddDialogOpen&&t.createElement(Qs,{onClose:function(){return e.setState({isAddDialogOpen:!1})},lineItem:this.state.currentLineItem,isReadonly:!this.isEditableLineItem(this.state.currentLineItem)}),this.state.delConfirmDialog.isOpen&&t.createElement(ir,{title:"Delete Line Item",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:this.state.delConfirmDialog.onConfirm,onClose:function(){e.setState({delConfirmDialog:{isOpen:!1}})}},t.createElement(x,{variant:"body1"},"Are you sure you want to delete?")),this.state.isReturnDialogOpen&&t.createElement(Js,{lineItems:this.state.selectedLineItems,orderGroupId:this.props.orderGroup.OrderGroupId,closeView:function(){return e.setState({isReturnDialogOpen:!1})}}))},r}(t.Component);function ea(e){if(!e.Shipments||0===e.Shipments.length)return[];for(var t=new Array,r=function(r){var n=e.Shipments[r];n.LineItems.forEach((function(e){e.ShipmentNo=r+1,e.ShipmentStatus=n.OrderShipmentStatus.Name,t.push(e)}))},n=0;n0)&&t.createElement(d,{item:!0},t.createElement(Ds,{payments:this.props.orderForm.Payments})))},r}(t.Component),na=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({})}))(n.connect((function(e,t){var r=e.orderGroup.currentOrderGroup;return{orderGroupId:r.OrderGroupId,orderForm:t.orderForm,orderGroupType:r.Type,classes:t.classes,isReadonly:$n(r),isCreateNewOrder:r.IsDraft}}))(ra)),sa=function(e){function r(t){var r=e.call(this,t)||this;r.state={selectedOrderTabIndex:0,showCancelPaymentPlanConfirm:!1},r.orderTabNames=new Array,r.closeOrderGroupView=function(){r.props.dispatch(rt.ApplicationActions.closeOrderGroupView()),r.props.dispatch(rt.ContactActions.setCurrentContact(null)),r.props.dispatch(rt.ContactActions.setCurrentAddress(null)),r.props.dispatch(rt.PaymentActions.hideAcceptPaymentForm()),r.props.dispatch(rt.PaymentActions.setPaymentMethodId("")),r.props.dispatch(rt.PaymentActions.setPayment(null)),r.props.dispatch(rt.PaymentActions.setBillingAddress(null)),r.props.dispatch(rt.PaymentActions.setBillingAddressDropdownIsExpanded(!1)),r.props.dispatch(rt.OrderGroupActions.setPaymentPlanSetting({}))},r.orderTabIndexChangedHandler=function(e){return Pe(r,void 0,void 0,(function(){var t;return Ne(this,(function(r){return this.setState({selectedOrderTabIndex:e}),(t=new URLSearchParams(zr.location.search)).set("tab",this.orderTabNames[e].key),zr.replace(zr.location.pathname+"?"+t.toString()),[2]}))}))},r.customPropertyChangedHandler=function(e){return Pe(r,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,Zt.MetaField.updateOrderGroupMetaFields(this.props.orderGroup.OrderGroupId,this.props.orderGroup.Type,e)];case 1:return n.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroup.Type,this.props.orderGroup.OrderGroupId)];case 2:return t=n.sent(),this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(t)),[3,4];case 3:return r=n.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(r.message)),[3,4];case 4:return[2]}}))}))},r.convertCartToOrderHandler=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),es(this.props.orderGroup)?[4,Zt.Cart.convertToPurchaseOrder(this.props.orderGroup.OrderGroupId)]:[3,2];case 1:return e=r.sent(),zr.replace(vt+"/"+e.OrderGroupId),Qr(It,pt+"?type=Order"),[3,3];case 2:this.props.dispatch(rt.ApplicationActions.showNotification("Cannot convert an empty cart to purchase order.")),r.label=3;case 3:return[3,5];case 4:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},r.convertCartToPaymentPlanHandler=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),es(this.props.orderGroup)?[4,Zt.Cart.convertToPaymentPlan(this.props.orderGroup.OrderGroupId)]:[3,2];case 1:return e=r.sent(),zr.replace(St+"/"+e.OrderGroupId),Qr(At,pt+"?type=PaymentPlan"),[3,3];case 2:this.props.dispatch(rt.ApplicationActions.showNotification("Cannot convert an empty cart to payment plan.")),r.label=3;case 3:return[3,5];case 4:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},r.convertPaymentPlanToOrderHandler=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),es(this.props.orderGroup)?[4,Zt.PaymentPlan.convertToPurchaseOrder(this.props.orderGroup.OrderGroupId)]:[3,2];case 1:return e=r.sent(),zr.replace(vt+"/"+e.OrderGroupId),Qr(It,St+"/"+this.props.orderGroup.OrderGroupId),[3,3];case 2:this.props.dispatch(rt.ApplicationActions.showNotification("Cannot convert an empty payment plan to purchase order.")),r.label=3;case 3:return[3,5];case 4:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},r.cancelPaymentPlanHandler=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:this.setState({showCancelPaymentPlanConfirm:!1}),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,Zt.PaymentPlan.cancelPaymentPlan(this.props.orderGroup.OrderGroupId)];case 2:return r.sent(),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroupType,this.props.orderGroupId)];case 3:return e=r.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(e)),[3,5];case 4:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},r.loadPaymentMethods=function(){return Pe(r,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return[4,Zt.PaymentMethod.getPaymentMethods(this.props.orderGroup.MarketId)];case 1:return e=t.sent(),this.props.dispatch(rt.PaymentActions.setPaymentMethods(e)),[2]}}))}))},r.loadCurrencies=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Zt.Currency.getCurrencies(this.props.orderGroup.MarketId)];case 1:return e=r.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrencies(e)),[3,3];case 2:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.initOrderTabs(t);var n=new URLSearchParams(zr.location.search).get("tab");if(n){var s=r.orderTabNames.findIndex((function(e){return e.key===n}));s>0&&(r.state.selectedOrderTabIndex=s)}return r}return Te(r,e),r.prototype.componentDidUpdate=function(){this.initOrderTabs(this.props)},r.prototype.initOrderTabs=function(e){var t=this;this.orderTabNames=[],this.orderTabNames.push({key:"summary",name:"Summary"}),this.orderTabNames.push({key:"details",name:"Form Details "}),"Order"===e.orderGroupType&&this.orderTabNames.push({key:"return",name:"Return & Exchange"}),this.orderTabNames.push({key:"contact",name:"Contact Details"}),"PaymentPlan"===e.orderGroupType&&(this.orderTabNames.push({key:"plansettings",name:"Settings"}),this.orderTabNames.push({key:"orders",name:"Orders"})),"Order"===e.orderGroupType&&this.props.orderDetailExtraTabs&&this.props.orderDetailExtraTabs.map((function(e,r){t.orderTabNames.push({key:"extraTab_"+r,name:e.title})})),"Cart"===e.orderGroupType&&this.props.cartDetailExtraTabs&&this.props.cartDetailExtraTabs.map((function(e,r){t.orderTabNames.push({key:"extraTab_"+r,name:e.title})})),"PaymentPlan"===e.orderGroupType&&this.props.paymentPlanExtraTabs&&this.props.paymentPlanExtraTabs.map((function(e,r){t.orderTabNames.push({key:"extraTab_"+r,name:e.title})}))},r.prototype.componentWillMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.getData()];case 1:return e.sent(),[2]}}))}))},r.prototype.shouldComponentUpdate=function(e,t){var r=this;return e.orderGroupId!==this.props.orderGroupId&&(zr.push(Zt.OrderGroup.getOrderGroupRouting(e.orderGroupType)+"/"+e.orderGroupId),setTimeout((function(){r.getData()}),200)),!0},r.prototype.getData=function(){return Pe(this,void 0,void 0,(function(){var e,t,r,n;return Ne(this,(function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),[4,Zt.OrderGroup.getSingleOrderGroup(this.props.orderGroupType,this.props.orderGroupId)];case 1:return e=s.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(e)),e.ValidationMessages.length>0&&this.props.dispatch(rt.ApplicationActions.showNotification(e.ValidationMessages.join(", "))),e.Customer.IsAnonymous?[3,3]:[4,Zt.Contact.get(e.Customer.Id)];case 2:t=s.sent(),this.props.dispatch(rt.ContactActions.setCurrentContact(t)),s.label=3;case 3:return this.loadCurrencies(),[4,Zt.Shipment.getShippingMethods()];case 4:return r=s.sent(),this.props.dispatch(rt.ShipmentActions.setShippingMethods(r)),"Cart"!==this.props.orderGroup.Type&&this.loadPaymentMethods(),[3,6];case 5:return n=s.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(n.message)),404===n.response.status&&zr.replace("/?type="+this.props.orderGroupType),[3,6];case 6:return[2]}}))}))},r.prototype.closeView=function(){var e=new URLSearchParams(zr.location.search).get("returnUrl"),t=void 0;if(e)return zr.push(e),void this.closeOrderGroupView();switch(this.props.orderGroupType){case"Order":t=Kr(It);break;case"PaymentPlan":t=Kr(At);break;default:t=Kr(bt)}void 0!==t?zr.push(t):zr.push("/"),this.closeOrderGroupView()},r.prototype.render=function(){var e,r,n=this,a=this.orderTabNames[this.state.selectedOrderTabIndex].key,i=function(){return t.createElement(t.Fragment,null)},o=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,c=null===(r=this.props.extendUI)||void 0===r?void 0:r.bottomPlaceHolder;if(a.startsWith("extraTab_")){var l=parseInt(a.substring(a.lastIndexOf("_")+1,a.length),10);"Order"===this.props.orderGroupType&&this.props.orderDetailExtraTabs&&(i=this.props.orderDetailExtraTabs[l].render),"Cart"===this.props.orderGroupType&&this.props.cartDetailExtraTabs&&(i=this.props.cartDetailExtraTabs[l].render),"PaymentPlan"===this.props.orderGroupType&&this.props.paymentPlanExtraTabs&&(i=this.props.paymentPlanExtraTabs[l].render)}return this.props.orderGroup&&t.createElement("div",null,t.createElement(Zn,null),t.createElement(fr,{closeView:function(){return n.closeView()},title:("PaymentPlan"===this.props.orderGroupType?"Payment Plan":this.props.orderGroupType)+" Details",showDialogActions:!0},o&&t.createElement(o,{Id:this.props.orderGroupId,className:"top-placeholder"}),t.createElement(d,{container:!0,direction:"column",spacing:8},t.createElement(d,{item:!0},"Order"===this.props.orderGroup.Type&&t.createElement(ss,null),"Cart"===this.props.orderGroup.Type&&t.createElement(d,{container:!0,justify:"flex-end",spacing:8},t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:this.convertCartToOrderHandler,id:"convertToPurchaseOrder"},"Convert to purchase order")),t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:this.convertCartToPaymentPlanHandler,id:"convertToPaymentPlan"},"Convert to payment plan"))),"PaymentPlan"===this.props.orderGroup.Type&&t.createElement(d,{container:!0,justify:"flex-end",spacing:8},this.props.orderGroup.CanConvertPaymentPlanToPurchaseOrder&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:this.convertPaymentPlanToOrderHandler,id:"convertPaymenPlanToPurchaseOrder"},"Create First Purchase Order")),this.props.orderGroup.OrderStatus===zn.InProgress&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return n.setState({showCancelPaymentPlanConfirm:!0})},id:"cancelPaymentPlan"},"Cancel Payment Plan")))),t.createElement(d,null,t.createElement(U,{position:"static",color:"default"},t.createElement(f.TabBar,{activeIndex:this.state.selectedOrderTabIndex,handleActiveIndexUpdate:this.orderTabIndexChangedHandler},this.orderTabNames.map((function(e){return t.createElement(f.Tab,{key:e.key},e.name)})))),t.createElement(s.Card,null,t.createElement(s.CardContent,null,t.createElement(d,null,"summary"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&("Cart"===this.props.orderGroupType?t.createElement(Wn,{orderGroup:this.props.orderGroup}):t.createElement(Hn,{orderGroup:this.props.orderGroup,isReadonly:this.props.isReadonly})),"details"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(d,null,t.createElement(na,{orderForm:this.props.orderGroup.Forms[0]})),"return"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&"Order"===this.props.orderGroup.Type&&t.createElement(d,null,t.createElement(us,{orderGroupId:this.props.orderGroupId})),"contact"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(d,null,t.createElement(jn,{orderGroup:this.props.orderGroup})),"plansettings"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&"PaymentPlan"===this.props.orderGroup.Type&&t.createElement(d,null,t.createElement(Jn,{editMode:!1,paymentPlan:this.props.orderGroup})),"orders"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&"PaymentPlan"===this.props.orderGroup.Type&&t.createElement(d,null,t.createElement(ds,{paymentPlan:this.props.orderGroup})),i&&t.createElement(i,{Id:this.props.orderGroupId,className:"extra-tab-content"})))))),c&&t.createElement(c,{Id:this.props.orderGroupId,className:"bottom-placeholder"}),this.state.showCancelPaymentPlanConfirm&&t.createElement(ir,{title:"Cancel Payment Plan",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:this.cancelPaymentPlanHandler,onClose:function(){n.setState({showCancelPaymentPlanConfirm:!1})}},t.createElement(s.Typography,{variant:"body1"},"Are you sure you want to cancel this payment plan?"))))},r}(t.Component),aa=function(e,t){var r,n,s,a;switch(e){case"Order":a=null===(r=t.setting.pageConfig.orderDetail)||void 0===r?void 0:r.extendUI;break;case"Cart":a=null===(n=t.setting.pageConfig.cartDetail)||void 0===n?void 0:n.extendUI;break;case"PaymentPlan":a=null===(s=t.setting.pageConfig.paymentPlanDetail)||void 0===s?void 0:s.extendUI}return a},ia=o.withStyles((function(){return s.createStyles({})}))(n.connect((function(e,t){var r,n,s,a,i,o,c,l,u,d;return{orderGroupType:t.orderGroupType,orderGroupId:t.orderGroupId,orderGroup:e.orderGroup.currentOrderGroup,rowsPerPage:e.application.rowsPerPage,orderStatuses:e.orderGroup.orderStatuses,currencies:e.orderGroup.currencies,isReadonly:$n(e.orderGroup.currentOrderGroup),selectedEntry:e.orderGroup.selectedEntry,hasReadonlyOrderStatus:(d=e.orderGroup.currentOrderGroup,!!d&&("Cart"===d.Type||d.OrderStatus===zn.Cancelled||d.OrderStatus===zn.Completed)),classes:t.classes,orderDetailExtraTabs:null===(s=null===(n=null===(r=e.setting.pageConfig)||void 0===r?void 0:r.orderDetail)||void 0===n?void 0:n.config)||void 0===s?void 0:s.extraTabs,cartDetailExtraTabs:null===(o=null===(i=null===(a=e.setting.pageConfig)||void 0===a?void 0:a.cartDetail)||void 0===i?void 0:i.config)||void 0===o?void 0:o.extraTabs,paymentPlanExtraTabs:null===(u=null===(l=null===(c=e.setting.pageConfig)||void 0===c?void 0:c.paymentPlanDetail)||void 0===l?void 0:l.config)||void 0===u?void 0:u.extraTabs,extendUI:aa(t.orderGroupType,e)}}))(sa)),oa=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Te(r,e),r.prototype.render=function(){return t.createElement(ia,Ge({},this.props))},r}(t.Component),ca=function(e){return t.createElement(d,{container:!0,justify:"flex-end",direction:"row",alignItems:"center",spacing:8},t.createElement(d,{item:!0},t.createElement(x,{style:{fontWeight:"normal"},variant:e.variant},e.label)),t.createElement(d,{item:!0},t.createElement(En,{amount:e.amount,align:"right",variant:e.variant,style:{fontWeight:"bold",paddingRight:16}})))},la=function(e){function r(t){var r=e.call(this,t)||this;return r.state={loaded:!1,errorMessage:"",refundAmountMessage:"",paymentMethodOptions:[],currentPayment:{},returnOrderSummary:{ItemTotal:0,InvalidatedDiscountsTotal:0,ExchangeTotal:0,RefundAmount:0,ExistingPayments:[]},refundAmount:0,maxRefundAmount:0},r.refundForm={},r.existPaymentHandleChange=function(e){var t=r.state.returnOrderSummary.ExistingPayments[e];r.setState({currentPayment:t,refundAmount:Math.min(r.state.maxRefundAmount,t.Amount.Amount)})},r.refundAmountHandlerChange=function(e,t){r.setState({refundAmount:Number(t)})},r.completeReturn=function(){return Pe(r,void 0,void 0,(function(){var e,t,r=this;return Ne(this,(function(n){switch(n.label){case 0:if(""!==this.validateRefundForm())return[2];e=this.state.currentPayment,n.label=1;case 1:return n.trys.push([1,5,,6]),this.state.refundAmount>0?[4,Zt.OrderGroup.createRefund(this.props.orderGroupId,this.props.orderGroup.Forms[0].OrderFormId,{existingPaymentId:e.PaymentId,amount:this.state.refundAmount})]:[3,3];case 2:n.sent(),n.label=3;case 3:return[4,Zt.OrderGroup.completeReturn(this.props.orderGroupId,this.props.returnFormId).catch((function(e){r.setState({errorMessage:e.message})}))];case 4:return n.sent(),this.props.onClose(),zr.go(0),[3,6];case 5:return t=n.sent(),this.setState({errorMessage:t.message}),[3,6];case 6:return[2]}}))}))},r.state.paymentMethodOptions=r.props.paymentMethods.map((function(e){return{label:e.Name,value:e.PaymentMethodId}})),r}return Te(r,e),r.prototype.componentDidMount=function(){return Pe(this,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return[4,Zt.OrderGroup.getRefundInfo(this.props.orderGroupId,this.props.returnFormId)];case 1:return(e=t.sent())&&this.setState({returnOrderSummary:Ge({},e.data),maxRefundAmount:e.data.RefundAmount,loaded:!0}),this.state.returnOrderSummary.ExistingPayments.length>0&&this.existPaymentHandleChange(0),[2]}}))}))},r.prototype.validateRefundForm=function(){var e="",t=this.state.currentPayment;return this.state.currentPayment?this.state.refundAmount>t.Amount.Amount&&(e="Total Refund Amount cannot exceed "+t.Amount.Amount):e="Please select Existing Payments!",this.setState({errorMessage:e}),e},r.prototype.render=function(){var e=this;return t.createElement(ar,{open:!0,title:"Create Refund",okLabel:"OK",onOK:this.completeReturn,closeLabel:"Cancel",onClose:function(){e.props.onClose()}},this.state.loaded&&t.createElement(T.ValidatorForm,{instantValidate:!0,onSubmit:function(){return null},ref:function(t){return e.refundForm=t}},t.createElement(s.Grid,{container:!0,direction:"column",spacing:16},t.createElement(s.Grid,{item:!0},t.createElement("span",{style:{color:"red"}},this.state.errorMessage)),t.createElement(s.Grid,{item:!0},t.createElement(s.TextField,{variant:"outlined",type:"number",label:"Return Items ("+this.props.orderGroup.Currency+")",fullWidth:!0,disabled:!0,value:this.state.returnOrderSummary.ItemTotal})),t.createElement(s.Grid,{item:!0},t.createElement(s.TextField,{variant:"outlined",type:"number",label:"Invalidated Discounts ("+this.props.orderGroup.Currency+")",fullWidth:!0,disabled:!0,value:this.state.returnOrderSummary.InvalidatedDiscountsTotal})),t.createElement(s.Grid,{item:!0},t.createElement(s.TextField,{variant:"outlined",type:"number",label:"Exchange Total ("+this.props.orderGroup.Currency+")",fullWidth:!0,disabled:!0,value:this.state.returnOrderSummary.ExchangeTotal})),t.createElement(s.Grid,{item:!0},t.createElement(s.TextField,{variant:"outlined",type:"number",label:"Refund Total ("+this.props.orderGroup.Currency+")",fullWidth:!0,disabled:!0,value:this.state.maxRefundAmount})),t.createElement(s.Grid,{item:!0},this.state.returnOrderSummary.ExistingPayments.map((function(r,n){return t.createElement(s.Grid,{container:!0,key:n},t.createElement(s.Grid,{item:!0},t.createElement(s.Grid,{container:!0,alignItems:"center",spacing:8},t.createElement(s.Grid,{item:!0},t.createElement(s.Radio,{value:r.PaymentId,onChange:function(t){return e.existPaymentHandleChange(n)},checked:r.PaymentId===e.state.currentPayment.PaymentId,style:{marginLeft:"-12px"}})),t.createElement(s.Grid,{item:!0},t.createElement(s.Typography,null,r.PaymentMethodName+" ("+r.TransactionType+") \n - "+r.Amount.Amount+" "+e.props.orderGroup.Currency)))),e.state.currentPayment.PaymentId===r.PaymentId&&t.createElement(s.Grid,{item:!0,xs:12},t.createElement(s.Grid,{container:!0,spacing:16},t.createElement(s.Grid,{item:!0,xs:6},t.createElement(s.TextField,{variant:"outlined",type:"number",label:"Amount ("+e.props.orderGroup.Currency+")",fullWidth:!0,value:e.state.refundAmount,onChange:function(t){return e.refundAmountHandlerChange(r,t.target.value)},inputProps:{min:0,max:e.state.maxRefundAmount,step:.1}})),t.createElement(s.Grid,{item:!0,xs:6},t.createElement(_t,{label:"Payment Method",options:e.state.paymentMethodOptions,fullWidth:!0,value:r.PaymentMethodId,disabled:!0})),t.createElement(s.Grid,{item:!0,xs:12,style:{marginTop:"-10px"}},e.state.refundAmount!==e.state.maxRefundAmount&&t.createElement("span",{style:{fontSize:"12px",color:"red"}},"The amount you are refunding is different from the suggested refund total")))))}))))))},r}(t.Component),ua=n.connect((function(e,t){return Ge(Ge({},t),{paymentMethods:e.payment.paymentMethods,orderGroup:e.orderGroup.currentOrderGroup})}))(la),da=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={confirmDialog:{isOpen:!1,title:"",message:"",closeButtonLabel:"",confirmButtonLabel:"",onConfirm:function(){return null}},isOpenRefundDialog:!1},t}return Te(r,e),r.prototype.cancelReturn=function(){return Pe(this,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,Zt.OrderGroup.cancelReturn(this.props.orderGroupId,this.props.returnOrderForm.OrderFormId)];case 1:return t.sent(),this.props.onUpdated(),[3,3];case 2:return e=t.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(e.message)),[3,3];case 3:return this.closeDialog(),[2]}}))}))},r.prototype.updateAcknowledgeReceiptItems=function(){return Pe(this,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,Zt.OrderGroup.acknowledgeReceiptItems(this.props.orderGroupId,this.props.returnOrderForm.OrderFormId)];case 1:return t.sent(),this.props.onUpdated(),[3,3];case 2:return e=t.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(e.message)),[3,3];case 3:return this.closeDialog(),[2]}}))}))},r.prototype.closeDialog=function(){this.setState({confirmDialog:{isOpen:!1}})},r.prototype.showCancelConfirmDialog=function(){var e=this;this.setState({confirmDialog:{isOpen:!0,title:"Cancel Return",message:"Are you sure you want to cancel this return?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return e.cancelReturn()}}})},r.prototype.showAcknowledgeReceiptItemsConfirmDialog=function(){var e=this;this.setState({confirmDialog:{isOpen:!0,title:"Acknowledge Receipt Items",message:"Are you sure you want to acknowledge receipt items?",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:function(){return e.updateAcknowledgeReceiptItems()}}})},r.prototype.canShowCancelButton=function(){return this.props&&this.props.returnOrderForm&&(this.props.returnOrderForm.Status.Code===cs.AwaitingStockReturn||this.props.returnOrderForm.Status.Code===cs.AwaitingCompletion)},r.prototype.canShowAcknowledgeButton=function(){return this.props&&this.props.returnOrderForm&&this.props.returnOrderForm.Status.Code===cs.AwaitingStockReturn},r.prototype.canShowCompleteButton=function(){return this.props&&this.props.returnOrderForm&&this.props.returnOrderForm.Status.Code===cs.AwaitingCompletion},r.prototype.canShowViewExchangeButton=function(){return this.props&&this.props.returnOrderForm&&this.props.returnOrderForm.ExchangeOrderId>0},r.prototype.canShowCreateExchangeButton=function(){return this.canShowCancelButton()&&this.props.returnOrderForm.ExchangeOrderId<=0},r.prototype.showCreateRefundDialog=function(){this.setState({isOpenRefundDialog:!0})},r.prototype.createExchangeOrder=function(){return Pe(this,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return[4,Zt.OrderGroup.initExchangeOrder(this.props.orderGroupId)];case 1:return e=t.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(e)),Qr("previous_order_create"),zr.push(Tt+"?returnFormId="+this.props.returnOrderForm.OrderFormId),[2]}}))}))},r.prototype.viewExchangeOrder=function(e){zr.push(vt+"/"+e+"?returnUrl="+Xr())},r.prototype.render=function(){var e=this;return t.createElement("div",null,t.createElement(d,{container:!0,justify:"flex-end",spacing:8},this.canShowCompleteButton()&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.showCreateRefundDialog()}},"Complete Return")),this.canShowAcknowledgeButton()&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.showAcknowledgeReceiptItemsConfirmDialog()}},"Acknowledge Receipt Items")),this.canShowViewExchangeButton()&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.viewExchangeOrder(e.props.returnOrderForm.ExchangeOrderId)}},"View Exchange")),this.canShowCreateExchangeButton()&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.createExchangeOrder()}},"Create Exchange")),this.canShowCancelButton()&&t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:function(){return e.showCancelConfirmDialog()}},"Cancel Return"))),t.createElement(ar,{open:this.state.confirmDialog.isOpen,title:this.state.confirmDialog.title,closeLabel:this.state.confirmDialog.closeButtonLabel,okLabel:this.state.confirmDialog.confirmButtonLabel,onOK:this.state.confirmDialog.onConfirm,onClose:function(){return e.closeDialog()}},t.createElement(s.Typography,{variant:"body1"},this.state.confirmDialog.message)),this.state.isOpenRefundDialog&&t.createElement(ua,{onClose:function(){e.setState({isOpenRefundDialog:!1})},orderGroupId:this.props.orderGroupId,returnFormId:this.props.returnOrderForm.OrderFormId}))},r}(t.Component),pa=n.connect((function(e,t){return Ge({},t)}))(da),ha=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={returnLineItem:t.props.returnLineItem,returnReasons:Array(),isLoadingResource:!1,returnQuantity:t.props.returnLineItem.ReturnQuantity},t.handleReturnQuantityChange=function(e){isNaN(e.target.value)?t.setState({returnQuantity:0}):t.setState({returnQuantity:Number(e.target.value)})},t.handleReturnReasonChange=function(e){var r=Ge({},t.state.returnLineItem);r.ReturnReason=e,t.setState({returnLineItem:r})},t.update=function(){return Pe(t,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.state.returnQuantity>this.state.returnLineItem.Quantity?(this.props.dispatch(rt.ApplicationActions.showNotification("The return quantity must be less than or equal to available quantity.")),[2]):[4,Zt.OrderGroup.updateReturnLineItem(this.props.orderGroupId,this.props.returnFormId,this.state.returnLineItem.LineItemId,this.state.returnQuantity,this.state.returnLineItem.ReturnReason)];case 1:return t.sent(),this.props.onUpdated&&this.props.onUpdated(),[3,3];case 2:return e=t.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(e.message)),[3,3];case 3:return[2]}}))}))},t}return Te(r,e),r.prototype.componentWillMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,this.getData()];case 1:return e.sent(),[2]}}))}))},r.prototype.getData=function(){return Pe(this,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return this.setState({isLoadingResource:!0}),[4,Zt.OrderGroup.getReturnReasons()];case 1:return e=r.sent(),t=e.map((function(e){return{label:e.Label,value:e.Label}})),this.setState({returnReasons:t,isLoadingResource:!1}),[2]}}))}))},r.prototype.render=function(){var e=t.createElement(d,{container:!0,spacing:16},t.createElement(d,{item:!0,xs:12,sm:12,md:12},t.createElement(be,{outlined:!0,label:"Display Name",style:{width:"100%"}},t.createElement(Ie.Input,{readOnly:!0,disabled:!0,style:{width:"100%"},value:this.props.returnLineItem.DisplayName}))),t.createElement(d,{item:!0,xs:12,sm:12,md:12},t.createElement(be,{outlined:!0,label:"Quantity",style:{width:"100%"}},t.createElement(Ie.Input,{type:"number",readOnly:!0,disabled:!0,style:{width:"100%"},value:this.props.returnLineItem.Quantity}))),t.createElement(d,{item:!0,xs:12,sm:12,md:12},t.createElement(be,{outlined:!0,onChange:this.handleReturnQuantityChange,style:{width:"100%"},label:"Return Quantity"},t.createElement(Ie.Input,{type:"number",step:"0.01",min:"0",disabled:!this.props.isReturnEditable,readOnly:!this.props.isReturnEditable,max:this.state.returnLineItem.Quantity,value:this.state.returnQuantity}))),t.createElement(d,{item:!0,xs:12,sm:12,md:12},t.createElement(be,{outlined:!0,type:"number",label:"Placed Price",style:{width:"100%"}},t.createElement(Ie.Input,{type:"number",style:{width:"100%"},readOnly:!0,disabled:!0,value:this.props.returnLineItem.PlacedPrice.Amount}))),t.createElement(d,{item:!0,xs:12,sm:12,md:12},!this.state.isLoadingResource&&t.createElement(_t,{label:"Return Reason",disabled:!this.props.isReturnEditable,fullWidth:!0,value:this.state.returnLineItem.ReturnReason,options:this.state.returnReasons,required:!0,onChange:this.handleReturnReasonChange})));return this.props.isReturnEditable?t.createElement(ar,{title:"Edit Return Line Item",open:!0,okLabel:"Save",onOK:this.update,onClose:this.props.onClose},e):t.createElement(ar,{title:"View Return Line Item",open:!0,onClose:this.props.onClose},e)},r}(t.Component),ma=n.connect()(ha),ga=function(e){function r(r){var n=e.call(this,r)||this;return n.columns=[{name:"NAME",selector:"DisplayName",render:function(e){return t.createElement(s.Grid,{container:!0,direction:"row",className:n.props.classes.rowData},t.createElement(_s,Ge({},e)),t.createElement(s.Grid,{item:!0},t.createElement(x,{noWrap:!0,variant:"body2",color:"inherit"},e.DisplayName),t.createElement(x,{variant:"body1",color:"inherit"},e.Code)))}},{name:"PLACED PRICE",selector:"PlacedPrice",right:!0,render:function(e){return t.createElement(En,{amount:e.PlacedPrice})}},{name:"PURCHASED QUANTITY",selector:"Quantity",right:!0},{name:"SHIPMENT NO",selector:"OriginalShipmentNo",right:!0},{name:"RETURN QUANTITY",selector:"ReturnQuantity",right:!0},{name:"TOTAL BEFORE RETURN",selector:"Total",right:!0,render:function(e){return t.createElement(En,{amount:e.Total})}},{name:"",width:10,render:function(e,r){var s=[];return n.isReturnEditable()?(s.push({title:"Edit",clickHandler:function(){return Pe(n,void 0,void 0,(function(){return Ne(this,(function(t){return this.goToLineItemDetail(e),[2]}))}))}}),s.push({title:"Delete",clickHandler:function(){return Pe(n,void 0,void 0,(function(){return Ne(this,(function(t){return this.setState({currentItem:e,isDeleteDialogOpen:!0}),[2]}))}))}})):s.push({title:"View",clickHandler:function(){return Pe(n,void 0,void 0,(function(){return Ne(this,(function(t){return this.goToLineItemDetail(e),[2]}))}))}}),t.createElement(is,{actions:s,rowData:e,rowIndex:r})}}],n.handleReturnCommentChange=function(e){var t=Ge({},n.state.returnOrderForm);t.ReturnComment=e.target.value,n.setState({returnOrderForm:t})},n.closeDialog=n.closeDialog.bind(n),n}return Te(r,e),r.prototype.loadPaymentMethods=function(e){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(t){switch(t.label){case 0:return[4,Zt.PaymentMethod.getPaymentMethods(e)];case 1:return[2,t.sent()]}}))}))},r.prototype.componentWillMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return this.setState({isLoadingResource:!0}),[4,this.getData()];case 1:return e.sent(),this.setState({isLoadingResource:!1}),[2]}}))}))},r.prototype.getData=function(){return Pe(this,void 0,void 0,(function(){var e,t,r,n;return Ne(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,Zt.OrderGroup.getReturn(this.props.orderGroupId,this.props.returnFormId)];case 1:return e=s.sent(),this.setState({returnOrderForm:e}),[4,Zt.OrderGroup.getSingleOrderGroup("Order",this.props.orderGroupId)];case 2:return t=s.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(t)),t.ValidationMessages.length>0&&this.props.dispatch(rt.ApplicationActions.showNotification(t.ValidationMessages.join(", "))),[4,this.loadPaymentMethods(t.MarketId)];case 3:return r=s.sent(),this.props.dispatch(rt.PaymentActions.setPaymentMethods(r)),[3,5];case 4:return n=s.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(n.message)),[3,5];case 5:return[2]}}))}))},r.prototype.cancelReturn=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,Zt.OrderGroup.cancelReturn(this.props.orderGroupId,this.props.returnFormId)];case 1:return e.sent(),[4,this.getData()];case 2:return e.sent(),[2]}}))}))},r.prototype.closeView=function(){var e=vt+"/"+this.props.orderGroupId+"?tab=return";zr.push(e)},r.prototype.closeDialog=function(){this.setState({lineItemDialogOpen:!1})},r.prototype.goToLineItemDetail=function(e){this.setState({lineItemDialogOpen:!0,returnLineItemSelected:e,isReturnEditable:this.isReturnEditable()})},r.prototype.deleteLineItem=function(e){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(t){switch(t.label){case 0:return this.setState({isLoadingResource:!0}),[4,Zt.OrderGroup.deleteReturnLineItem(this.props.orderGroupId,this.props.returnFormId,e.LineItemId)];case 1:return t.sent(),[2]}}))}))},r.prototype.updateReturnComment=function(){return Pe(this,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,Zt.OrderGroup.updateReturnForm(this.props.orderGroupId,this.props.returnFormId,this.state.returnOrderForm)];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(e.message)),[3,3];case 3:return[2]}}))}))},r.prototype.isReturnEditable=function(){return this.state.returnOrderForm.Status.Code===cs.AwaitingStockReturn},r.prototype.render=function(){var e=this;return t.createElement("div",null,t.createElement(fr,{closeView:function(){return e.closeView()},title:"Return Details",showDialogActions:!0},this.state.lineItemDialogOpen&&t.createElement(ma,{orderGroupId:this.props.orderGroupId,returnFormId:this.props.returnFormId,returnLineItem:this.state.returnLineItemSelected,isReturnEditable:this.state.isReturnEditable,onUpdated:function(){return Pe(e,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return this.closeDialog(),[4,this.getData()];case 1:return e.sent(),[2]}}))}))},onClose:this.closeDialog}),t.createElement(s.Grid,{container:!0,direction:"column",spacing:8},t.createElement(s.Grid,{item:!0},t.createElement(pa,{onUpdated:function(){return e.getData()},returnOrderForm:this.state.returnOrderForm,orderGroupId:this.props.orderGroupId})),t.createElement(s.Grid,{item:!0},t.createElement(s.Card,null,t.createElement(s.CardContent,null,this.state&&this.state.returnOrderForm&&t.createElement(s.Grid,{container:!0,direction:"column",spacing:16},t.createElement(s.Grid,{item:!0},t.createElement(x,{className:this.props.classes.rowLabel},"Return No"),t.createElement(x,{className:this.props.classes.rowData},this.state.returnOrderForm.RMANumber)),t.createElement(s.Grid,{item:!0},t.createElement(x,{className:this.props.classes.rowLabel},"Created Date"),t.createElement(x,{className:this.props.classes.rowData},X(this.state.returnOrderForm.Created).format("LLL"))),t.createElement(s.Grid,{item:!0},t.createElement(x,{className:this.props.classes.rowLabel},"Created By"),t.createElement(x,{className:this.props.classes.rowData},this.state.returnOrderForm.Creator.FullName)),t.createElement(s.Grid,{item:!0},t.createElement(x,{className:this.props.classes.rowLabel},"Status"),t.createElement(x,{className:this.props.classes.rowData},this.state.returnOrderForm.Status.Name)),t.createElement(s.Grid,{item:!0},t.createElement(x,{className:this.props.classes.rowLabel},"Comment"),t.createElement(be,{className:this.props.classes.rowData,textarea:!0,style:{height:"100px",width:"400px"}},t.createElement(Ie.Input,{style:{resize:"none"},maxLength:1024,readOnly:this.state.returnOrderForm.Status.Code!==cs.AwaitingStockReturn,value:this.state.returnOrderForm.ReturnComment,onChange:this.handleReturnCommentChange,onBlur:function(){e.updateReturnComment()}}))),t.createElement(s.Grid,{item:!0},!this.state.isLoadingResource&&this.state.returnOrderForm&&t.createElement(wn,{columns:this.columns,data:ea(this.state.returnOrderForm)})),t.createElement(s.Grid,null,t.createElement(s.Grid,null,t.createElement(ca,{amount:this.state.returnOrderForm.ItemsTotal,label:"Line Item Total",variant:"subtitle1"})),t.createElement(s.Grid,null,t.createElement(ca,{amount:this.state.returnOrderForm.InvalidDiscount,label:"Invalidated Discounts",variant:"subtitle1"})),t.createElement(s.Grid,null,t.createElement(ca,{amount:this.state.returnOrderForm.Total,label:"Return Total",variant:"subtitle1"}))))))))),t.createElement(ar,{open:this.state.isDeleteDialogOpen,title:"Delete Item",closeLabel:"No",okLabel:"Yes",onOK:function(){e.deleteLineItem(e.state.currentItem).then((function(){e.setState({isDeleteDialogOpen:!1}),e.getData().then((function(){return e.setState({isLoadingResource:!1})}))}))},onClose:function(){return e.setState({isDeleteDialogOpen:!1})}},t.createElement(x,{variant:"body1"},"Are you sure you want to delete this item?")))},r}(t.Component),fa=s.withStyles((function(e){e.spacing;return s.createStyles({rowLabel:{display:"inline-block",width:"200px"},rowData:{display:"inline-block"}})}))(n.connect((function(e,t){return Ge({orderGroup:e.orderGroup.currentOrderGroup},t)}))(ga)),ya=function(e){function r(t){var r,n=e.call(this,t)||this;if(n.state={selectedOrderTabIndex:1,showConfirmDiscardDialog:!1,returnOrderFormId:-1},n.orderTabNames=new Array,n.orderTabIndexChangedHandler=function(e){return Pe(n,void 0,void 0,(function(){var t;return Ne(this,(function(r){return this.setState({selectedOrderTabIndex:e}),(t=new URLSearchParams(zr.location.search)).set("tab",this.orderTabNames[e].key),zr.replace(zr.location.pathname+"?"+t.toString()),[2]}))}))},n.createOrderHandler=function(){return Pe(n,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),[4,Zt.OrderGroup.createPurchaseOrder(this.props.orderGroup)];case 1:return e=r.sent(),this.state.returnOrderFormId>-1&&e.ParentOrderId?[4,Zt.OrderGroup.updateExchangeOrderId(e.ParentOrderId,this.state.returnOrderFormId,e.OrderGroupId)]:[3,3];case 2:r.sent(),r.label=3;case 3:return zr.replace(vt+"/"+e.OrderGroupId),[3,5];case 4:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,5];case 5:return[2]}}))}))},!n.props.orderGroup)return zr.push("/?type=Order"),n;n.initOrderTabs(t);var s=new URLSearchParams(zr.location.search),a=s.get("tab");if(a){var i=n.orderTabNames.findIndex((function(e){return e.key===a}));i>0&&(n.state.selectedOrderTabIndex=i)}return n.state.returnOrderFormId=parseInt(null!=(r=s.get("returnFormId"))?r:"-1",10),n}return Te(r,e),r.prototype.initOrderTabs=function(e){this.orderTabNames.push({key:"summary",name:"Summary"}),this.orderTabNames.push({key:"details",name:"Form Details "}),this.orderTabNames.push({key:"contact",name:"Contact Details"})},r.prototype.closeView=function(){var e=Kr("previous_order_create");zr.push(null!=e?e:"/")},r.prototype.render=function(){var e,r,n=this,a=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,i=null===(r=this.props.extendUI)||void 0===r?void 0:r.bottomPlaceHolder;return t.createElement(t.Fragment,null,this.props.orderGroup&&t.createElement(fr,{closeView:function(){return n.setState({showConfirmDiscardDialog:!0})},title:"Prepare Order",showDialogActions:!0},a&&t.createElement(a,{MarketId:this.props.selectedMarket,CustomerId:this.props.orderGroup.Customer.Id}),t.createElement(s.Grid,{container:!0,direction:"column",spacing:8},t.createElement(s.Grid,{item:!0},t.createElement(s.Grid,{container:!0,justify:"flex-end"},t.createElement(s.Grid,{item:!0},t.createElement(f.TextButton,{outlined:!0,type:"submit",disabled:!ts(this.props.orderGroup),onClick:this.createOrderHandler},"Create Order")))),t.createElement(s.Grid,{item:!0},t.createElement(s.AppBar,{position:"static",color:"default"},t.createElement(f.TabBar,{activeIndex:this.state.selectedOrderTabIndex,handleActiveIndexUpdate:this.orderTabIndexChangedHandler},this.orderTabNames.map((function(e){return t.createElement(f.Tab,{key:e.key},e.name)})))),t.createElement(s.Card,null,t.createElement(s.CardContent,null,t.createElement(s.Grid,null,"summary"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(Hn,{orderGroup:this.props.orderGroup,isReadonly:!0,createMode:!0}),"details"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(s.Grid,null,t.createElement(na,{orderForm:this.props.orderGroup.Forms[0]})),"contact"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(s.Grid,null,t.createElement(jn,{orderGroup:this.props.orderGroup}))))))),i&&t.createElement(i,{MarketId:this.props.selectedMarket,CustomerId:this.props.orderGroup.Customer.Id})),this.state.showConfirmDiscardDialog&&t.createElement(ir,{title:"Discard Order",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:this.closeView,onClose:function(){n.setState({showConfirmDiscardDialog:!1})}},t.createElement(s.Typography,{variant:"body1"},"Are you sure you want to discard Order?")))},r}(t.Component),Ea=n.connect((function(e,t){var r,n;return{selectedMarket:e.market.selectedMarket,orderGroup:e.orderGroup.currentOrderGroup,extendUI:null===(n=null===(r=e.setting.pageConfig)||void 0===r?void 0:r.createOrder)||void 0===n?void 0:n.extendUI}}))(ya),va=function(e){function r(t){var r=e.call(this,t)||this;r.state={selectedOrderTabIndex:1,showConfirmDiscardDialog:!1,loaded:!1},r.orderTabNames=new Array,r.paymentPlanSettingValidator={validate:function(){return!1}},r.initCartData=function(){return Pe(r,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return[4,Zt.Cart.getCustomerCart(this.props.customerId,this.props.marketId)];case 1:return t.sent()&&this.props.dispatch(rt.ApplicationActions.showNotification("EPiServer Commerce does not allow carts with same customer and market. Existing cart of the customer in current market was cleared.")),[4,Zt.Cart.createOrRefreshCart(this.props.customerId,this.props.marketId,"Default")];case 2:return(e=t.sent())&&this.props.dispatch(rt.OrderGroupActions.updateCurrentOrderGroup(e)),[2]}}))}))},r.orderTabIndexChangedHandler=function(e){return Pe(r,void 0,void 0,(function(){var t;return Ne(this,(function(r){return this.setState({selectedOrderTabIndex:e}),(t=new URLSearchParams(zr.location.search)).set("tab",this.orderTabNames[e].key),zr.replace(zr.location.pathname+"?"+t.toString()),[2]}))}))},r.closeView=function(){r.props.dispatch(rt.ApplicationActions.closeCustomerSelectionView()),r.props.dispatch(rt.OrderGroupActions.setPaymentPlanSetting({})),Zt.Cart.deleteCart(r.props.orderGroup.OrderGroupId);var e=Kr("previous_paymentplan_create");zr.push(null!=e?e:"/")},r.createPaymentPlanHandler=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Zt.PaymentPlan.createPaymentPlan(this.props.orderGroup.OrderGroupId,this.props.paymentPlanSetting)];case 1:return e=r.sent(),zr.replace(St+"/"+e.OrderGroupId),[3,3];case 2:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.initOrderTabs(t);var n=new URLSearchParams(zr.location.search).get("tab");if(n){var s=r.orderTabNames.findIndex((function(e){return e.key===n}));s>0&&(r.state.selectedOrderTabIndex=s)}return r}return Te(r,e),r.prototype.componentDidMount=function(){return Pe(this,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return this.props.orderGroup&&this.props.orderGroup.OrderGroupId&&this.props.currentOrderGroupId===this.props.orderGroup.OrderGroupId?[3,3]:[4,this.initCartData()];case 1:return t.sent(),[4,Zt.Currency.getCurrencies(this.props.orderGroup.MarketId)];case 2:e=t.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrencies(e)),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroupId(this.props.orderGroup.OrderGroupId)),t.label=3;case 3:return this.setState({loaded:!0}),[2]}}))}))},r.prototype.initOrderTabs=function(e){this.orderTabNames.push({key:"summary",name:"Summary"}),this.orderTabNames.push({key:"details",name:"Form Details "}),this.orderTabNames.push({key:"contact",name:"Contact Details"}),this.orderTabNames.push({key:"settings",name:"Settings"})},r.prototype.render=function(){var e,r,n=this,a=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,i=null===(r=this.props.extendUI)||void 0===r?void 0:r.bottomPlaceHolder;return t.createElement(t.Fragment,null,this.props.orderGroup&&this.state.loaded&&t.createElement(fr,{closeView:function(){return n.setState({showConfirmDiscardDialog:!0})},title:"Create Payment Plan",showDialogActions:!0},a&&t.createElement(a,{MarketId:this.props.marketId,CustomerId:this.props.customerId}),t.createElement(s.Grid,{container:!0,direction:"column",spacing:8},t.createElement(s.Grid,{item:!0},t.createElement(s.Grid,{container:!0,justify:"flex-end"},t.createElement(s.Grid,{item:!0},t.createElement(f.TextButton,{outlined:!0,type:"submit",disabled:!ts(this.props.orderGroup)||!this.paymentPlanSettingValidator.validate(),onClick:this.createPaymentPlanHandler},"Create Payment Plan")))),t.createElement(s.Grid,{item:!0},t.createElement(s.AppBar,{position:"static",color:"default"},t.createElement(f.TabBar,{activeIndex:this.state.selectedOrderTabIndex,handleActiveIndexUpdate:this.orderTabIndexChangedHandler},this.orderTabNames.map((function(e){return t.createElement(f.Tab,{key:e.key},e.name)})))),t.createElement(s.Card,null,t.createElement(s.CardContent,null,t.createElement(s.Grid,null,"summary"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(Hn,{orderGroup:this.props.orderGroup,isReadonly:!1,createMode:!0}),"details"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(s.Grid,null,t.createElement(na,{orderForm:this.props.orderGroup.Forms[0]})),"contact"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(s.Grid,null,t.createElement(jn,{orderGroup:this.props.orderGroup})),"settings"===this.orderTabNames[this.state.selectedOrderTabIndex].key&&t.createElement(s.Grid,null,t.createElement(Jn,{editMode:!0,createMode:!0,paymentPlan:this.props.orderGroup,validator:this.paymentPlanSettingValidator}))))))),i&&t.createElement(i,{MarketId:this.props.marketId,CustomerId:this.props.customerId})),this.state.showConfirmDiscardDialog&&t.createElement(ir,{title:"Discard Payment Plan",closeButtonLabel:"No",confirmButtonLabel:"Yes",onConfirm:this.closeView,onClose:function(){n.setState({showConfirmDiscardDialog:!1})}},t.createElement(s.Typography,{variant:"body1"},"Are you sure you want to discard Payment Plan?")))},r}(t.Component),Ca=n.connect((function(e,t){var r,n;return{orderGroup:e.orderGroup.currentOrderGroup,currentOrderGroupId:e.orderGroup.currentOrderGroupId,marketId:t.marketId,customerId:t.customerId,paymentPlanSetting:e.orderGroup.paymentPlanSetting,extendUI:null===(n=null===(r=e.setting.pageConfig)||void 0===r?void 0:r.createPaymentPlan)||void 0===n?void 0:n.extendUI}}))(va),Sa=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({root:{border:"solid 1px #000",padding:"8px 12px",backgroundColor:"#fff",textAlign:"center"}})}))(n.connect((function(e,t){return{orderGroupFilterIsVisible:e.application.orderGroupFilterIsVisible,classes:t.classes}}))((function(e){var r=e.classes;return e.orderGroupFilterIsVisible?t.createElement("div",{className:r.root},t.createElement(x,null,"This feature is yet not available.")):null}))),Ia=require("autosuggest-highlight/match"),ba=require("autosuggest-highlight/parse"),Aa=function(e,r){var n=Ia(e.FullName,r.query),a=ba(e.FullName,n),i=Ia(e.Email,r.query),o=ba(e.Email,i);return t.createElement(f.List,null,t.createElement(f.ListItem,{style:{height:"48px"}},t.createElement(f.ListItemText,{primaryText:t.createElement("div",null,a.map((function(e,r){return e.highlight?t.createElement("span",{key:String(r),style:{fontWeight:500}},e.text):t.createElement("strong",{key:String(r),style:{fontWeight:300}},e.text)})),t.createElement("div",null,t.createElement(s.Typography,{color:"textSecondary",gutterBottom:!0},t.createElement("div",null,o.map((function(e,r){return e.highlight?t.createElement("span",{key:String(r),style:{fontWeight:500}},e.text):t.createElement("strong",{key:String(r),style:{fontWeight:300}},e.text)}))))))})),t.createElement(f.ListDivider,null))},Oa=function(e){var r=e.ref,n=De(e,["ref"]);return t.createElement(s.TextField,{autoFocus:!0,required:!0,fullWidth:!0,label:"Choose customer",placeholder:"Search by name or e-mail...",variant:"outlined",InputProps:Ge({inputRef:r},n)})},Ta=function(e){return e.FullName};var wa=o.withStyles((function(e){e.palette;var t=e.spacing;e.breakpoints;return s.createStyles({container:{position:"relative"},suggestionsContainerOpen:{position:"absolute",zIndex:1,marginTop:t.unit,left:0,right:0,maxHeight:"300px",overflowY:"auto"},suggestion:{display:"block"},suggestionsList:{margin:0,padding:0,listStyleType:"none"},divider:{height:2*t.unit},email:{display:"block",fontSize:"0.9em"}})}))(n.connect((function(e,t){var r=e.market.markets.find((function(e){return!0===e.IsCurrentMarket}));return{suggestions:e.application.customerSearchFieldSuggestions,classes:t.classes,listedOrderGroups:e.orderGroup.listedOrderGroups,orderPageIndex:e.application.pageIndex,orderRowsPerPage:e.application.rowsPerPage,selectedMarket:e.market.selectedMarket||(r?r.Id:""),selectedContactId:e.application.selectedContactId,onSelectionChanged:t.onSelectionChanged}}))((function(e){var r=this,n=e.classes,a=t.useState(""),i=a[0],o=a[1],c=t.useState(""),l=c[0],u=c[1];t.useEffect((function(){!function(){Pe(this,void 0,void 0,(function(){var t,r;return Ne(this,(function(n){switch(n.label){case 0:if(!e.selectedContactId||i===e.selectedContactId)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),o(e.selectedContactId),[4,Zt.Contact.get(e.selectedContactId)];case 2:return t=n.sent(),e.dispatch(rt.ApplicationActions.setCustomerSearchFieldSuggestions([{Id:t.Id,FullName:t.FullName?t.FullName:"",Email:t.Email?t.Email:""}])),u(t.FullName),e.onSelectionChanged(e.selectedMarket,e.selectedContactId),[3,4];case 3:return r=n.sent(),e.dispatch(rt.ApplicationActions.showNotification(r.message)),[3,4];case 4:return[2]}}))}))}()}),[e.selectedContactId]);var d=t.useCallback(ve.debounce((function(t){var n=t.value;return Pe(r,void 0,void 0,(function(){var t,r,s;return Ne(this,(function(a){switch(a.label){case 0:t=n.trim().toLowerCase(),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,Zt.Contact.list(t)];case 2:return r=a.sent(),e.dispatch(rt.ApplicationActions.setCustomerSearchFieldSuggestions(r)),[3,4];case 3:return s=a.sent(),e.dispatch(rt.ApplicationActions.showNotification(s.message)),[3,4];case 4:return[2]}}))}))}),1e3,{trailing:!0}),[]),p=function(){e.dispatch(rt.CreateContactFormActions.showCreateContactForm())};return t.createElement(s.Grid,{container:!0,spacing:16,direction:"row"},t.createElement(s.Grid,{item:!0,xs:12},t.createElement(Un,{selectedMarket:e.selectedMarket,updateInputValue:function(t){return function(t){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(r){return e.dispatch(rt.MarketActions.setSelectedMarket(t)),e.onSelectionChanged(t,e.selectedContactId),[2]}))}))}(t)}})),t.createElement(s.Grid,{item:!0,xs:12},t.createElement(Ce,{renderInputComponent:Oa,suggestions:e.suggestions,onSuggestionsFetchRequested:d,onSuggestionsClearRequested:function(){e.dispatch(rt.ApplicationActions.setCustomerSearchFieldSuggestions([]))},renderSuggestionsContainer:function(e){return function(e,r){var n=e.containerProps,a=e.children;return t.createElement("div",{style:{marginTop:"8px"}},!a&&t.createElement(f.TextButton,{onClick:function(e){e.preventDefault(),r(e)},outlined:!0},"New Customer"),t.createElement(s.Paper,Ge({},n,{style:{marginTop:0},square:!0}),a))}(e,p)},getSuggestionValue:Ta,renderSuggestion:Aa,onSuggestionSelected:function(t,n){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(t){return e.dispatch(rt.ApplicationActions.setSelectedContactId(n.suggestion.Id)),e.onSelectionChanged(e.selectedMarket,n.suggestion.Id),o(n.suggestion.Id),[2]}))}))},inputProps:{value:l,onChange:function(t,r){r&&(u(r.newValue),""===r.newValue&&(e.onSelectionChanged(e.selectedMarket,""),e.dispatch(rt.ApplicationActions.setSelectedContactId(""))))},type:"search"},theme:{container:n.container,suggestionsContainerOpen:n.suggestionsContainerOpen,suggestionsList:n.suggestionsList,suggestion:n.suggestion}})))}))),Ga=function(e){function r(t){var r=e.call(this,t)||this;return r.getTitle=function(e){switch(e){case"Cart":return"Open Cart";case"Order":return"Create Order";case"PaymentPlan":return"Create Payment Plan";default:return""}},r.selectionChangedHandler=function(e,t){return Pe(r,void 0,void 0,(function(){var r,n;return Ne(this,(function(s){switch(s.label){case 0:if(!e||!t)return this.setState({cartMode:null,currentCart:null,isFormValid:!1}),[2];if(this.setState({cartMode:null,isFormValid:!0}),"Cart"!==this.props.orderGroupType)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,Zt.Cart.getCustomerCart(t,e)];case 2:return r=s.sent(),this.setState({currentCart:r,cartMode:r?"open":"create"}),[3,4];case 3:return n=s.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(n.message)),[3,4];case 4:return[2]}}))}))},r.createOrRefreshCart=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Zt.Cart.createOrRefreshCart(this.props.selectedContactId,this.props.selectedMarket,"Default")];case 1:return(e=r.sent())&&(this.closeView(),zr.push(Ct+"/"+e.OrderGroupId)),[3,3];case 2:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.openCustomerCart=function(){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(e){return this.state.currentCart?(this.closeView(),zr.push(Ct+"/"+this.state.currentCart.OrderGroupId)):this.props.dispatch(rt.ApplicationActions.showNotification("Cart is not found.")),[2]}))}))},r.createCustomerOrder=function(){return Pe(r,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return[4,Zt.OrderGroup.initPurchaseOrder(this.props.selectedContactId,this.props.selectedMarket)];case 1:return e=t.sent(),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup(e)),this.closeView(),Qr("previous_order_create"),zr.push(""+Tt),[2]}}))}))},r.createPaymentPlan=function(){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(e){return this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroup({})),this.props.dispatch(rt.OrderGroupActions.setCurrentOrderGroupId(null)),this.closeView(),Qr("previous_paymentplan_create"),zr.push(wt+"?marketId="+this.props.selectedMarket+"&customerId="+this.props.selectedContactId),[2]}))}))},r.closeView=function(){r.props.dispatch(rt.ApplicationActions.setSelectedContactId("")),r.props.dispatch(rt.ApplicationActions.closeCustomerSelectionView())},r.state={title:r.getTitle(r.props.orderGroupType),orderGroupType:r.props.orderGroupType,isFormValid:!1,currentCart:null,cartMode:null},r}return Te(r,e),r.prototype.render=function(){return t.createElement(h,{open:!0,maxWidth:"sm",fullWidth:!0,onClose:this.closeView,className:this.props.classes.root,classes:{paper:this.props.classes.paper}},t.createElement(ce,null,this.state.title),t.createElement(g,{className:this.props.classes.dialogContent},t.createElement(wa,{onSelectionChanged:this.selectionChangedHandler})),t.createElement(m,null,t.createElement(f.TextButton,{onClick:this.closeView},"Cancel"),"Cart"===this.props.orderGroupType&&t.createElement(t.Fragment,null,"create"===this.state.cartMode&&t.createElement(f.TextButton,{disabled:!this.state.isFormValid,unelevated:!0,type:"submit",onClick:this.createOrRefreshCart},"Create a cart"),"open"===this.state.cartMode&&t.createElement(f.TextButton,{disabled:!this.state.isFormValid,unelevated:!0,type:"submit",onClick:this.openCustomerCart},"Open cart")),"Order"===this.props.orderGroupType&&t.createElement(f.TextButton,{disabled:!this.state.isFormValid,unelevated:!0,type:"submit",onClick:this.createCustomerOrder},"Create Order"),"PaymentPlan"===this.props.orderGroupType&&t.createElement(f.TextButton,{disabled:!this.state.isFormValid,unelevated:!0,type:"submit",onClick:this.createPaymentPlan},"Create Payment Plan")))},r}(t.Component),Da=o.withStyles((function(e){e.palette,e.spacing,e.breakpoints;return s.createStyles({root:{},paper:{overflowY:"visible"},dialogContent:{overflowY:"visible"}})}))(n.connect((function(e,t){return{selectedMarket:e.market.selectedMarket,selectedContactId:e.application.selectedContactId,listedOrderGroups:e.orderGroup.listedOrderGroups,orderGroupType:t.orderGroupType,classes:t.classes}}))(Ga)),Pa=function(e){function r(t){var r=e.call(this,t)||this;return r.updateInputValue=function(e){return Pe(r,void 0,void 0,(function(){var t;return Ne(this,(function(r){return(t=Object.assign({},this.props.contact))[e.target.name]=String(e.target.value),this.props.dispatch(rt.CreateContactFormActions.setCreateContactFormContact(t)),[2]}))}))},r.saveChanges=function(){return Pe(r,void 0,void 0,(function(){var e,t;return Ne(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Zt.Contact.createContact(this.props.contact)];case 1:return e=r.sent(),this.props.dispatch(rt.ApplicationActions.setSelectedContactId(e.Id)),this.closeView(),[3,3];case 2:return t=r.sent(),this.props.dispatch(rt.ApplicationActions.showNotification(t.message)),[3,3];case 3:return[2]}}))}))},r.closeView=function(){r.props.dispatch(rt.CreateContactFormActions.hideCreateContactForm())},r}return Te(r,e),r.prototype.componentDidUpdate=function(e){this.currentForm&&e.isCurrentFormValid!==this.currentForm.isFormValid()&&this.props.dispatch(rt.CreateContactFormActions.setCreateContactFormIsValid(this.currentForm.isFormValid()))},r.prototype.render=function(){var e=this;return t.createElement(h,{open:!0,maxWidth:"sm",fullWidth:!0},t.createElement(ce,null,"Create Contact"),t.createElement(g,null,t.createElement(T.ValidatorForm,{ref:function(t){return e.currentForm=t},onSubmit:this.saveChanges},t.createElement(en,{contact:this.props.contact,saveChanges:this.saveChanges,updateInputValue:this.updateInputValue}))),t.createElement(m,null,t.createElement(f.TextButton,{onClick:this.closeView},"Cancel"),t.createElement(f.TextButton,{unelevated:!0,type:"submit",disabled:!this.props.isCurrentFormValid,onClick:this.saveChanges},"Save Customer")))},r}(t.Component),Na=n.connect((function(e){return{contact:e.createContactForm.contact,selectedMarket:e.market.selectedMarket,isCurrentFormValid:e.createContactForm.isValid,listedOrderGroups:e.orderGroup.listedOrderGroups}}))(Pa),Ra=require("autosuggest-highlight/match"),xa=require("autosuggest-highlight/parse"),La=function(e,r){var n=Ra(e.FullName,r.query),a=xa(e.FullName,n),i=Ra(e.Email,r.query),o=xa(e.Email,i);return t.createElement(f.List,null,t.createElement(f.ListItem,{style:{height:"48px"}},t.createElement(f.ListItemText,{primaryText:t.createElement("div",null,a.map((function(e,r){return e.highlight?t.createElement("span",{key:String(r),style:{fontWeight:500}},e.text):t.createElement("strong",{key:String(r),style:{fontWeight:300}},e.text)})),t.createElement("div",null,t.createElement(s.Typography,{color:"textSecondary",gutterBottom:!0},t.createElement("div",null,o.map((function(e,r){return e.highlight?t.createElement("span",{key:String(r),style:{fontWeight:500}},e.text):t.createElement("strong",{key:String(r),style:{fontWeight:300}},e.text)}))))))})),t.createElement(f.ListDivider,null))},Ma=function(e){var r=e.ref,n=De(e,["ref"]);return t.createElement(s.TextField,{autoFocus:!0,required:!0,fullWidth:!0,label:"Choose customer",placeholder:"Search by name or e-mail...",variant:"outlined",InputProps:Ge({inputRef:r},n)})},Fa=function(e){return e.FullName};var ka=o.withStyles((function(){return s.createStyles({container:{position:"relative"},suggestionsContainerOpen:{zIndex:1,position:"fixed",marginTop:"0px",maxHeight:"300px",overflowY:"auto",width:"512px"},suggestion:{display:"block"},suggestionsList:{margin:0,padding:0,listStyleType:"none"}})}))(n.connect((function(e,t){return{classes:t.classes,onContactSelected:t.onContactSelected,onClose:t.onClose}}))((function(e){var r=this,n=e.classes,a=t.useState(""),i=a[0],o=a[1],c=t.useState([]),l=c[0],u=c[1],d=t.useCallback(ve.debounce((function(t){var n=t.value;return Pe(r,void 0,void 0,(function(){var t,r,s;return Ne(this,(function(a){switch(a.label){case 0:t=n.trim().toLowerCase(),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,Zt.Contact.list(t)];case 2:return r=a.sent(),u(r),[3,4];case 3:return s=a.sent(),e.dispatch(rt.ApplicationActions.showNotification(s.message)),[3,4];case 4:return[2]}}))}))}),1e3,{trailing:!0}),[]);return t.createElement(ar,{title:"Open Customer",open:!0,onClose:e.onClose},t.createElement(s.Grid,{container:!0,spacing:16},t.createElement(s.Grid,{item:!0,xs:12},t.createElement(Ce,{renderInputComponent:Ma,suggestions:l,onSuggestionsFetchRequested:d,onSuggestionsClearRequested:function(){u([])},renderSuggestionsContainer:function(e){return function(e){var r=e.containerProps,n=e.children;return t.createElement(s.Paper,Ge({},r),n)}(e)},getSuggestionValue:Fa,renderSuggestion:La,onSuggestionSelected:function(t,n){return Pe(r,void 0,void 0,(function(){return Ne(this,(function(t){return e.onContactSelected&&e.onContactSelected(n.suggestion.Id),[2]}))}))},inputProps:{value:i,onChange:function(e,t){t&&o(t.newValue)},type:"search"},theme:{container:n.container,suggestionsContainerOpen:n.suggestionsContainerOpen,suggestionsList:n.suggestionsList,suggestion:n.suggestion}}))))}))),_a=function(e){function r(t){var r=e.call(this,t)||this;return r.state={orderGroupType:r.props.orderGroupType,searchText:r.props.searchText,searchInputValue:r.props.searchText,isLoadingResource:!0,searchOptions:r.getSearchTypeOptions(r.props.orderGroupType),searchType:r.props.searchType,openCustomerDialogVisible:!1},r.handleScroll=function(){return Pe(r,void 0,void 0,(function(){var e;return Ne(this,(function(t){switch(t.label){case 0:return window.innerHeight+window.pageYOffset>=document.body.offsetHeight&&this.props.listedOrderGroups.length0&&0===this.props.listedOrderGroups.length?t.createElement(x,null,"Sorry, we couldn't find any results matching \""+this.state.searchText+'"'):this.props.listedOrderGroups.map((function(r,n){var s=t.createElement(x,{variant:"body1",className:e.props.classes.orderStatusText},Mn(r.OrderStatus)),a=[];return r.HasAwaitingReturnCompletable&&a.push("Awaiting Return Completion"),r.HasAwaitingStockReturns&&a.push("Awaiting Stock Return"),t.createElement(d,{item:!0,key:n,onClick:function(){return e.goToDetail(r.OrderGroupId,r.Type)},className:e.props.classes.orderRow},t.createElement(d,{container:!0,direction:"row",spacing:16,alignItems:"flex-start",justify:"space-between"},t.createElement(d,{item:!0,xs:12,md:1,className:e.props.classes.orderGroupId},t.createElement(x,{variant:"body1"},"Order"===r.Type?r.OrderNumber:"# "+r.OrderGroupId)),t.createElement(d,{item:!0,xs:12,md:2,className:e.props.classes.orderDate},t.createElement(x,{variant:"body1",className:e.props.classes.orderDateText},r.Created&&X(r.Created).format("LLL"))),t.createElement(d,{item:!0,xs:12,md:1,className:e.props.classes.cartName},t.createElement(x,{variant:"body1"},r.Name)),t.createElement(d,{item:!0,xs:12,md:1,className:e.props.classes.marketName},t.createElement(x,{variant:"body1"},r.MarketName)),t.createElement(d,{item:!0,xs:12,md:1,className:e.props.classes.customerName},t.createElement(x,{variant:"body1"},r.CustomerName)),t.createElement(d,{item:!0,xs:12,sm:12,md:2,className:e.props.classes.email},t.createElement(x,{variant:"body1"},r.Customer.Email)),t.createElement(d,{item:!0,xs:12,sm:6,md:2,className:e.props.classes.orderAmount},t.createElement(En,{amount:r.Total,className:e.props.classes.orderAmountText,align:"right"})),t.createElement(d,{item:!0,xs:12,sm:6,md:2,className:e.props.classes.orderStatus},s,a.length>0&&t.createElement(x,{variant:"subtitle2"},"(",a.join(", "),")"))))}))},r.prototype.render=function(){var e=this;return t.createElement(s.Card,{className:this.props.classes.root},t.createElement(s.CardContent,null,t.createElement(d,{container:!0,spacing:16,direction:"column"},t.createElement(d,{item:!0},t.createElement(d,{container:!0,justify:"space-between"},t.createElement(d,{item:!0},t.createElement(d,{container:!0,spacing:8},t.createElement(d,{item:!0},t.createElement(f.TextButton,{unelevated:"Cart"===this.state.orderGroupType,outlined:!0,onClick:function(){return e.switchOrderGroupType("Cart")}},"Carts")),t.createElement(d,{item:!0},t.createElement(f.TextButton,{unelevated:"Order"===this.state.orderGroupType,outlined:!0,onClick:function(){return e.switchOrderGroupType("Order")}},"Orders")),t.createElement(d,{item:!0},t.createElement(f.TextButton,{unelevated:"PaymentPlan"===this.state.orderGroupType,outlined:!0,onClick:function(){return e.switchOrderGroupType("PaymentPlan")}},"Payment plan")),t.createElement(d,{item:!0},t.createElement(_t,{dense:!0,value:this.state.searchType,options:this.state.searchOptions,onChange:this.handleSearchTypeChange})),t.createElement(d,{item:!0},t.createElement(s.TextField,{value:this.state.searchInputValue,variant:"outlined",placeholder:"Search",onChange:this.handleSearchTextChange,onKeyPress:function(t){"Enter"===t.key&&e.handleEnterThrottle()},InputProps:{classes:{root:this.props.classes.searchInput},startAdornment:t.createElement(s.InputAdornment,{position:"start"},t.createElement(Ae.Search,null)),endAdornment:0===this.state.searchInputValue.length?void 0:t.createElement(s.InputAdornment,{position:"end"},t.createElement(Ae.Clear,{onClick:this.clearSearchText}))}})))),t.createElement(d,{item:!0},t.createElement(d,{container:!0,spacing:8},t.createElement(d,{item:!0},"Cart"===this.state.orderGroupType&&t.createElement(f.TextButton,{onClick:this.openCustomerSelectionView,outlined:!0},"Open Cart"),"Order"===this.state.orderGroupType&&t.createElement(f.TextButton,{outlined:!0,onClick:this.handleCreateOrder},"Create Order"),"PaymentPlan"===this.state.orderGroupType&&t.createElement(f.TextButton,{outlined:!0,onClick:this.handleCreatePaymentPlan},"Create Payment Plan")),t.createElement(d,{item:!0},t.createElement(f.TextButton,{outlined:!0,onClick:this.handleOpenCustomerSearchDialog},"Open Customer"),this.state.openCustomerDialogVisible&&t.createElement(ka,{onContactSelected:this.handleContactSelected,onClose:this.handleCloseCustomerSearchDialog})))))),t.createElement(d,{item:!0},t.createElement(d,{container:!0,direction:"column"},t.createElement(d,{item:!0},t.createElement(V,{smDown:!0},t.createElement(d,{item:!0,className:this.props.classes.orderHeaderRow},t.createElement(d,{container:!0,direction:"row",spacing:16,alignItems:"flex-start",justify:"space-between"},t.createElement(d,{item:!0,xs:6,md:1},t.createElement(x,{variant:"caption"},"No.")),t.createElement(d,{item:!0,xs:6,md:2},t.createElement(x,{variant:"caption"},"Created Date")),t.createElement(d,{item:!0,xs:6,md:1},t.createElement(x,{variant:"caption"},"Name")),t.createElement(d,{item:!0,xs:6,md:1},t.createElement(x,{variant:"caption"},"Market")),t.createElement(d,{item:!0,xs:12,sm:6,md:1},t.createElement(x,{variant:"caption"},"Customer Name")),t.createElement(d,{item:!0,xs:12,sm:6,md:2},t.createElement(x,{variant:"caption"},"Customer Email")),t.createElement(d,{item:!0,xs:6,sm:6,md:2},t.createElement(x,{variant:"caption",align:"right"},"Amount")),t.createElement(d,{item:!0,xs:6,sm:6,md:2},t.createElement(x,{variant:"caption"},"Status"))))),this.renderGridBody()),this.state.isLoadingResource&&t.createElement(d,{item:!0},t.createElement(v,{className:this.props.classes.progressIndicator})))))))},r}(t.Component),Va={cursor:"pointer",borderBottom:"1px solid #eee",paddingTop:er.paddingDefault,paddingBottom:er.paddingDefault},Ua=o.withStyles((function(e){var t,r,n,a,i,o,c,l,u,d,p,h=e.palette,m=(e.spacing,e.breakpoints);return s.createStyles({root:{margin:15,width:"calc(100% - 30px)"},orderRow:Ge(Ge({},Va),{paddingLeft:5,paddingRight:5,cursor:"pointer","&:hover":{backgroundColor:tr.hoveredList,color:h.getContrastText(tr.hoveredList)}}),orderHeaderRow:Ge({},Va),emptyListStatement:{margin:er.marginDefault,padding:er.paddingDefault,textAlign:"center"},progressContainer:{marginTop:8,textAlign:"center"},progressIndicator:{margin:8,color:h.secondary.light},customerName:(t={fontWeight:"bold",order:4},t[m.down("sm")]={order:0},t),email:(r={fontWeight:"bold",order:5},r[m.down("sm")]={order:1},r),customerNameText:{fontWeight:"bold"},orderDate:(n={order:2},n[m.down("sm")]={order:3},n),orderDateText:(a={},a[m.down("sm")]={color:h.secondary.light},a),orderGroupId:(i={order:1},i[m.down("sm")]={display:"none"},i),marketName:(o={order:4},o[m.down("sm")]={order:2},o),cartName:(c={order:3},c[m.down("sm")]={display:"none"},c),orderAmount:(l={order:6},l[m.down("sm")]={order:4},l),orderAmountText:(u={},u[m.down("sm")]={textAlign:"left"},u),orderStatus:(d={order:7},d[m.down("sm")]={order:5},d),orderStatusText:(p={},p[m.down("sm")]={color:h.secondary.light},p),searchInput:{height:"36px"}})}))(n.connect((function(e,t){return{listedOrderGroups:e.orderGroup.listedOrderGroups,pageIndex:e.application.pageIndex,rowsPerPage:e.application.rowsPerPage,totalOrderGroups:e.application.totalOrderGroups,orderGroupType:t.orderGroupType,classes:t.classes,searchText:t.searchText,searchType:t.searchType}}))(_a)),Ba=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Te(r,e),r.prototype.render=function(){var e,r,n=null===(e=this.props.extendUI)||void 0===e?void 0:e.topPlaceHolder,s=null===(r=this.props.extendUI)||void 0===r?void 0:r.bottomPlaceHolder;return t.createElement("div",null,n&&t.createElement(n,{className:"top-placeholder"}),t.createElement(Sa,null),this.props.customerSelectionViewIsVisible&&t.createElement(Da,{orderGroupType:this.props.orderGroupType}),this.props.createContactFormIsVisible&&t.createElement(Na,null),t.createElement(Ua,{orderGroupType:this.props.orderGroupType,searchText:this.props.searchText,searchType:this.props.searchType}),s&&t.createElement(s,{className:"bottom-placeholder"}))},r}(t.Component),Ha=function(e,t){var r,n,s,a;switch(e){case"Order":a=null===(r=t.setting.pageConfig.orderList)||void 0===r?void 0:r.extendUI;break;case"Cart":a=null===(n=t.setting.pageConfig.cartList)||void 0===n?void 0:n.extendUI;break;case"PaymentPlan":a=null===(s=t.setting.pageConfig.paymentPlanList)||void 0===s?void 0:s.extendUI}return a};var qa,Wa=(qa=o.withStyles((function(e){return e.palette,e.spacing,e.breakpoints,s.createStyles({})}))(n.connect((function(e,t){return{customerSelectionViewIsVisible:e.application.customerSelectionViewIsVisible,orderGroupType:t.orderGroupType,searchText:t.searchText,searchType:t.searchType,orderGroupViewIsVisible:e.application.orderGroupViewIsVisible,createContactFormIsVisible:e.createContactForm.isVisible,classes:t.classes,extendUI:Ha(t.orderGroupType,e)}}))(Ba)),function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return Te(r,e),r.prototype.render=function(){return t.createElement("div",null,this.props.topPlaceHolder?this.props.topPlaceHolder:"",t.createElement(qa,Ge({},this.props)),this.props.bottomPlaceHolder?this.props.bottomPlaceHolder:"")},r}(t.Component)),ja=n.connect((function(e,t){var r;return{extraPages:null===(r=e.setting.pageConfig)||void 0===r?void 0:r.extraPages}}))((function(e){return t.createElement(D.HashRouter,null,t.createElement("div",null,t.createElement(D.Route,{path:mt,render:function(e){return t.createElement(yn,Ge({customerId:e.match.params.id},e))}}),t.createElement(D.Route,{path:It,exact:!0,render:function(e){var r=e.match.params;return t.createElement(oa,{orderGroupId:r.id,orderGroupType:"Order"})}}),t.createElement(D.Route,{path:bt,exact:!0,render:function(e){var r=e.match.params;return t.createElement(oa,{orderGroupId:r.id,orderGroupType:"Cart"})}}),t.createElement(D.Route,{path:At,exact:!0,render:function(e){var r=e.match.params;return t.createElement(oa,{orderGroupId:r.id,orderGroupType:"PaymentPlan"})}}),t.createElement(D.Route,{path:Ot,exact:!0,render:function(e){var r=e.match.params;return t.createElement(fa,{orderGroupId:r.id,returnFormId:r.formId})}}),t.createElement(D.Route,{path:Tt,render:function(e){return t.createElement(Ea,Ge({},e))}}),t.createElement(D.Route,{path:wt,render:function(e){var r=new URLSearchParams(e.location.search),n=r.get("customerId")||"",s=r.get("marketId")||"";return t.createElement(Ca,{customerId:n,marketId:s})}}),t.createElement(D.Route,{path:pt,exact:!0,render:function(e){var r,n,s,a=new URLSearchParams(e.location.search),i=a.get("type");switch(i){case"Order":i="Order";break;case"PaymentPlan":i="PaymentPlan";break;default:i="Cart"}var o=null!=(r=a.get("search"))?r:"",c=null!=(s=Yn[(n=a.get("searchBy"),null!=n?n:"CustomerName")])?s:Yn.CustomerName;return c===Yn.OrderNumber&&"Order"!==i&&(c=Yn.CustomerName),t.createElement(Wa,{orderGroupType:i,searchText:o,searchType:c})}}),e.extraPages&&e.extraPages.map((function(e){return t.createElement(D.Route,{key:e.path,path:e.path,exact:e.exact,render:function(t){return e.render(t)}})}))))})),Ya=o.createMuiTheme({typography:{fontFamily:"Barlow, sans-serif",useNextVariants:!0},palette:{primary:{main:"#1456F1",light:"#8EBAFF",contrastText:"#fff"},secondary:{main:"#FF9283",contrastText:"#000"},error:{main:"#f01c10"}},overrides:{MuiCard:{root:{overflow:"unset"}},MuiModal:{root:{zIndex:1e4}},MuiSnackbar:{root:{zIndex:10001}}}});(new dt).initialize(nt);var za=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.state={ready:!1},t}return Te(r,e),r.prototype.componentDidMount=function(){return Pe(this,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,Pe(void 0,void 0,void 0,(function(){var e,t,r,n,s,a;return Ne(this,(function(i){switch(i.label){case 0:return[4,Pe(void 0,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,Zt.Geographics.getCountries()];case 1:return[2,e.sent()]}}))}))];case 1:return e=i.sent(),nt.dispatch(rt.GeographicsActions.setCountries(e)),[4,Pe(void 0,void 0,void 0,(function(){return Ne(this,(function(e){switch(e.label){case 0:return[4,Zt.Market.getMarkets()];case 1:return[2,e.sent()]}}))}))];case 2:return t=i.sent(),nt.dispatch(rt.MarketActions.setMarkets(t)),r=t.find((function(e){return!0===e.IsCurrentMarket})),nt.dispatch(rt.MarketActions.setSelectedMarket(r?r.Id:"")),[4,Zt.Shipment.getShippingMethods()];case 3:return n=i.sent(),nt.dispatch(rt.ShipmentActions.setShippingMethods(n)),[4,Zt.OrderGroup.getOrderStatuses()];case 4:return s=i.sent(),nt.dispatch(rt.OrderGroupActions.setOrderStatuses(s)),[4,Zt.Shipment.getShipmentStatuses()];case 5:return a=i.sent(),nt.dispatch(rt.ShipmentActions.setShipmentStatuses(a)),[2]}}))}))];case 1:return e.sent(),this.setState({ready:!0}),null!=this.props.setting&&nt.dispatch(rt.AppSettingActions.updateSetting(this.props.setting)),[2]}}))}))},r.prototype.render=function(){return this.state.ready&&t.createElement(n.Provider,{store:nt},t.createElement(s.MuiThemeProvider,{theme:Ya},t.createElement(a.MuiPickersUtilsProvider,{utils:c},t.createElement(st,null),t.createElement(ut,null),t.createElement(at,null),t.createElement(it,null),t.createElement(ja,null))))},r}(t.Component),Qa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Te(t,e),t}((function(){}));exports.AppSettingState=Qa,exports.CSRApp=za; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/package.json b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/package.json new file mode 100644 index 00000000..a5a6953c --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/package.json @@ -0,0 +1,46 @@ +{ + "name": "@episerver/csr-app", + "version": "0.1.0", + "main": "bundle.js", + "types": "types.d.ts", + "module": "bundle.esm.js", + "license": "MIT", + "dependencies": { + "axios": "^0.18.0", + "moment": "^2.24.0", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "@date-io/core": "^1.3.8", + "@date-io/moment": "^1.3.8", + "@episerver/ui-framework": "^0.8.1", + "@material-ui/core": "3.9.1", + "@material-ui/icons": "^3.0.1", + "@material/button": "^4.0.0", + "@material/checkbox": "^4.0.0", + "@material/data-table": "^4.0.0", + "@material/menu": "^4.0.0", + "@material/menu-surface": "^4.0.0", + "@material/react-menu": "^0.15.0", + "@material/react-select": "^0.15.0", + "@material/react-text-field": "^0.15.0", + "@material/ripple": "^4.0.0", + "@material/theme": "^4.0.0", + "autosuggest-highlight": "^3.1.1", + "bignumber.js": "^9.0.0", + "countries-list": "^2.5.1", + "flag-icon-css": "^3.3.0", + "lodash-es": "^4.17.15", + "material-ui-pickers": "^2.2.4", + "react-autosuggest": "9.3.2", + "react-material-ui-form-validator": "2.0.2", + "react-redux": "^5.0.7", + "react-router-dom": "^4.3.1", + "redux": "^4.0.0", + "rollup-plugin-terser": "^7.0.2", + "url-search-params": "^1.1.0", + "us-state-codes": "^1.1.2", + "yup": "^0.28.5", + "zipcodes": "^8.0.0", + "node-sass": "^4.12.0" + } +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/types.d.ts b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/types.d.ts new file mode 100644 index 00000000..58cd9b1a --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-app/types.d.ts @@ -0,0 +1,236 @@ +// Generated by dts-bundle v0.7.3 +// Dependencies for this module: +// ../react +// ../store/setting/state +// ../react-router-dom + +import * as React from 'react'; +import { AppSettingState } from 'store/setting/state'; +import { RouteComponentProps } from 'react-router-dom'; + +export { CSRApp, AppSettingState }; + +import '@episerver/ui-framework/dist/main.css'; +import '../styles/app.scss'; +interface Props { + setting?: AppSettingState; +} +export declare class CSRApp extends React.Component { + state: { + ready: boolean; + }; + componentDidMount(): Promise; + render(): false | JSX.Element; +} +export {}; + +export declare class AppSettingState extends CSRAppSetting { +} + +export declare class CSRAppSetting { + pageConfig: AppPagesConfig; + general?: { + searchLineItemResult: ExtendableUI; + editShipmentDialog?: ExtendableUI; + addLineItemDialog?: ExtendableUI; + editLineItemDialog?: ExtendableUI; + }; +} +export interface AppPagesConfig { + /** + * Config page at route '/orders' + */ + orderList?: ExtendableUI; + /** + * Config page at route '/carts' + */ + cartList?: ExtendableUI; + /** + * Config page at route '/paymentplans' + */ + paymentPlanList?: ExtendableUI; + /** + * Config page at route '/createorder' + */ + createOrder?: ExtendableUI, CreateOrderExtendProps>; + /** + * Config page at route '/orders/:id' + */ + orderDetail?: ExtendableUI, OrderDetailExtendProps>; + /** + * Config page at route '/customers/:contactId' + */ + contactDetail?: ExtendableUI>; + /** + * Config page at route '/carts/:id' + */ + cartDetail?: ExtendableUI, CartDetailExtendProps>; + /** + * Config page at route '/paymentplans/:id' + */ + paymentPlanDetail?: ExtendableUI, PaymentPlanDetailExtendProps>; + /** + * Config page at route '/createPaymentPlan' + */ + createPaymentPlan?: ExtendableUI, CreatePaymentPlanExtendProps>; + /** + * Define more routes + */ + extraPages?: Array; +} +export interface ExtendableUI { + extendUI?: ExtendableComponentProps; + config?: T; +} +export interface ExtendableUI { + extendUI?: ExtendableComponentProps; + config?: T; +} +export interface OrderListConfig { +} +export interface CreateOrderConfig { + extraTabs?: Array>; +} +export interface OrderDetailConfig { + /** + * Add more tabs for OrderDetail page + */ + extraTabs?: Array>; +} +export interface OrderDetailTab { + title: string; + render: React.FunctionComponent; +} +export interface ContactDetailConfig { + extraPages: Array>; +} +export interface CustomContactDetailPage { + title: string; + path: string; + exact?: boolean; + render: React.FunctionComponent; + getLink(props: D): string; +} +export interface CartListConfig { +} +export interface CartDetailConfig { + extraTabs?: Array>; +} +export interface PaymentPlanListConfig { +} +export interface CreatePaymentPlanConfig { + extraTabs?: Array>; +} +export interface PaymentPlanDetailConfig { + extraTabs?: Array>; +} +export interface EditShipmentDialogConfig { +} +export interface EditLineItemDialogConfig { +} +export interface AddLineItemDialogConfig { +} +export interface ExtraPageConfig { + path: string; + exact?: boolean; + render(props: RouteComponentProps): JSX.Element; +} +export interface SearchLineItemResult { +} +export interface OrderDetailExtendProps { + /** + * Id of Order + */ + Id: number; +} +export interface CartDetailExtendProps { + /** + * Id of Cart + */ + Id: number; +} +export interface PaymentPlanDetailExtendProps { + /** + * Id of PaymentPlan + */ + Id: number; +} +export interface ContactDetailExtendProps { + CustomerId: string; +} +export interface CreateOrderExtendProps { + MarketId: string; + CustomerId: string; +} +export interface CreatePaymentPlanExtendProps { + MarketId: string; + CustomerId: string; +} + +export interface ExtendableComponentProps { + /** + * Placeholder at the top of component + */ + topPlaceHolder?: React.FunctionComponent; + /** + * Placeholder at the bottom of component + */ + bottomPlaceHolder?: React.FunctionComponent; +} +export interface ExtendableUIProps { + extendUI?: ExtendableComponentProps; +} +export declare const withExtendableUI:

(Component: React.ComponentType

) => { + new (props: Readonly

>): { + render(): JSX.Element; + context: any; + setState(state: {} | ((prevState: Readonly<{}>, props: Readonly

>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; + forceUpdate(callback?: (() => void) | undefined): void; + readonly props: Readonly

> & Readonly<{ + children?: React.ReactNode; + }>; + state: Readonly<{}>; + refs: { + [key: string]: React.ReactInstance; + }; + componentDidMount?(): void; + shouldComponentUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): boolean; + componentWillUnmount?(): void; + componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; + getSnapshotBeforeUpdate?(prevProps: Readonly

>, prevState: Readonly<{}>): any; + componentDidUpdate?(prevProps: Readonly

>, prevState: Readonly<{}>, snapshot?: any): void; + componentWillMount?(): void; + UNSAFE_componentWillMount?(): void; + componentWillReceiveProps?(nextProps: Readonly

>, nextContext: any): void; + UNSAFE_componentWillReceiveProps?(nextProps: Readonly

>, nextContext: any): void; + componentWillUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): void; + UNSAFE_componentWillUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): void; + }; + new (props: P & ExtendableComponentProps, context?: any): { + render(): JSX.Element; + context: any; + setState(state: {} | ((prevState: Readonly<{}>, props: Readonly

>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; + forceUpdate(callback?: (() => void) | undefined): void; + readonly props: Readonly

> & Readonly<{ + children?: React.ReactNode; + }>; + state: Readonly<{}>; + refs: { + [key: string]: React.ReactInstance; + }; + componentDidMount?(): void; + shouldComponentUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): boolean; + componentWillUnmount?(): void; + componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; + getSnapshotBeforeUpdate?(prevProps: Readonly

>, prevState: Readonly<{}>): any; + componentDidUpdate?(prevProps: Readonly

>, prevState: Readonly<{}>, snapshot?: any): void; + componentWillMount?(): void; + UNSAFE_componentWillMount?(): void; + componentWillReceiveProps?(nextProps: Readonly

>, nextContext: any): void; + UNSAFE_componentWillReceiveProps?(nextProps: Readonly

>, nextContext: any): void; + componentWillUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): void; + UNSAFE_componentWillUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): void; + }; + contextType?: React.Context | undefined; +}; + diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/bundle.esm.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/bundle.esm.js new file mode 100644 index 00000000..f7fd3c77 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/bundle.esm.js @@ -0,0 +1,15 @@ +import n from"axios"; +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */var t=function(n,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o])})(n,o)};var o=function(n){function o(){return null!==n&&n.apply(this,arguments)||this}return function(n,o){function r(){this.constructor=n}t(n,o),n.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}(o,n),o}((function(){})),r=n.create({baseURL:"./api-extension"}),i={InitConfiguration:function(n){window.CSRExtension&&window.CSRExtension.InitConfiguration(n)}};export{o as AppSettingState,i as CSRExtension,r as HttpRequest}; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/bundle.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/bundle.js new file mode 100644 index 00000000..cd8e0153 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/bundle.js @@ -0,0 +1,15 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,n=(t=require("axios"))&&"object"==typeof t&&"default"in t?t.default:t,e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)}; +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */var o=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(n,t),n}((function(){})),r=n.create({baseURL:"./api-extension"}),i={InitConfiguration:function(t){window.CSRExtension&&window.CSRExtension.InitConfiguration(t)}};exports.AppSettingState=o,exports.CSRExtension=i,exports.HttpRequest=r; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/package.json b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/package.json new file mode 100644 index 00000000..718c69ed --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/package.json @@ -0,0 +1,12 @@ +{ + "name": "@episerver/csr-extension", + "version": "0.1.0", + "main": "bundle.js", + "types": "types.d.ts", + "module": "bundle.esm.js", + "license": "MIT", + "dependencies": { + "axios": "^0.18.0", + "react": "^16.13.1" + } +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/types.d.ts b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/types.d.ts new file mode 100644 index 00000000..cec9d3d8 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/internal-npm-packages/csr-extension/types.d.ts @@ -0,0 +1,224 @@ +// Generated by dts-bundle v0.7.3 +// Dependencies for this module: +// ../react-router-dom +// ../react + +import { RouteComponentProps } from 'react-router-dom'; +import * as React from 'react'; + +declare const HttpRequest: import("axios").AxiosInstance; +declare const CSRExtension: { + InitConfiguration: (setting: AppSettingState) => void; +}; +export { AppSettingState, HttpRequest, CSRExtension }; + +export declare class AppSettingState extends CSRAppSetting { +} + +export declare class CSRAppSetting { + pageConfig: AppPagesConfig; + general?: { + searchLineItemResult: ExtendableUI; + editShipmentDialog?: ExtendableUI; + addLineItemDialog?: ExtendableUI; + editLineItemDialog?: ExtendableUI; + }; +} +export interface AppPagesConfig { + /** + * Config page at route '/orders' + */ + orderList?: ExtendableUI; + /** + * Config page at route '/carts' + */ + cartList?: ExtendableUI; + /** + * Config page at route '/paymentplans' + */ + paymentPlanList?: ExtendableUI; + /** + * Config page at route '/createorder' + */ + createOrder?: ExtendableUI, CreateOrderExtendProps>; + /** + * Config page at route '/orders/:id' + */ + orderDetail?: ExtendableUI, OrderDetailExtendProps>; + /** + * Config page at route '/customers/:contactId' + */ + contactDetail?: ExtendableUI>; + /** + * Config page at route '/carts/:id' + */ + cartDetail?: ExtendableUI, CartDetailExtendProps>; + /** + * Config page at route '/paymentplans/:id' + */ + paymentPlanDetail?: ExtendableUI, PaymentPlanDetailExtendProps>; + /** + * Config page at route '/createPaymentPlan' + */ + createPaymentPlan?: ExtendableUI, CreatePaymentPlanExtendProps>; + /** + * Define more routes + */ + extraPages?: Array; +} +export interface ExtendableUI { + extendUI?: ExtendableComponentProps; + config?: T; +} +export interface ExtendableUI { + extendUI?: ExtendableComponentProps; + config?: T; +} +export interface OrderListConfig { +} +export interface CreateOrderConfig { + extraTabs?: Array>; +} +export interface OrderDetailConfig { + /** + * Add more tabs for OrderDetail page + */ + extraTabs?: Array>; +} +export interface OrderDetailTab { + title: string; + render: React.FunctionComponent; +} +export interface ContactDetailConfig { + extraPages: Array>; +} +export interface CustomContactDetailPage { + title: string; + path: string; + exact?: boolean; + render: React.FunctionComponent; + getLink(props: D): string; +} +export interface CartListConfig { +} +export interface CartDetailConfig { + extraTabs?: Array>; +} +export interface PaymentPlanListConfig { +} +export interface CreatePaymentPlanConfig { + extraTabs?: Array>; +} +export interface PaymentPlanDetailConfig { + extraTabs?: Array>; +} +export interface EditShipmentDialogConfig { +} +export interface EditLineItemDialogConfig { +} +export interface AddLineItemDialogConfig { +} +export interface ExtraPageConfig { + path: string; + exact?: boolean; + render(props: RouteComponentProps): JSX.Element; +} +export interface SearchLineItemResult { +} +export interface OrderDetailExtendProps { + /** + * Id of Order + */ + Id: number; +} +export interface CartDetailExtendProps { + /** + * Id of Cart + */ + Id: number; +} +export interface PaymentPlanDetailExtendProps { + /** + * Id of PaymentPlan + */ + Id: number; +} +export interface ContactDetailExtendProps { + CustomerId: string; +} +export interface CreateOrderExtendProps { + MarketId: string; + CustomerId: string; +} +export interface CreatePaymentPlanExtendProps { + MarketId: string; + CustomerId: string; +} + +export interface ExtendableComponentProps { + /** + * Placeholder at the top of component + */ + topPlaceHolder?: React.FunctionComponent; + /** + * Placeholder at the bottom of component + */ + bottomPlaceHolder?: React.FunctionComponent; +} +export interface ExtendableUIProps { + extendUI?: ExtendableComponentProps; +} +export declare const withExtendableUI:

(Component: React.ComponentType

) => { + new (props: Readonly

>): { + render(): JSX.Element; + context: any; + setState(state: {} | ((prevState: Readonly<{}>, props: Readonly

>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; + forceUpdate(callback?: (() => void) | undefined): void; + readonly props: Readonly

> & Readonly<{ + children?: React.ReactNode; + }>; + state: Readonly<{}>; + refs: { + [key: string]: React.ReactInstance; + }; + componentDidMount?(): void; + shouldComponentUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): boolean; + componentWillUnmount?(): void; + componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; + getSnapshotBeforeUpdate?(prevProps: Readonly

>, prevState: Readonly<{}>): any; + componentDidUpdate?(prevProps: Readonly

>, prevState: Readonly<{}>, snapshot?: any): void; + componentWillMount?(): void; + UNSAFE_componentWillMount?(): void; + componentWillReceiveProps?(nextProps: Readonly

>, nextContext: any): void; + UNSAFE_componentWillReceiveProps?(nextProps: Readonly

>, nextContext: any): void; + componentWillUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): void; + UNSAFE_componentWillUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): void; + }; + new (props: P & ExtendableComponentProps, context?: any): { + render(): JSX.Element; + context: any; + setState(state: {} | ((prevState: Readonly<{}>, props: Readonly

>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; + forceUpdate(callback?: (() => void) | undefined): void; + readonly props: Readonly

> & Readonly<{ + children?: React.ReactNode; + }>; + state: Readonly<{}>; + refs: { + [key: string]: React.ReactInstance; + }; + componentDidMount?(): void; + shouldComponentUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): boolean; + componentWillUnmount?(): void; + componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; + getSnapshotBeforeUpdate?(prevProps: Readonly

>, prevState: Readonly<{}>): any; + componentDidUpdate?(prevProps: Readonly

>, prevState: Readonly<{}>, snapshot?: any): void; + componentWillMount?(): void; + UNSAFE_componentWillMount?(): void; + componentWillReceiveProps?(nextProps: Readonly

>, nextContext: any): void; + UNSAFE_componentWillReceiveProps?(nextProps: Readonly

>, nextContext: any): void; + componentWillUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): void; + UNSAFE_componentWillUpdate?(nextProps: Readonly

>, nextState: Readonly<{}>, nextContext: any): void; + }; + contextType?: React.Context | undefined; +}; + diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/package.json b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/package.json new file mode 100644 index 00000000..836e170f --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/package.json @@ -0,0 +1,151 @@ +{ + "name": "csr-extension", + "version": "0.1.0", + "private": true, + "scripts": { + "start": "node scripts/start.js", + "build": "SET NODE_ENV=development&&node scripts/build.js", + "package": "SET NODE_ENV=production&& node scripts/build-extension.js", + "package:dev": "SET NODE_ENV=development&& node scripts/build-extension.js", + "test": "node scripts/test.js" + }, + "dependencies": { + "@babel/core": "7.9.0", + "@babel/preset-react": "^7.10.4", + "@babel/preset-typescript": "^7.10.4", + "@episerver/csr-app": "file:internal-npm-packages/csr-app", + "@episerver/csr-extension": "file:internal-npm-packages/csr-extension", + "@svgr/webpack": "4.3.3", + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.3.2", + "@testing-library/user-event": "^7.1.2", + "@types/jest": "^24.0.0", + "@types/node": "^12.0.0", + "@typescript-eslint/eslint-plugin": "^2.10.0", + "@typescript-eslint/parser": "^2.10.0", + "babel-eslint": "10.1.0", + "babel-jest": "^24.9.0", + "babel-loader": "8.1.0", + "babel-plugin-named-asset-import": "^0.3.6", + "babel-preset-react-app": "^9.1.2", + "camelcase": "^5.3.1", + "case-sensitive-paths-webpack-plugin": "2.3.0", + "css-loader": "3.4.2", + "dotenv": "8.2.0", + "dotenv-expand": "5.1.0", + "eslint": "^6.6.0", + "eslint-config-react-app": "^5.2.1", + "eslint-loader": "3.0.3", + "eslint-plugin-flowtype": "4.6.0", + "eslint-plugin-import": "2.20.1", + "eslint-plugin-jsx-a11y": "6.2.3", + "eslint-plugin-react": "7.19.0", + "eslint-plugin-react-hooks": "^1.6.1", + "file-loader": "4.3.0", + "fs-extra": "^8.1.0", + "html-webpack-plugin": "4.0.0-beta.11", + "identity-obj-proxy": "3.0.0", + "jest": "24.9.0", + "jest-environment-jsdom-fourteen": "1.0.1", + "jest-resolve": "24.9.0", + "jest-watch-typeahead": "0.4.2", + "mini-css-extract-plugin": "0.9.0", + "node-sass": "^4.14.1", + "optimize-css-assets-webpack-plugin": "5.0.3", + "pnp-webpack-plugin": "1.6.4", + "postcss-flexbugs-fixes": "4.1.0", + "postcss-loader": "3.0.0", + "postcss-normalize": "8.0.1", + "postcss-preset-env": "6.7.0", + "postcss-safe-parser": "4.0.1", + "react-app-polyfill": "^1.0.6", + "react-dev-utils": "^10.2.1", + "react-redux": "^7.2.1", + "react-table": "^7.5.2", + "redux": "^4.0.5", + "resolve": "1.15.0", + "resolve-url-loader": "3.1.1", + "sass-loader": "8.0.2", + "semver": "6.3.0", + "style-loader": "0.23.1", + "terser-webpack-plugin": "2.3.8", + "ts-pnp": "1.1.6", + "typescript": "~3.7.2", + "url-loader": "2.3.0", + "webpack": "4.42.0", + "webpack-dev-server": "3.11.0", + "webpack-manifest-plugin": "2.2.0", + "workbox-webpack-plugin": "4.3.1" + }, + "devDependencies": { + "http-proxy-middleware": "^1.0.5" + }, + "eslintConfig": { + "extends": "react-app" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + }, + "jest": { + "roots": [ + "/src" + ], + "collectCoverageFrom": [ + "src/**/*.{js,jsx,ts,tsx}", + "!src/**/*.d.ts" + ], + "setupFiles": [ + "react-app-polyfill/jsdom" + ], + "setupFilesAfterEnv": [], + "testMatch": [ + "/src/**/__tests__/**/*.{js,jsx,ts,tsx}", + "/src/**/*.{spec,test}.{js,jsx,ts,tsx}" + ], + "testEnvironment": "jest-environment-jsdom-fourteen", + "transform": { + "^.+\\.(js|jsx|ts|tsx)$": "/node_modules/babel-jest", + "^.+\\.css$": "/config/jest/cssTransform.js", + "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "/config/jest/fileTransform.js" + }, + "transformIgnorePatterns": [ + "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$", + "^.+\\.module\\.(css|sass|scss)$" + ], + "modulePaths": [], + "moduleNameMapper": { + "^react-native$": "react-native-web", + "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy" + }, + "moduleFileExtensions": [ + "web.js", + "js", + "web.ts", + "ts", + "web.tsx", + "tsx", + "json", + "web.jsx", + "jsx", + "node" + ], + "watchPlugins": [ + "jest-watch-typeahead/filename", + "jest-watch-typeahead/testname" + ] + }, + "babel": { + "presets": [ + "react-app" + ] + } +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/favicon.ico b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/favicon.ico new file mode 100644 index 00000000..bcd5dfd6 Binary files /dev/null and b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/favicon.ico differ diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/index.html b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/index.html new file mode 100644 index 00000000..973bf5fe --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/index.html @@ -0,0 +1,16 @@ + + + + + + + + + + CSR Extension Configuration Sample + + + +

+ + diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/logo192.png b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/logo192.png new file mode 100644 index 00000000..fc44b0a3 Binary files /dev/null and b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/logo192.png differ diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/logo512.png b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/logo512.png new file mode 100644 index 00000000..a4e47a65 Binary files /dev/null and b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/logo512.png differ diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/manifest.json b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/manifest.json new file mode 100644 index 00000000..080d6c77 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/build-extension.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/build-extension.js new file mode 100644 index 00000000..f005f039 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/build-extension.js @@ -0,0 +1,173 @@ +'use strict'; + +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'production'; + +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + +// Ensure environment variables are read. +require('../config/env'); + +const chalk = require('react-dev-utils/chalk'); +const fs = require('fs-extra'); +const webpack = require('webpack'); +const configFactory = require('../config/webpack.extension.config'); +const paths = require('../config/paths'); +const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages'); +const FileSizeReporter = require('react-dev-utils/FileSizeReporter'); +const printBuildError = require('react-dev-utils/printBuildError'); + +const measureFileSizesBeforeBuild = + FileSizeReporter.measureFileSizesBeforeBuild; + +const isInteractive = process.stdout.isTTY; + +// Generate configuration +const config = configFactory(process.env.NODE_ENV); + +// We require that you explicitly set browsers and do not fall back to +// browserslist defaults. +const { checkBrowsers } = require('react-dev-utils/browsersHelper'); +checkBrowsers(paths.appPath, isInteractive) + .then(() => { + // First, read the current file sizes in build directory. + // This lets us display how much they changed later. + return measureFileSizesBeforeBuild(paths.appBuild); + }) + .then(previousFileSizes => { + // Remove all content but keep the directory so that + // if you're in it, you don't end up in Trash + fs.emptyDirSync(paths.appBuild); + // Merge with the public folder + // copyPublicFolder(); + // Start the webpack build + return build(previousFileSizes); + }) + .then( + ({ stats, previousFileSizes, warnings }) => { + if (warnings.length) { + console.log(chalk.yellow('Compiled with warnings.\n')); + console.log(warnings.join('\n\n')); + console.log( + '\nSearch for the ' + + chalk.underline(chalk.yellow('keywords')) + + ' to learn more about each warning.' + ); + console.log( + 'To ignore, add ' + + chalk.cyan('// eslint-disable-next-line') + + ' to the line before.\n' + ); + } else { + console.log(chalk.green('Compiled successfully.\n')); + } + }, + err => { + const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true'; + if (tscCompileOnError) { + console.log( + chalk.yellow( + 'Compiled with the following type errors (you may want to check these before deploying your app):\n' + ) + ); + printBuildError(err); + } else { + console.log(chalk.red('Failed to compile.\n')); + printBuildError(err); + process.exit(1); + } + } + ) + .catch(err => { + if (err && err.message) { + console.log(err.message); + } + process.exit(1); + }); + +// Create the production build and print the deployment instructions. +function build(previousFileSizes) { + // We used to support resolving modules according to `NODE_PATH`. + // This now has been deprecated in favor of jsconfig/tsconfig.json + // This lets you use absolute paths in imports inside large monorepos: + if (process.env.NODE_PATH) { + console.log( + chalk.yellow( + 'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.' + ) + ); + console.log(); + } + + console.log('Creating an optimized production build...'); + + const compiler = webpack(config); + return new Promise((resolve, reject) => { + compiler.run((err, stats) => { + let messages; + if (err) { + if (!err.message) { + return reject(err); + } + + let errMessage = err.message; + + // Add additional information for postcss errors + if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) { + errMessage += + '\nCompileError: Begins at CSS selector ' + + err['postcssNode'].selector; + } + + messages = formatWebpackMessages({ + errors: [errMessage], + warnings: [], + }); + } else { + messages = formatWebpackMessages( + stats.toJson({ all: false, warnings: true, errors: true }) + ); + } + if (messages.errors.length) { + // Only keep the first error. Others are often indicative + // of the same problem, but confuse the reader with noise. + if (messages.errors.length > 1) { + messages.errors.length = 1; + } + return reject(new Error(messages.errors.join('\n\n'))); + } + if ( + process.env.CI && + (typeof process.env.CI !== 'string' || + process.env.CI.toLowerCase() !== 'false') && + messages.warnings.length + ) { + console.log( + chalk.yellow( + '\nTreating warnings as errors because process.env.CI = true.\n' + + 'Most CI servers set it automatically.\n' + ) + ); + return reject(new Error(messages.warnings.join('\n\n'))); + } + + return resolve({ + stats, + previousFileSizes, + warnings: messages.warnings, + }); + }); + }); +} + +function copyPublicFolder() { + fs.copySync(paths.appPublic, paths.appBuild, { + dereference: true, + filter: file => file !== paths.appHtml, + }); +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/build.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/build.js new file mode 100644 index 00000000..2d826691 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/build.js @@ -0,0 +1,211 @@ +'use strict'; + +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'production'; +process.env.NODE_ENV = 'production'; + +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + +// Ensure environment variables are read. +require('../config/env'); + + +const path = require('path'); +const chalk = require('react-dev-utils/chalk'); +const fs = require('fs-extra'); +const webpack = require('webpack'); +const configFactory = require('../config/webpack.config'); +const paths = require('../config/paths'); +const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); +const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages'); +const printHostingInstructions = require('react-dev-utils/printHostingInstructions'); +const FileSizeReporter = require('react-dev-utils/FileSizeReporter'); +const printBuildError = require('react-dev-utils/printBuildError'); + +const measureFileSizesBeforeBuild = + FileSizeReporter.measureFileSizesBeforeBuild; +const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild; +const useYarn = fs.existsSync(paths.yarnLockFile); + +// These sizes are pretty large. We'll warn for bundles exceeding them. +const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024; +const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024; + +const isInteractive = process.stdout.isTTY; + +// Warn and crash if required files are missing +if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { + process.exit(1); +} + +// Generate configuration +const config = configFactory('production'); + +// We require that you explicitly set browsers and do not fall back to +// browserslist defaults. +const { checkBrowsers } = require('react-dev-utils/browsersHelper'); +checkBrowsers(paths.appPath, isInteractive) + .then(() => { + // First, read the current file sizes in build directory. + // This lets us display how much they changed later. + return measureFileSizesBeforeBuild(paths.appBuild); + }) + .then(previousFileSizes => { + // Remove all content but keep the directory so that + // if you're in it, you don't end up in Trash + fs.emptyDirSync(paths.appBuild); + // Merge with the public folder + copyPublicFolder(); + // Start the webpack build + return build(previousFileSizes); + }) + .then( + ({ stats, previousFileSizes, warnings }) => { + if (warnings.length) { + console.log(chalk.yellow('Compiled with warnings.\n')); + console.log(warnings.join('\n\n')); + console.log( + '\nSearch for the ' + + chalk.underline(chalk.yellow('keywords')) + + ' to learn more about each warning.' + ); + console.log( + 'To ignore, add ' + + chalk.cyan('// eslint-disable-next-line') + + ' to the line before.\n' + ); + } else { + console.log(chalk.green('Compiled successfully.\n')); + } + + console.log('File sizes after gzip:\n'); + printFileSizesAfterBuild( + stats, + previousFileSizes, + paths.appBuild, + WARN_AFTER_BUNDLE_GZIP_SIZE, + WARN_AFTER_CHUNK_GZIP_SIZE + ); + console.log(); + + const appPackage = require(paths.appPackageJson); + const publicUrl = paths.publicUrlOrPath; + const publicPath = config.output.publicPath; + const buildFolder = path.relative(process.cwd(), paths.appBuild); + printHostingInstructions( + appPackage, + publicUrl, + publicPath, + buildFolder, + useYarn + ); + }, + err => { + const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true'; + if (tscCompileOnError) { + console.log( + chalk.yellow( + 'Compiled with the following type errors (you may want to check these before deploying your app):\n' + ) + ); + printBuildError(err); + } else { + console.log(chalk.red('Failed to compile.\n')); + printBuildError(err); + process.exit(1); + } + } + ) + .catch(err => { + if (err && err.message) { + console.log(err.message); + } + process.exit(1); + }); + +// Create the production build and print the deployment instructions. +function build(previousFileSizes) { + // We used to support resolving modules according to `NODE_PATH`. + // This now has been deprecated in favor of jsconfig/tsconfig.json + // This lets you use absolute paths in imports inside large monorepos: + if (process.env.NODE_PATH) { + console.log( + chalk.yellow( + 'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.' + ) + ); + console.log(); + } + + console.log('Creating an optimized production build...'); + + const compiler = webpack(config); + return new Promise((resolve, reject) => { + compiler.run((err, stats) => { + let messages; + if (err) { + if (!err.message) { + return reject(err); + } + + let errMessage = err.message; + + // Add additional information for postcss errors + if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) { + errMessage += + '\nCompileError: Begins at CSS selector ' + + err['postcssNode'].selector; + } + + messages = formatWebpackMessages({ + errors: [errMessage], + warnings: [], + }); + } else { + messages = formatWebpackMessages( + stats.toJson({ all: false, warnings: true, errors: true }) + ); + } + if (messages.errors.length) { + // Only keep the first error. Others are often indicative + // of the same problem, but confuse the reader with noise. + if (messages.errors.length > 1) { + messages.errors.length = 1; + } + return reject(new Error(messages.errors.join('\n\n'))); + } + if ( + process.env.CI && + (typeof process.env.CI !== 'string' || + process.env.CI.toLowerCase() !== 'false') && + messages.warnings.length + ) { + console.log( + chalk.yellow( + '\nTreating warnings as errors because process.env.CI = true.\n' + + 'Most CI servers set it automatically.\n' + ) + ); + return reject(new Error(messages.warnings.join('\n\n'))); + } + + return resolve({ + stats, + previousFileSizes, + warnings: messages.warnings, + }); + }); + }); +} + +function copyPublicFolder() { + fs.copySync(paths.appPublic, paths.appBuild, { + dereference: true, + filter: file => file !== paths.appHtml, + }); +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/start.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/start.js new file mode 100644 index 00000000..088ea49a --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/start.js @@ -0,0 +1,166 @@ +'use strict'; + +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'development'; +process.env.NODE_ENV = 'development'; + +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + +// Ensure environment variables are read. +require('../config/env'); + + +const fs = require('fs'); +const chalk = require('react-dev-utils/chalk'); +const webpack = require('webpack'); +const WebpackDevServer = require('webpack-dev-server'); +const clearConsole = require('react-dev-utils/clearConsole'); +const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); +const { + choosePort, + createCompiler, + prepareProxy, + prepareUrls, +} = require('react-dev-utils/WebpackDevServerUtils'); +const openBrowser = require('react-dev-utils/openBrowser'); +const paths = require('../config/paths'); +const configFactory = require('../config/webpack.config'); +const createDevServerConfig = require('../config/webpackDevServer.config'); + +const useYarn = fs.existsSync(paths.yarnLockFile); +const isInteractive = process.stdout.isTTY; + +// Warn and crash if required files are missing +if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { + process.exit(1); +} + +// Tools like Cloud9 rely on this. +const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; +const HOST = process.env.HOST || '0.0.0.0'; + +if (process.env.HOST) { + console.log( + chalk.cyan( + `Attempting to bind to HOST environment variable: ${chalk.yellow( + chalk.bold(process.env.HOST) + )}` + ) + ); + console.log( + `If this was unintentional, check that you haven't mistakenly set it in your shell.` + ); + console.log( + `Learn more here: ${chalk.yellow('https://bit.ly/CRA-advanced-config')}` + ); + console.log(); +} + +// We require that you explicitly set browsers and do not fall back to +// browserslist defaults. +const { checkBrowsers } = require('react-dev-utils/browsersHelper'); +checkBrowsers(paths.appPath, isInteractive) + .then(() => { + // We attempt to use the default port but if it is busy, we offer the user to + // run on a different port. `choosePort()` Promise resolves to the next free port. + return choosePort(HOST, DEFAULT_PORT); + }) + .then(port => { + if (port == null) { + // We have not found a port. + return; + } + + const config = configFactory('development'); + const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'; + const appName = require(paths.appPackageJson).name; + const useTypeScript = fs.existsSync(paths.appTsConfig); + const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true'; + const urls = prepareUrls( + protocol, + HOST, + port, + paths.publicUrlOrPath.slice(0, -1) + ); + const devSocket = { + warnings: warnings => + devServer.sockWrite(devServer.sockets, 'warnings', warnings), + errors: errors => + devServer.sockWrite(devServer.sockets, 'errors', errors), + }; + // Create a webpack compiler that is configured with custom messages. + const compiler = createCompiler({ + appName, + config, + devSocket, + urls, + useYarn, + useTypeScript, + tscCompileOnError, + webpack, + }); + // Load proxy config + const proxySetting = require(paths.appPackageJson).proxy; + const proxyConfig = prepareProxy( + proxySetting, + paths.appPublic, + paths.publicUrlOrPath + ); + // Serve webpack assets generated by the compiler over a web server. + const serverConfig = createDevServerConfig( + proxyConfig, + urls.lanUrlForConfig + ); + const devServer = new WebpackDevServer(compiler, serverConfig); + // Launch WebpackDevServer. + devServer.listen(port, HOST, err => { + if (err) { + return console.log(err); + } + if (isInteractive) { + clearConsole(); + } + + // We used to support resolving modules according to `NODE_PATH`. + // This now has been deprecated in favor of jsconfig/tsconfig.json + // This lets you use absolute paths in imports inside large monorepos: + if (process.env.NODE_PATH) { + console.log( + chalk.yellow( + 'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.' + ) + ); + console.log(); + } + + console.log(chalk.cyan('Starting the development server...\n')); + openBrowser(urls.localUrlForBrowser); + }); + + ['SIGINT', 'SIGTERM'].forEach(function(sig) { + process.on(sig, function() { + devServer.close(); + process.exit(); + }); + }); + + if (isInteractive || process.env.CI !== 'true') { + // Gracefully exit when stdin ends + process.stdin.on('end', function() { + devServer.close(); + process.exit(); + }); + process.stdin.resume(); + } + }) + .catch(err => { + if (err && err.message) { + console.log(err.message); + } + process.exit(1); + }); diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/test.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/test.js new file mode 100644 index 00000000..b57cb383 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/scripts/test.js @@ -0,0 +1,53 @@ +'use strict'; + +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'test'; +process.env.NODE_ENV = 'test'; +process.env.PUBLIC_URL = ''; + +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + +// Ensure environment variables are read. +require('../config/env'); + + +const jest = require('jest'); +const execSync = require('child_process').execSync; +let argv = process.argv.slice(2); + +function isInGitRepository() { + try { + execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' }); + return true; + } catch (e) { + return false; + } +} + +function isInMercurialRepository() { + try { + execSync('hg --cwd . root', { stdio: 'ignore' }); + return true; + } catch (e) { + return false; + } +} + +// Watch unless on CI or explicitly running all tests +if ( + !process.env.CI && + argv.indexOf('--watchAll') === -1 && + argv.indexOf('--watchAll=false') === -1 +) { + // https://github.com/facebook/create-react-app/issues/5210 + const hasSourceControl = isInGitRepository() || isInMercurialRepository(); + argv.push(hasSourceControl ? '--watch' : '--watchAll'); +} + + +jest.run(argv); diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/configuration/csr-extension.tsx b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/configuration/csr-extension.tsx new file mode 100644 index 00000000..b01497f3 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/configuration/csr-extension.tsx @@ -0,0 +1,4 @@ +import { setting } from './demo-setting'; +import { CSRExtension } from '@episerver/csr-extension'; + +CSRExtension.InitConfiguration(setting); diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/configuration/demo-setting.tsx b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/configuration/demo-setting.tsx new file mode 100644 index 00000000..314a2ff7 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/configuration/demo-setting.tsx @@ -0,0 +1,193 @@ +import * as React from 'react'; +import { AppSettingState, HttpRequest } from '@episerver/csr-extension'; +import { OrderDetailTab } from '../demo/class-component'; +import { ReactHookComponent } from '../demo/react-hook-component'; +import { ReduxContainerComponent } from '../demo/redux-container-component'; +import store from '../store'; +import * as ApplicationActions from '../store/actions'; +import { Provider } from 'react-redux'; + +const PlaceHolder: React.FunctionComponent = (props) => { + return
+ {props.children} +
+} + +export const setting = { + pageConfig: { + /** + * Config page at route '/orders' + */ + orderList: { + extendUI: { + /** + * Put component at the top of page + */ + topPlaceHolder: () => Orders Top Placeholder, + + /** + * Put component at the bottom of page + */ + bottomPlaceHolder: () => Orders Bottom Placeholder, + }, + }, + + /** + * Config page at route '/orders/:id' + */ + orderDetail: { + extendUI: { + topPlaceHolder: (props) => { + // Return function component. + return + }, + bottomPlaceHolder: (props) => { + HttpRequest.get('csr-demo/getData').then(resp => { + store.dispatch(ApplicationActions.setMessage(resp.data)); + }); + // You should config your own store provider when using Redux container component. + return + }, + }, + config: { + extraTabs: [ + { + title: 'Extra tab', + render: (props) => { + // Return class component + return + }, + }, + ], + }, + }, + + /** + * Config page at route '/createorder' + */ + createOrder: { + extendUI: { + topPlaceHolder: props => { + return + CreateOrder Top Placeholder. MarketId: {props.MarketId}, ContactId: {props.CustomerId} + + }, + bottomPlaceHolder: props => CreateOrder Bottom Placeholder, + }, + }, + + /** + * Config page at route '/carts' + */ + cartList: { + extendUI: { + topPlaceHolder: () => Carts Top Placeholder, + bottomPlaceHolder: () => Carts Bottom Placeholder, + }, + }, + + /** + * Config page at route '/carts/:id' + */ + cartDetail: { + extendUI: { + topPlaceHolder: (props) => CartDetail Top Placeholder: {props.Id}, + bottomPlaceHolder: (props) => CartDetail Bottom Placeholde: {props.Id}, + }, + config: { + extraTabs: [ + { + title: 'Extra tab', + render: (props) => { + return Tab content for cart: {props.Id}; + }, + }, + ], + }, + }, + + /** + * Config page at route '/createPaymentplan' + */ + createPaymentPlan: { + extendUI: { + topPlaceHolder: props => ( + + CreatePaymentPlan Top Placeholder. MarketId: {props.MarketId}, ContactId: {props.CustomerId} + + ), + bottomPlaceHolder: props => CreatePaymentPlan Bottom Placeholder, + }, + }, + + /** + * Config page at route '/paymentplans' + */ + paymentPlanList: { + extendUI: { + topPlaceHolder: () => PaymentPlans Top Placeholder, + bottomPlaceHolder: () => PaymentPlans Bottom Placeholder, + }, + }, + + /** + * Config page at route '/paymentplans/:id' + */ + paymentPlanDetail: { + extendUI: { + topPlaceHolder: (data) => PaymentPlanDetail Top Placeholder, + bottomPlaceHolder: (data) => PaymentPlanDetail Bottom Placeholder, + }, + config: { + extraTabs: [ + { + title: 'Extra tab', + render: (props) => { + return Tab content for paymentplan: {props.Id}; + }, + }, + ], + }, + }, + + /** + * Config page at route '/customers/:id' + */ + contactDetail: { + config: { + extraPages: [ + { + title: 'Extra page', + // link pattern, default path has prefix route /customers/{id}, you cannot change this prefix + path: '/extra-page', + exact: true, + getLink: () => { + return 'extra-page'; + }, + + /** + * Return JSX.Element + */ + render: (props) => { + return Extra page content for customer: {props.CustomerId}; + }, + }, + ], + }, + }, + + /** + * Register more routes + */ + extraPages: [ + { + path: '/demo-page', + exact: true, + render: () => { + return Demo page content; + }, + }, + ], + } +} as AppSettingState; + diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/class-component.tsx b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/class-component.tsx new file mode 100644 index 00000000..cb7d6d7b --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/class-component.tsx @@ -0,0 +1,32 @@ +import * as React from 'react'; +import { HttpRequest } from '@episerver/csr-extension'; + +interface OrderDetailProps { + Id: number +} + +export class OrderDetailTab extends React.Component { + state = { + message: '', + }; + + async componentDidMount() { + let message = (await this.getData()).data; + this.setState({ + message: message, + }); + } + + getData = async () => { + return await HttpRequest.get('csr-demo/getData'); + }; + + render() { + return ( +
+

Class component

+

Message from remote: {this.state.message}

+
+ ); + } +} \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/react-hook-component.tsx b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/react-hook-component.tsx new file mode 100644 index 00000000..2daf6c26 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/react-hook-component.tsx @@ -0,0 +1,11 @@ +import React, { useState } from 'react'; + +export const ReactHookComponent = () => { + const [message, setMessage] = useState(''); + + React.useEffect(() => { + setMessage('This is message.'); + }, [message]); + + return

React hook component: {message}

; +}; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/redux-container-component.tsx b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/redux-container-component.tsx new file mode 100644 index 00000000..60289ead --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/demo/redux-container-component.tsx @@ -0,0 +1,30 @@ +import * as React from 'react'; +import { StoreState } from '../store/index'; +import { connect } from 'react-redux'; + +interface Prop { + Id: number; + message?: string; +} + +const PlaceHolder = (props: Prop) => { + return ( +
+

Redux container component

+

Message: {props.message}

+
+ ); +}; + +interface ContainerProps { + Id: number; +} + +const mapStateToProps = (state: StoreState, ownProps: ContainerProps): Prop => { + return { + message: state.application.message, + Id: ownProps.Id + }; +}; + +export const ReduxContainerComponent = connect(mapStateToProps)(PlaceHolder); \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/index.tsx b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/index.tsx new file mode 100644 index 00000000..70f12cc7 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/index.tsx @@ -0,0 +1,13 @@ +import * as React from 'react'; +import ReactDOM from 'react-dom'; +import { CSRApp } from '@episerver/csr-app'; +import { setting } from './configuration/demo-setting'; + +import '@episerver/csr-app/bundle.css'; + +ReactDOM.render( +
+ +
, + document.getElementById('root') +); \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/react-app-env.d.ts b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/react-app-env.d.ts new file mode 100644 index 00000000..981cd734 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/react-app-env.d.ts @@ -0,0 +1,66 @@ +/// +/// +/// + +declare namespace NodeJS { + interface ProcessEnv { + readonly NODE_ENV: 'development' | 'production' | 'test'; + readonly PUBLIC_URL: string; + } +} + +declare module '*.bmp' { + const src: string; + export default src; +} + +declare module '*.gif' { + const src: string; + export default src; +} + +declare module '*.jpg' { + const src: string; + export default src; +} + +declare module '*.jpeg' { + const src: string; + export default src; +} + +declare module '*.png' { + const src: string; + export default src; +} + +declare module '*.webp' { + const src: string; + export default src; +} + +declare module '*.svg' { + import * as React from 'react'; + + export const ReactComponent: React.FunctionComponent & { title?: string }>; + + const src: string; + export default src; +} + +declare module '*.module.css' { + const classes: { readonly [key: string]: string }; + export default classes; +} + +declare module '*.module.scss' { + const classes: { readonly [key: string]: string }; + export default classes; +} + +declare module '*.module.sass' { + const classes: { readonly [key: string]: string }; + export default classes; +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/sample-table.tsx b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/sample-table.tsx new file mode 100644 index 00000000..81e1ccdb --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/sample-table.tsx @@ -0,0 +1,93 @@ +import React from 'react'; +import { useTable } from 'react-table'; + +function Table() { + const data = React.useMemo( + () => [ + { + col1: 'Hello', + col2: 'World', + }, + { + col1: 'react-table', + col2: 'rocks', + }, + { + col1: 'whatever', + col2: 'you want', + }, + ], + [] + ); + + const columns = React.useMemo( + () => [ + { + Header: 'Column 1', + col1: 'col1', // accessor is the "key" in the data + }, + { + Header: 'Column 2', + col2: 'col2', + }, + ], + [] + ); + + const { + getTableProps, + getTableBodyProps, + headerGroups, + rows, + prepareRow, + } = useTable({ columns, data }); + + return ( + + + {headerGroups.map((headerGroup) => ( + + {headerGroup.headers.map((column) => ( + + ))} + + ))} + + + {rows.map((row) => { + prepareRow(row); + return ( + + {row.cells.map((cell) => { + return ( + + ); + })} + + ); + })} + +
+ {column.render('Header')} +
+ {cell.render('Cell')} +
+ ); +} + +export default Table; \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/setupProxy.js b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/setupProxy.js new file mode 100644 index 00000000..84cbb265 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/setupProxy.js @@ -0,0 +1,52 @@ +const qs = require('qs'); +const axios = require('axios'); +const { createProxyMiddleware } = require('http-proxy-middleware'); +const baseURL = "http://commerceref/"; +const getCommerceAuthToken = () => { + const url = baseURL + 'token'; + + const requestConfig = { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + } + }; + + const params = { + grant_type: 'password', + username: 'admin@example.com', + password: 'store' + }; + + return axios.post(url, qs.stringify(params), requestConfig); +}; + +module.exports = function(app) { + getCommerceAuthToken().then(response => { + const commerceAuthToken = response.data.access_token; + + app.use('/api', createProxyMiddleware({ + target: baseURL + "episerver/Commerce/", + changeOrigin: true, + headers: { + "Authorization": `Bearer ${commerceAuthToken}` + } + })); + + app.use('/api-extension', createProxyMiddleware({ + target: baseURL + "episerver/Commerce/", + changeOrigin: true, + headers: { + "Authorization": `Bearer ${commerceAuthToken}` + } + })); + + app.use('/globalassets', createProxyMiddleware({ + target: baseURL, + changeOrigin: true, + headers: { + "Authorization": `Bearer ${commerceAuthToken}` + } + })); + }) +}; + diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/actions.ts b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/actions.ts new file mode 100644 index 00000000..9517b68f --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/actions.ts @@ -0,0 +1,17 @@ +export function setMessage(message: string) { + return { + type: 'SET_MESSAGE', + message, + } as const; +} + +export function setData(data: any) { + return { + type: 'SET_DATA', + payload: data, + } as const; +} + +export type ApplicationActionType = +| ReturnType +| ReturnType; diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/index.ts b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/index.ts new file mode 100644 index 00000000..4c802d5f --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/index.ts @@ -0,0 +1,23 @@ +import { combineReducers, createStore } from "redux"; + +import applicationReducer from './reducer'; +import { ApplicationState } from './state'; + +export interface StoreState { + application: ApplicationState; +} + +export const InitialState: StoreState = { + application: { + message: '', + data: null, + } +}; + +export const rootReducer = combineReducers({ + application: applicationReducer +}); + +const store = createStore(rootReducer, InitialState); + +export default store; \ No newline at end of file diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/reducer.ts b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/reducer.ts new file mode 100644 index 00000000..ef3c1dec --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/reducer.ts @@ -0,0 +1,25 @@ +import * as Actions from './actions'; +import { ApplicationState } from './state'; +import { InitialState } from './index'; + +export default function applicationReducer( + state: ApplicationState = InitialState.application, + action: Actions.ApplicationActionType +): ApplicationState { + switch (action.type) { + case 'SET_MESSAGE': + return { + ...state, + message: action.message + }; + + case 'SET_DATA': + return { + ...state, + data: action.payload + } + + default: + return state; + } +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/state.ts b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/state.ts new file mode 100644 index 00000000..4dc806f8 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/src/store/state.ts @@ -0,0 +1,5 @@ + +export interface ApplicationState { + message: string; + data: any; +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/tsconfig.json b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/tsconfig.json new file mode 100644 index 00000000..4dc65a19 --- /dev/null +++ b/Sources/EPiServer.Reference.Commerce.Site/CSRExtensibility/react-app/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react", + "noImplicitAny": false + }, + "include": [ + "src" + ] +} diff --git a/Sources/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj b/Sources/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj index 5bdbc48e..291ecec7 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj +++ b/Sources/EPiServer.Reference.Commerce.Site/EPiServer.Reference.Commerce.Site.csproj @@ -1,5 +1,6 @@ + Debug @@ -22,6 +23,8 @@ + 3.6 + true true @@ -340,6 +343,28 @@
+ + + + + + + + + + + + + + + + + + + + + + @@ -383,6 +408,8 @@ AssemblyVersionAuto.cs + + @@ -812,6 +839,13 @@ + + + + + + + Designer @@ -953,7 +987,27 @@ EPiServer.Reference.Commerce.Shared - + + + + + + + + + + + + + + + + + + + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) @@ -991,6 +1045,7 @@ true + @@ -1030,107 +1085,107 @@ - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Business.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Business.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Commerce.Internal.Migration.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.BusinessFoundation.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.BusinessFoundation.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.BusinessFoundation.Data.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.BusinessFoundation.Data.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Marketing.Validators.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Plugins.Payment.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Plugins.Shipping.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Website.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Website.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Commerce.Workflow.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Commerce.Workflow.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.DataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.DataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.FileUploader.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.FileUploader.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.MetaDataPlus.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.MetaDataPlus.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.Extensions.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.Extensions.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.Search.LuceneSearchProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.SqlDataProvider.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.SqlDataProvider.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\Mediachase.WebConsoleLib.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\Mediachase.WebConsoleLib.dll True - ..\..\packages\EPiServer.Commerce.UI.13.22.0\lib\net461\EPiServer.Commerce.Shell.dll + ..\..\packages\EPiServer.Commerce.UI.13.26.0\lib\net461\EPiServer.Commerce.Shell.dll True - ..\..\packages\EPiServer.Commerce.UI.ManagerIntegration.13.22.0\lib\net461\EPiServer.Commerce.Shell.ManagerIntegration.dll + ..\..\packages\EPiServer.Commerce.UI.ManagerIntegration.13.26.0\lib\net461\EPiServer.Commerce.Shell.ManagerIntegration.dll True - ..\..\packages\EPiServer.Commerce.UI.13.22.0\lib\net461\EPiServer.Commerce.UI.dll + ..\..\packages\EPiServer.Commerce.UI.13.26.0\lib\net461\EPiServer.Commerce.UI.dll True - ..\..\packages\EPiServer.Commerce.UI.CustomerService.13.22.0\lib\net461\EPiServer.Commerce.UI.CustomerService.dll + ..\..\packages\EPiServer.Commerce.UI.CustomerService.13.26.0\lib\net461\EPiServer.Commerce.UI.CustomerService.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\EPiServer.Commerce.Reporting.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\EPiServer.Commerce.Reporting.dll True - ..\..\packages\EPiServer.Tracking.Commerce.3.2.18\lib\net461\EPiServer.Tracking.Commerce.dll + ..\..\packages\EPiServer.Tracking.Commerce.3.2.23\lib\net461\EPiServer.Tracking.Commerce.dll True - ..\..\packages\EPiServer.Personalization.Commerce.3.2.18\lib\net461\EPiServer.Personalization.Commerce.dll + ..\..\packages\EPiServer.Personalization.Commerce.3.2.23\lib\net461\EPiServer.Personalization.Commerce.dll True - ..\..\packages\EPiServer.Commerce.Core.13.22.0\lib\net461\AjaxControlToolkit.dll + ..\..\packages\EPiServer.Commerce.Core.13.26.0\lib\net461\AjaxControlToolkit.dll True diff --git a/Sources/EPiServer.Reference.Commerce.Site/Styles/style.css b/Sources/EPiServer.Reference.Commerce.Site/Styles/style.css index 4c690803..df96148d 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Styles/style.css +++ b/Sources/EPiServer.Reference.Commerce.Site/Styles/style.css @@ -9255,37 +9255,37 @@ fieldset[disabled] .btn-yahoo.active { font-family: 'Arapey'; font-style: italic; font-weight: 400; - src: local('Arapey Italic'), local('Arapey-Italic'), url(http://fonts.gstatic.com/s/arapey/v8/-W_9XJn-UDDA2RCKZeofTkM.ttf) format('truetype'); + src: local('Arapey Italic'), local('Arapey-Italic'), url(http://fonts.gstatic.com/s/arapey/v9/-W_9XJn-UDDA2RCKZeofTkM.ttf) format('truetype'); } @font-face { font-family: 'Arapey'; font-style: normal; font-weight: 400; - src: local('Arapey Regular'), local('Arapey-Regular'), url(http://fonts.gstatic.com/s/arapey/v8/-W__XJn-UDDA2RCKYNoY.ttf) format('truetype'); + src: local('Arapey Regular'), local('Arapey-Regular'), url(http://fonts.gstatic.com/s/arapey/v9/-W__XJn-UDDA2RCKYNoY.ttf) format('truetype'); } @font-face { font-family: 'Cookie'; font-style: normal; font-weight: 400; - src: local('Cookie-Regular'), url(http://fonts.gstatic.com/s/cookie/v11/syky-y18lb0tSbf9kgqX.ttf) format('truetype'); + src: local('Cookie-Regular'), url(http://fonts.gstatic.com/s/cookie/v12/syky-y18lb0tSbf9kgqX.ttf) format('truetype'); } @font-face { font-family: 'Raleway'; font-style: normal; font-weight: 400; - src: url(http://fonts.gstatic.com/s/raleway/v17/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCIPrQ.ttf) format('truetype'); + src: url(http://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvaorCIPrQ.ttf) format('truetype'); } @font-face { font-family: 'Raleway'; font-style: normal; font-weight: 500; - src: url(http://fonts.gstatic.com/s/raleway/v17/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvoorCIPrQ.ttf) format('truetype'); + src: url(http://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVvoorCIPrQ.ttf) format('truetype'); } @font-face { font-family: 'Raleway'; font-style: normal; font-weight: 700; - src: url(http://fonts.gstatic.com/s/raleway/v17/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVs9pbCIPrQ.ttf) format('truetype'); + src: url(http://fonts.gstatic.com/s/raleway/v18/1Ptxg8zYS_SKggPN4iEgvnHyvveLxVs9pbCIPrQ.ttf) format('truetype'); } html { min-height: 100%; diff --git a/Sources/EPiServer.Reference.Commerce.Site/Web.config b/Sources/EPiServer.Reference.Commerce.Site/Web.config index 808ec6b1..97c37a6a 100644 --- a/Sources/EPiServer.Reference.Commerce.Site/Web.config +++ b/Sources/EPiServer.Reference.Commerce.Site/Web.config @@ -249,95 +249,95 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -628,7 +628,7 @@ - + @@ -644,7 +644,7 @@ - +