@riosst100/pwa-marketplace 1.2.7 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Utilities/graphQL.js +76 -76
- package/src/componentOverrideMapping.js +17 -17
- package/src/components/BecomeSeller/becomeSeller.js +335 -335
- package/src/components/BecomeSeller/becomeSeller.module.css +46 -46
- package/src/components/BecomeSellerLink/becomeSellerLink.js +52 -52
- package/src/components/BecomeSellerLink/becomeSellerLink.module.css +12 -12
- package/src/components/BecomeSellerPage/becomeSellerPage.js +45 -45
- package/src/components/BecomeSellerPage/becomeSellerPage.module.css +21 -21
- package/src/components/Filter/index.js +53 -53
- package/src/components/Header/becomeSellerLink.js +28 -28
- package/src/components/Header/becomeSellerLink.module.css +12 -12
- package/src/components/Header/websiteSwitcher.js +109 -109
- package/src/components/OperatingHours/index.js +1 -0
- package/src/components/OperatingHours/operatingHours.js +35 -0
- package/src/components/Pagination/index.js +49 -49
- package/src/components/PhoneTextInput/phoneTextInput.module.css +21 -21
- package/src/components/ProductItem/index.js +50 -50
- package/src/components/Search/index.js +16 -16
- package/src/components/Seller/index.js +1 -1
- package/src/components/Seller/seller.js +42 -249
- package/src/components/Seller/sellerAddressCard.js +48 -0
- package/src/components/SellerAccountPage/sellerAccountPage.js +110 -110
- package/src/components/SellerAccountPage/sellerAccountPage.module.css +55 -55
- package/src/components/SellerCountry/sellerCountry.gql.js +11 -11
- package/src/components/SellerDetail/index.js +1 -0
- package/src/components/SellerDetail/sellerDetail.js +166 -0
- package/src/components/SellerInformation/index.js +1 -1
- package/src/components/SellerInformation/sellerInformation.js +86 -90
- package/src/components/SellerLocation/index.js +1 -1
- package/src/components/SellerLocation/sellerLocation.js +19 -19
- package/src/components/SellerLocation/sellerLocationItem.js +27 -27
- package/src/components/SellerPage/sellerPage.js +9 -9
- package/src/components/SellerProducts/sellerProducts.js +46 -46
- package/src/components/SellerReview/index.js +1 -1
- package/src/components/SellerReview/sellerReview.js +143 -143
- package/src/components/SellerReviewItem/sellerReviewItem.js +60 -60
- package/src/components/SellerVerification/sellerVerification.js +198 -198
- package/src/components/SellerVerification/sellerVerification.module.css +47 -47
- package/src/components/SellerVerificationPage/sellerVerificationPage.js +43 -43
- package/src/components/SellerVerificationPage/sellerVerificationPage.module.css +21 -21
- package/src/components/SortBy/index.js +24 -24
- package/src/components/WebsiteSwitcher/websiteSwitcher.js +109 -109
- package/src/components/commons/Slider/index.js +13 -13
- package/src/components/commons/Tabs/index.js +64 -64
- package/src/index.js +6 -6
- package/src/intercept.js +113 -113
- package/src/moduleOverrideWebpackPlugin.js +70 -70
- package/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js +96 -96
- package/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js +74 -74
- package/src/overwrites/peregrine/lib/talons/Adapter/useAdapter.js +208 -208
- package/src/overwrites/peregrine/lib/talons/Header/storeSwitcher.gql.js +45 -45
- package/src/overwrites/peregrine/lib/talons/Header/useStoreSwitcher.js +204 -204
- package/src/overwrites/peregrine/lib/talons/Region/useRegion.js +102 -102
- package/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js +56 -56
- package/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js +226 -226
- package/src/overwrites/peregrine/lib/util/deriveErrorMessage.js +34 -34
- package/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql +11 -11
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +112 -112
- package/src/overwrites/venia-ui/lib/components/Header/header.js +130 -130
- package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +105 -105
- package/src/overwrites/venia-ui/lib/components/Header/switcherItem.js +47 -47
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -91
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -123
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -61
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -50
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -114
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -71
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -59
- package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -34
- package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -1
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -90
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -12
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -156
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +30 -30
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -89
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +42 -42
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -99
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -28
- package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -11
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -72
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -30
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -69
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -7
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -12
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -52
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -82
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -87
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -45
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -43
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -45
- package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -110
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -172
- package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -62
- package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -1
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -74
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +49 -49
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -40
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -48
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -13
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -49
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -97
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -24
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -43
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -13
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -75
- package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -6
- package/src/overwrites/venia-ui/lib/components/StoreCodeRoute/storeCodeRoute.js +75 -75
- package/src/overwrites/venia-ui/lib/targets/venia-ui-intercept.js +70 -70
- package/src/queries/getAvailableWebsitesConfigData.graphql +14 -14
- package/src/queries/index.js +30 -30
- package/src/talons/BecomeSeller/becomeSeller.gql.js +45 -45
- package/src/talons/BecomeSeller/useBecomeSeller.js +145 -145
- package/src/talons/BecomeSellerLink/useBecomeSellerLink.js +11 -11
- package/src/talons/BecomeSellerPage/useBecomeSellerPage.js +76 -76
- package/src/talons/Header/useBecomeSellerLink.js +13 -13
- package/src/talons/Header/useWebsiteSwitcher.js +218 -218
- package/src/talons/Seller/seller.gql.js +204 -139
- package/src/talons/Seller/useSeller.js +71 -66
- package/src/talons/SellerAccountPage/useSellerAccountPage.js +174 -174
- package/src/talons/SellerCountry/useSellerCountry.js +25 -25
- package/src/talons/WebsiteByIp/getWebsiteByIp.gql.js +13 -13
- package/src/talons/WebsiteByIp/useWebsiteByIp.js +34 -34
- package/src/talons/WebsiteSwitcher/useWebsiteSwitcher.js +218 -218
- package/src/theme/vars.js +6 -6
- package/src/util/mapSeller.js +7 -7
package/src/intercept.js
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
const componentOverrideMapping = require('./componentOverrideMapping');
|
|
2
|
-
const moduleOverridePlugin = require('./moduleOverrideWebpackPlugin');
|
|
3
|
-
const { DefinePlugin } = require('webpack');
|
|
4
|
-
const { getAvailableWebsitesConfigData } = require('./Utilities/graphQL');
|
|
5
|
-
const LocalizationPlugin = require('@magento/pwa-buildpack/lib/WebpackTools/plugins/LocalizationPlugin');
|
|
6
|
-
|
|
7
|
-
module.exports = targets => {
|
|
8
|
-
// Perform the asynchronous operation outside the tap
|
|
9
|
-
let availableWebsites;
|
|
10
|
-
|
|
11
|
-
// Use an IIFE (Immediately Invoked Function Expression) to enable async/await
|
|
12
|
-
(async () => {
|
|
13
|
-
availableWebsites = await getAvailableWebsitesConfigData();
|
|
14
|
-
})();
|
|
15
|
-
|
|
16
|
-
targets.of('@magento/pwa-buildpack').specialFeatures.tap(features => {
|
|
17
|
-
features[targets.name] = { i18n: true, esModules: true, cssModules: true, graphqlQueries: true };
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
targets.of('@magento/pwa-buildpack').webpackCompiler.tap(compiler => {
|
|
21
|
-
new moduleOverridePlugin(componentOverrideMapping).apply(compiler);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Tap into webpackCompiler
|
|
25
|
-
targets.of('@magento/pwa-buildpack').webpackCompiler.tap(compiler => {
|
|
26
|
-
// Check if the LocalizationPlugin is present
|
|
27
|
-
if (compiler.options.plugins) {
|
|
28
|
-
const localizationPlugin = compiler.options.plugins.find(
|
|
29
|
-
plugin => plugin instanceof LocalizationPlugin
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
// Check if LocalizationPlugin is found
|
|
33
|
-
if (localizationPlugin) {
|
|
34
|
-
// Store the original mergeLocales function
|
|
35
|
-
const originalMergeLocales = localizationPlugin.mergeLocales;
|
|
36
|
-
|
|
37
|
-
// Define your custom hook
|
|
38
|
-
function myCustomMergeLocalesHook(current, update) {
|
|
39
|
-
// Modify the mergedLocales data here
|
|
40
|
-
Object.keys(update).forEach(key => {
|
|
41
|
-
if (typeof current[key] === 'undefined') {
|
|
42
|
-
current[key] = [];
|
|
43
|
-
}
|
|
44
|
-
if (Array.isArray(current[key]) && Array.isArray(update[key])) {
|
|
45
|
-
if (update[key].toString().includes("venia-ui")) {
|
|
46
|
-
delete update[key];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Return the modified mergedLocales
|
|
52
|
-
return originalMergeLocales.call(localizationPlugin, current, update);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Override mergeLocales with your custom hook
|
|
56
|
-
localizationPlugin.mergeLocales = myCustomMergeLocalesHook;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
targets.of('@magento/pwa-buildpack').envVarDefinitions.tap(defs => {
|
|
62
|
-
defs.sections.push({
|
|
63
|
-
name: "Default Website Code",
|
|
64
|
-
variables: [
|
|
65
|
-
{
|
|
66
|
-
name: "WEBSITE_CODE",
|
|
67
|
-
type: "str",
|
|
68
|
-
desc: "Default Website Code for Multi Website Extension",
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Define the routes using the results of the asynchronous operation
|
|
75
|
-
const routes = [
|
|
76
|
-
{
|
|
77
|
-
exact: true,
|
|
78
|
-
name: "BecomeSellerRoute",
|
|
79
|
-
pattern: "/become-seller",
|
|
80
|
-
path: require.resolve("./components/BecomeSellerPage/index.js"),
|
|
81
|
-
authed: true,
|
|
82
|
-
redirectTo: "/sign-in"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
exact: true,
|
|
86
|
-
name: "SellerAccountRoute",
|
|
87
|
-
pattern: "/seller-account",
|
|
88
|
-
path: require.resolve("./components/SellerAccountPage/index.js"),
|
|
89
|
-
authed: true,
|
|
90
|
-
redirectTo: "/become-seller"
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
exact: true,
|
|
94
|
-
name: "SellerPage",
|
|
95
|
-
pattern: "/seller/:urlKey",
|
|
96
|
-
path: require.resolve("./components/SellerPage/index.js"),
|
|
97
|
-
authed: false,
|
|
98
|
-
},
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
// Apply DefinePlugin using the results of the asynchronous operation
|
|
102
|
-
targets.of('@magento/pwa-buildpack').webpackCompiler.tap(compiler => {
|
|
103
|
-
new DefinePlugin({
|
|
104
|
-
AVAILABLE_WEBSITES: JSON.stringify(availableWebsites.availableStoresByUserIp),
|
|
105
|
-
WEBSITE_CODE: process.env.WEBSITE_CODE
|
|
106
|
-
}).apply(compiler);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Handle the routes directly within the routes tap
|
|
110
|
-
targets.of("@magento/venia-ui").routes.tap(routesArray => {
|
|
111
|
-
routesArray.push(...routes);
|
|
112
|
-
return routesArray;
|
|
113
|
-
});
|
|
1
|
+
const componentOverrideMapping = require('./componentOverrideMapping');
|
|
2
|
+
const moduleOverridePlugin = require('./moduleOverrideWebpackPlugin');
|
|
3
|
+
const { DefinePlugin } = require('webpack');
|
|
4
|
+
const { getAvailableWebsitesConfigData } = require('./Utilities/graphQL');
|
|
5
|
+
const LocalizationPlugin = require('@magento/pwa-buildpack/lib/WebpackTools/plugins/LocalizationPlugin');
|
|
6
|
+
|
|
7
|
+
module.exports = targets => {
|
|
8
|
+
// Perform the asynchronous operation outside the tap
|
|
9
|
+
let availableWebsites;
|
|
10
|
+
|
|
11
|
+
// Use an IIFE (Immediately Invoked Function Expression) to enable async/await
|
|
12
|
+
(async () => {
|
|
13
|
+
availableWebsites = await getAvailableWebsitesConfigData();
|
|
14
|
+
})();
|
|
15
|
+
|
|
16
|
+
targets.of('@magento/pwa-buildpack').specialFeatures.tap(features => {
|
|
17
|
+
features[targets.name] = { i18n: true, esModules: true, cssModules: true, graphqlQueries: true };
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
targets.of('@magento/pwa-buildpack').webpackCompiler.tap(compiler => {
|
|
21
|
+
new moduleOverridePlugin(componentOverrideMapping).apply(compiler);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Tap into webpackCompiler
|
|
25
|
+
targets.of('@magento/pwa-buildpack').webpackCompiler.tap(compiler => {
|
|
26
|
+
// Check if the LocalizationPlugin is present
|
|
27
|
+
if (compiler.options.plugins) {
|
|
28
|
+
const localizationPlugin = compiler.options.plugins.find(
|
|
29
|
+
plugin => plugin instanceof LocalizationPlugin
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Check if LocalizationPlugin is found
|
|
33
|
+
if (localizationPlugin) {
|
|
34
|
+
// Store the original mergeLocales function
|
|
35
|
+
const originalMergeLocales = localizationPlugin.mergeLocales;
|
|
36
|
+
|
|
37
|
+
// Define your custom hook
|
|
38
|
+
function myCustomMergeLocalesHook(current, update) {
|
|
39
|
+
// Modify the mergedLocales data here
|
|
40
|
+
Object.keys(update).forEach(key => {
|
|
41
|
+
if (typeof current[key] === 'undefined') {
|
|
42
|
+
current[key] = [];
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(current[key]) && Array.isArray(update[key])) {
|
|
45
|
+
if (update[key].toString().includes("venia-ui")) {
|
|
46
|
+
delete update[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Return the modified mergedLocales
|
|
52
|
+
return originalMergeLocales.call(localizationPlugin, current, update);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Override mergeLocales with your custom hook
|
|
56
|
+
localizationPlugin.mergeLocales = myCustomMergeLocalesHook;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
targets.of('@magento/pwa-buildpack').envVarDefinitions.tap(defs => {
|
|
62
|
+
defs.sections.push({
|
|
63
|
+
name: "Default Website Code",
|
|
64
|
+
variables: [
|
|
65
|
+
{
|
|
66
|
+
name: "WEBSITE_CODE",
|
|
67
|
+
type: "str",
|
|
68
|
+
desc: "Default Website Code for Multi Website Extension",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Define the routes using the results of the asynchronous operation
|
|
75
|
+
const routes = [
|
|
76
|
+
{
|
|
77
|
+
exact: true,
|
|
78
|
+
name: "BecomeSellerRoute",
|
|
79
|
+
pattern: "/become-seller",
|
|
80
|
+
path: require.resolve("./components/BecomeSellerPage/index.js"),
|
|
81
|
+
authed: true,
|
|
82
|
+
redirectTo: "/sign-in"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
exact: true,
|
|
86
|
+
name: "SellerAccountRoute",
|
|
87
|
+
pattern: "/seller-account",
|
|
88
|
+
path: require.resolve("./components/SellerAccountPage/index.js"),
|
|
89
|
+
authed: true,
|
|
90
|
+
redirectTo: "/become-seller"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
exact: true,
|
|
94
|
+
name: "SellerPage",
|
|
95
|
+
pattern: "/seller/:urlKey",
|
|
96
|
+
path: require.resolve("./components/SellerPage/index.js"),
|
|
97
|
+
authed: false,
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
// Apply DefinePlugin using the results of the asynchronous operation
|
|
102
|
+
targets.of('@magento/pwa-buildpack').webpackCompiler.tap(compiler => {
|
|
103
|
+
new DefinePlugin({
|
|
104
|
+
AVAILABLE_WEBSITES: JSON.stringify(availableWebsites.availableStoresByUserIp),
|
|
105
|
+
WEBSITE_CODE: process.env.WEBSITE_CODE
|
|
106
|
+
}).apply(compiler);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Handle the routes directly within the routes tap
|
|
110
|
+
targets.of("@magento/venia-ui").routes.tap(routesArray => {
|
|
111
|
+
routesArray.push(...routes);
|
|
112
|
+
return routesArray;
|
|
113
|
+
});
|
|
114
114
|
};
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const glob = require('glob');
|
|
3
|
-
|
|
4
|
-
module.exports = class NormalModuleOverridePlugin {
|
|
5
|
-
constructor(moduleOverrideMap) {
|
|
6
|
-
this.name = 'NormalModuleOverridePlugin';
|
|
7
|
-
this.moduleOverrideMap = moduleOverrideMap;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
requireResolveIfCan(id, options = undefined) {
|
|
11
|
-
try {
|
|
12
|
-
return require.resolve(id, options);
|
|
13
|
-
} catch (e) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
resolveModulePath(context, request) {
|
|
18
|
-
const filePathWithoutExtension = path.resolve(context, request);
|
|
19
|
-
const files = glob.sync(`${filePathWithoutExtension}@(|.*)`);
|
|
20
|
-
if (files.length === 0) {
|
|
21
|
-
throw new Error(`There is no file '${filePathWithoutExtension}'`);
|
|
22
|
-
}
|
|
23
|
-
if (files.length > 1) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
`There is more than one file '${filePathWithoutExtension}'`
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return require.resolve(files[0]);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
resolveModuleOverrideMap(context, map) {
|
|
33
|
-
return Object.keys(map).reduce(
|
|
34
|
-
(result, x) => ({
|
|
35
|
-
...result,
|
|
36
|
-
[require.resolve(x)]:
|
|
37
|
-
this.requireResolveIfCan(map[x]) ||
|
|
38
|
-
this.resolveModulePath(context, map[x]),
|
|
39
|
-
}),
|
|
40
|
-
{}
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
apply(compiler) {
|
|
45
|
-
if (Object.keys(this.moduleOverrideMap).length === 0) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const moduleMap = this.resolveModuleOverrideMap(
|
|
50
|
-
compiler.context,
|
|
51
|
-
this.moduleOverrideMap
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
compiler.hooks.normalModuleFactory.tap(this.name, (nmf) => {
|
|
55
|
-
nmf.hooks.beforeResolve.tap(this.name, (resolve) => {
|
|
56
|
-
if (!resolve) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const moduleToReplace = this.requireResolveIfCan(resolve.request, {
|
|
61
|
-
paths: [resolve.context],
|
|
62
|
-
});
|
|
63
|
-
if (moduleToReplace && moduleMap[moduleToReplace]) {
|
|
64
|
-
resolve.request = moduleMap[moduleToReplace];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return resolve;
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const glob = require('glob');
|
|
3
|
+
|
|
4
|
+
module.exports = class NormalModuleOverridePlugin {
|
|
5
|
+
constructor(moduleOverrideMap) {
|
|
6
|
+
this.name = 'NormalModuleOverridePlugin';
|
|
7
|
+
this.moduleOverrideMap = moduleOverrideMap;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
requireResolveIfCan(id, options = undefined) {
|
|
11
|
+
try {
|
|
12
|
+
return require.resolve(id, options);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
resolveModulePath(context, request) {
|
|
18
|
+
const filePathWithoutExtension = path.resolve(context, request);
|
|
19
|
+
const files = glob.sync(`${filePathWithoutExtension}@(|.*)`);
|
|
20
|
+
if (files.length === 0) {
|
|
21
|
+
throw new Error(`There is no file '${filePathWithoutExtension}'`);
|
|
22
|
+
}
|
|
23
|
+
if (files.length > 1) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`There is more than one file '${filePathWithoutExtension}'`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return require.resolve(files[0]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
resolveModuleOverrideMap(context, map) {
|
|
33
|
+
return Object.keys(map).reduce(
|
|
34
|
+
(result, x) => ({
|
|
35
|
+
...result,
|
|
36
|
+
[require.resolve(x)]:
|
|
37
|
+
this.requireResolveIfCan(map[x]) ||
|
|
38
|
+
this.resolveModulePath(context, map[x]),
|
|
39
|
+
}),
|
|
40
|
+
{}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
apply(compiler) {
|
|
45
|
+
if (Object.keys(this.moduleOverrideMap).length === 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const moduleMap = this.resolveModuleOverrideMap(
|
|
50
|
+
compiler.context,
|
|
51
|
+
this.moduleOverrideMap
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
compiler.hooks.normalModuleFactory.tap(this.name, (nmf) => {
|
|
55
|
+
nmf.hooks.beforeResolve.tap(this.name, (resolve) => {
|
|
56
|
+
if (!resolve) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const moduleToReplace = this.requireResolveIfCan(resolve.request, {
|
|
61
|
+
paths: [resolve.context],
|
|
62
|
+
});
|
|
63
|
+
if (moduleToReplace && moduleMap[moduleToReplace]) {
|
|
64
|
+
resolve.request = moduleMap[moduleToReplace];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return resolve;
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
71
|
};
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import BrowserPersistence from '@magento/peregrine/lib/util/simplePersistence';
|
|
2
|
-
import { removeCart } from '@magento/peregrine/lib/store/actions/cart';
|
|
3
|
-
import { clearCheckoutDataFromStorage } from '@magento/peregrine/lib/store/actions/checkout';
|
|
4
|
-
|
|
5
|
-
import actions from '@magento/peregrine/lib/store/actions/user/actions';
|
|
6
|
-
|
|
7
|
-
const storage = new BrowserPersistence();
|
|
8
|
-
|
|
9
|
-
export const signOut = (payload = {}) =>
|
|
10
|
-
async function thunk(dispatch, getState, { apolloClient }) {
|
|
11
|
-
const { revokeToken } = payload;
|
|
12
|
-
|
|
13
|
-
if (revokeToken) {
|
|
14
|
-
// Send mutation to revoke token.
|
|
15
|
-
try {
|
|
16
|
-
await revokeToken();
|
|
17
|
-
} catch (error) {
|
|
18
|
-
console.error('Error Revoking Token', error);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Remove token from local storage and Redux.
|
|
23
|
-
await dispatch(clearToken());
|
|
24
|
-
await dispatch(actions.reset());
|
|
25
|
-
await clearCheckoutDataFromStorage();
|
|
26
|
-
await apolloClient.clearCacheData(apolloClient, 'cart');
|
|
27
|
-
await apolloClient.clearCacheData(apolloClient, 'customer');
|
|
28
|
-
|
|
29
|
-
// Now that we're signed out, forget the old (customer) cart.
|
|
30
|
-
// We don't need to create a new cart here because we're going to refresh
|
|
31
|
-
// the page immediately after.
|
|
32
|
-
await dispatch(removeCart());
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const getUserDetails = ({ fetchUserDetails }) =>
|
|
36
|
-
async function thunk(...args) {
|
|
37
|
-
const [dispatch, getState] = args;
|
|
38
|
-
const { user } = getState();
|
|
39
|
-
|
|
40
|
-
if (user.isSignedIn) {
|
|
41
|
-
dispatch(actions.getDetails.request());
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const { data } = await fetchUserDetails();
|
|
45
|
-
|
|
46
|
-
if (data.customer) {
|
|
47
|
-
const isSeller = data.customer.is_seller;
|
|
48
|
-
if (isSeller) {
|
|
49
|
-
storage.setItem('is_seller', true);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
dispatch(actions.getDetails.receive(data.customer));
|
|
54
|
-
} catch (error) {
|
|
55
|
-
dispatch(actions.getDetails.receive(error));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const resetPassword = ({ email }) =>
|
|
61
|
-
async function thunk(...args) {
|
|
62
|
-
const [dispatch] = args;
|
|
63
|
-
|
|
64
|
-
dispatch(actions.resetPassword.request());
|
|
65
|
-
|
|
66
|
-
// TODO: actually make the call to the API.
|
|
67
|
-
// For now, just return a resolved promise.
|
|
68
|
-
await Promise.resolve(email);
|
|
69
|
-
|
|
70
|
-
dispatch(actions.resetPassword.receive());
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const setToken = token =>
|
|
74
|
-
async function thunk(...args) {
|
|
75
|
-
const [dispatch] = args;
|
|
76
|
-
|
|
77
|
-
// Store token in local storage.
|
|
78
|
-
// TODO: Get correct token expire time from API
|
|
79
|
-
storage.setItem('signin_token', token, 3600);
|
|
80
|
-
|
|
81
|
-
// Persist in store
|
|
82
|
-
dispatch(actions.setToken(token));
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const clearToken = () =>
|
|
86
|
-
async function thunk(...args) {
|
|
87
|
-
const [dispatch] = args;
|
|
88
|
-
|
|
89
|
-
// Clear token from local storage
|
|
90
|
-
storage.removeItem('signin_token');
|
|
91
|
-
|
|
92
|
-
storage.removeItem('is_seller');
|
|
93
|
-
|
|
94
|
-
// Remove from store
|
|
95
|
-
dispatch(actions.clearToken());
|
|
96
|
-
};
|
|
1
|
+
import BrowserPersistence from '@magento/peregrine/lib/util/simplePersistence';
|
|
2
|
+
import { removeCart } from '@magento/peregrine/lib/store/actions/cart';
|
|
3
|
+
import { clearCheckoutDataFromStorage } from '@magento/peregrine/lib/store/actions/checkout';
|
|
4
|
+
|
|
5
|
+
import actions from '@magento/peregrine/lib/store/actions/user/actions';
|
|
6
|
+
|
|
7
|
+
const storage = new BrowserPersistence();
|
|
8
|
+
|
|
9
|
+
export const signOut = (payload = {}) =>
|
|
10
|
+
async function thunk(dispatch, getState, { apolloClient }) {
|
|
11
|
+
const { revokeToken } = payload;
|
|
12
|
+
|
|
13
|
+
if (revokeToken) {
|
|
14
|
+
// Send mutation to revoke token.
|
|
15
|
+
try {
|
|
16
|
+
await revokeToken();
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error Revoking Token', error);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Remove token from local storage and Redux.
|
|
23
|
+
await dispatch(clearToken());
|
|
24
|
+
await dispatch(actions.reset());
|
|
25
|
+
await clearCheckoutDataFromStorage();
|
|
26
|
+
await apolloClient.clearCacheData(apolloClient, 'cart');
|
|
27
|
+
await apolloClient.clearCacheData(apolloClient, 'customer');
|
|
28
|
+
|
|
29
|
+
// Now that we're signed out, forget the old (customer) cart.
|
|
30
|
+
// We don't need to create a new cart here because we're going to refresh
|
|
31
|
+
// the page immediately after.
|
|
32
|
+
await dispatch(removeCart());
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const getUserDetails = ({ fetchUserDetails }) =>
|
|
36
|
+
async function thunk(...args) {
|
|
37
|
+
const [dispatch, getState] = args;
|
|
38
|
+
const { user } = getState();
|
|
39
|
+
|
|
40
|
+
if (user.isSignedIn) {
|
|
41
|
+
dispatch(actions.getDetails.request());
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const { data } = await fetchUserDetails();
|
|
45
|
+
|
|
46
|
+
if (data.customer) {
|
|
47
|
+
const isSeller = data.customer.is_seller;
|
|
48
|
+
if (isSeller) {
|
|
49
|
+
storage.setItem('is_seller', true);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
dispatch(actions.getDetails.receive(data.customer));
|
|
54
|
+
} catch (error) {
|
|
55
|
+
dispatch(actions.getDetails.receive(error));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const resetPassword = ({ email }) =>
|
|
61
|
+
async function thunk(...args) {
|
|
62
|
+
const [dispatch] = args;
|
|
63
|
+
|
|
64
|
+
dispatch(actions.resetPassword.request());
|
|
65
|
+
|
|
66
|
+
// TODO: actually make the call to the API.
|
|
67
|
+
// For now, just return a resolved promise.
|
|
68
|
+
await Promise.resolve(email);
|
|
69
|
+
|
|
70
|
+
dispatch(actions.resetPassword.receive());
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const setToken = token =>
|
|
74
|
+
async function thunk(...args) {
|
|
75
|
+
const [dispatch] = args;
|
|
76
|
+
|
|
77
|
+
// Store token in local storage.
|
|
78
|
+
// TODO: Get correct token expire time from API
|
|
79
|
+
storage.setItem('signin_token', token, 3600);
|
|
80
|
+
|
|
81
|
+
// Persist in store
|
|
82
|
+
dispatch(actions.setToken(token));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const clearToken = () =>
|
|
86
|
+
async function thunk(...args) {
|
|
87
|
+
const [dispatch] = args;
|
|
88
|
+
|
|
89
|
+
// Clear token from local storage
|
|
90
|
+
storage.removeItem('signin_token');
|
|
91
|
+
|
|
92
|
+
storage.removeItem('is_seller');
|
|
93
|
+
|
|
94
|
+
// Remove from store
|
|
95
|
+
dispatch(actions.clearToken());
|
|
96
|
+
};
|