@riosst100/pwa-marketplace 1.2.6 → 1.2.7
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/.github/workflows/dependabot.yml +28 -28
- package/package.json +18 -18
- package/src/Utilities/graphQL.js +76 -76
- package/src/componentOverrideMapping.js +17 -16
- 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/Pagination/index.js +49 -40
- 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 +249 -42
- 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/SellerInformation/index.js +1 -1
- package/src/components/SellerInformation/sellerInformation.js +90 -84
- package/src/components/SellerLocation/index.js +1 -1
- package/src/components/SellerLocation/sellerLocation.js +19 -18
- package/src/components/SellerLocation/sellerLocationItem.js +27 -25
- package/src/components/SellerPage/sellerPage.js +9 -9
- package/src/components/SellerProducts/sellerProducts.js +47 -218
- 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 -16
- 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 -62
- 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 -118
- 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 +139 -204
- package/src/talons/Seller/useSeller.js +66 -71
- 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/components/OperatingHours/index.js +0 -1
- package/src/components/OperatingHours/operatingHours.js +0 -32
- package/src/components/Seller/sellerAddressCard.js +0 -48
- package/src/components/SellerDetail/index.js +0 -1
- package/src/components/SellerDetail/sellerDetail.js +0 -158
- package/src/components/SellerPage/core.js +0 -10
- package/src/talons/SellerProducts/useSellerProducts.js +0 -129
|
@@ -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
|
+
};
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import { useCallback, useEffect } from 'react';
|
|
2
|
-
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
3
|
-
|
|
4
|
-
const storage = new BrowserPersistence();
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {Object} props
|
|
8
|
-
* @param {Function} props.onSignOut - A function to call when sign out occurs.
|
|
9
|
-
*
|
|
10
|
-
* @returns {Object} result
|
|
11
|
-
* @returns {Function} result.handleSignOut - The function to handle sign out actions.
|
|
12
|
-
*/
|
|
13
|
-
export const useAccountMenuItems = props => {
|
|
14
|
-
const { onSignOut } = props;
|
|
15
|
-
|
|
16
|
-
const handleSignOut = useCallback(() => {
|
|
17
|
-
onSignOut();
|
|
18
|
-
}, [onSignOut]);
|
|
19
|
-
|
|
20
|
-
let MENU_ITEMS = [
|
|
21
|
-
{
|
|
22
|
-
name: 'Order History',
|
|
23
|
-
id: 'accountMenu.orderHistoryLink',
|
|
24
|
-
url: '/order-history'
|
|
25
|
-
},
|
|
26
|
-
// Hide links until features are completed
|
|
27
|
-
// {
|
|
28
|
-
// name: 'Store Credit & Gift Cards',
|
|
29
|
-
// id: 'accountMenu.storeCreditLink',
|
|
30
|
-
// url: ''
|
|
31
|
-
// },
|
|
32
|
-
{
|
|
33
|
-
name: 'Favorites Lists',
|
|
34
|
-
id: 'accountMenu.favoritesListsLink',
|
|
35
|
-
url: '/wishlist'
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: 'Address Book',
|
|
39
|
-
id: 'accountMenu.addressBookLink',
|
|
40
|
-
url: '/address-book'
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'Saved Payments',
|
|
44
|
-
id: 'accountMenu.savedPaymentsLink',
|
|
45
|
-
url: '/saved-payments'
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'Communications',
|
|
49
|
-
id: 'accountMenu.communicationsLinak',
|
|
50
|
-
url: '/communications'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: 'Account Information',
|
|
54
|
-
id: 'accountMenu.accountInfoLink',
|
|
55
|
-
url: '/account-information'
|
|
56
|
-
}
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
if (storage && storage.getItem('is_seller')) {
|
|
60
|
-
MENU_ITEMS = [
|
|
61
|
-
...MENU_ITEMS,
|
|
62
|
-
{
|
|
63
|
-
name: 'Seller Account Information',
|
|
64
|
-
id: 'accountMenu.sellerAccountInfoLink',
|
|
65
|
-
url: '/seller-account'
|
|
66
|
-
}
|
|
67
|
-
];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
handleSignOut,
|
|
72
|
-
menuItems: MENU_ITEMS
|
|
73
|
-
};
|
|
74
|
-
};
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
import { BrowserPersistence } from '@magento/peregrine/lib/util';
|
|
3
|
+
|
|
4
|
+
const storage = new BrowserPersistence();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {Object} props
|
|
8
|
+
* @param {Function} props.onSignOut - A function to call when sign out occurs.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Object} result
|
|
11
|
+
* @returns {Function} result.handleSignOut - The function to handle sign out actions.
|
|
12
|
+
*/
|
|
13
|
+
export const useAccountMenuItems = props => {
|
|
14
|
+
const { onSignOut } = props;
|
|
15
|
+
|
|
16
|
+
const handleSignOut = useCallback(() => {
|
|
17
|
+
onSignOut();
|
|
18
|
+
}, [onSignOut]);
|
|
19
|
+
|
|
20
|
+
let MENU_ITEMS = [
|
|
21
|
+
{
|
|
22
|
+
name: 'Order History',
|
|
23
|
+
id: 'accountMenu.orderHistoryLink',
|
|
24
|
+
url: '/order-history'
|
|
25
|
+
},
|
|
26
|
+
// Hide links until features are completed
|
|
27
|
+
// {
|
|
28
|
+
// name: 'Store Credit & Gift Cards',
|
|
29
|
+
// id: 'accountMenu.storeCreditLink',
|
|
30
|
+
// url: ''
|
|
31
|
+
// },
|
|
32
|
+
{
|
|
33
|
+
name: 'Favorites Lists',
|
|
34
|
+
id: 'accountMenu.favoritesListsLink',
|
|
35
|
+
url: '/wishlist'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Address Book',
|
|
39
|
+
id: 'accountMenu.addressBookLink',
|
|
40
|
+
url: '/address-book'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Saved Payments',
|
|
44
|
+
id: 'accountMenu.savedPaymentsLink',
|
|
45
|
+
url: '/saved-payments'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Communications',
|
|
49
|
+
id: 'accountMenu.communicationsLinak',
|
|
50
|
+
url: '/communications'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'Account Information',
|
|
54
|
+
id: 'accountMenu.accountInfoLink',
|
|
55
|
+
url: '/account-information'
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
if (storage && storage.getItem('is_seller')) {
|
|
60
|
+
MENU_ITEMS = [
|
|
61
|
+
...MENU_ITEMS,
|
|
62
|
+
{
|
|
63
|
+
name: 'Seller Account Information',
|
|
64
|
+
id: 'accountMenu.sellerAccountInfoLink',
|
|
65
|
+
url: '/seller-account'
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
handleSignOut,
|
|
72
|
+
menuItems: MENU_ITEMS
|
|
73
|
+
};
|
|
74
|
+
};
|