@riosst100/pwa-marketplace 3.2.6 → 3.2.8
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/components/BecomeSeller/becomeSeller.js +2 -2
- package/src/components/LiveChat/MessagesModal.js +6 -6
- package/src/components/LiveChat/liveChat.js +12 -42
- package/src/components/RFQPage/quoteDetail.js +15 -8
- package/src/components/SellerMegaMenu/sellerMegaMenu.js +3 -1
- package/src/components/SellerMegaMenu/sellerMegaMenuItem.js +1 -1
- package/src/components/SellerMegaMenu/sellerMegaMenuItem.module.css +2 -1
- package/src/overwrites/venia-ui/lib/components/Footer/footer.js +12 -3
- package/src/talons/SellerMegaMenu/megaMenu.gql.js +4 -3
- package/src/talons/SellerMegaMenu/useSellerMegaMenu.js +95 -33
- package/src/talons/SellerMegaMenu/useSellerMegaMenuItem.js +1 -1
- package/src/talons/SellerProducts/useProductContent.js +11 -7
package/package.json
CHANGED
|
@@ -243,8 +243,8 @@ const BecomeSeller = props => {
|
|
|
243
243
|
<label className='text-left text-xs font-normal text-gray-400 mt-2'>
|
|
244
244
|
<FormattedMessage
|
|
245
245
|
id={'becomeSeller.urlNotes'}
|
|
246
|
-
defaultMessage={`Please enter a valid Store URL (Ex: "tcg-
|
|
247
|
-
Your Store URL will be https://
|
|
246
|
+
defaultMessage={`Please enter a valid Store URL (Ex: "tcg-store").
|
|
247
|
+
Your Store URL will be https://tcgcollective.co/seller/tcg-store`}
|
|
248
248
|
/>
|
|
249
249
|
</label>
|
|
250
250
|
</Field>
|
|
@@ -169,11 +169,11 @@ const MessagesModal = ({
|
|
|
169
169
|
}}
|
|
170
170
|
>
|
|
171
171
|
<div
|
|
172
|
-
className='bg-white rounded-[6px] shadow-lg w-full max-w-[
|
|
172
|
+
className='bg-white rounded-[6px] shadow-lg w-full max-w-[500px] p-5'
|
|
173
173
|
onClick={(e) => e.stopPropagation()}
|
|
174
174
|
>
|
|
175
175
|
<div className='flex items-center justify-between mb-3'>
|
|
176
|
-
<h3 className='text-[18px] font-semibold'>{formatMessage({ id: 'messages.titleWithSeller', defaultMessage: 'Conversation
|
|
176
|
+
<h3 className='text-[18px] font-semibold'>{formatMessage({ id: 'messages.titleWithSeller', defaultMessage: 'Start Conversation With ' })} {seller?.name}</h3>
|
|
177
177
|
<button onClick={onClose} aria-label='Close' className='text-gray-600 text-[30px] hover:text-black'>×</button>
|
|
178
178
|
</div>
|
|
179
179
|
<div className='flex gap-4'>
|
|
@@ -190,7 +190,7 @@ const MessagesModal = ({
|
|
|
190
190
|
}}
|
|
191
191
|
className='text-[12px] px-2 py-1 rounded border border-[#FF6E26] text-[#FF6E26] hover:bg-[#FF6E26] hover:text-white'
|
|
192
192
|
>
|
|
193
|
-
{formatMessage({ id: 'messages.compose.newMessage', defaultMessage: '
|
|
193
|
+
{formatMessage({ id: 'messages.compose.newMessage', defaultMessage: 'Send New Message' })}
|
|
194
194
|
</button>
|
|
195
195
|
</div>
|
|
196
196
|
<div className='max-h-[420px] overflow-y-auto'>
|
|
@@ -222,7 +222,7 @@ const MessagesModal = ({
|
|
|
222
222
|
<div className='flex-1 flex flex-col'>
|
|
223
223
|
{/* Compose new message (shown only when composing OR when no thread exists) */}
|
|
224
224
|
{(isComposing || sortedThreads.length === 0) && (
|
|
225
|
-
<form onSubmit={handleSubmitNewMessage} className='mb-3
|
|
225
|
+
<form onSubmit={handleSubmitNewMessage} className='mb-3 rounded-[6px] p-1 flex flex-col gap-2'>
|
|
226
226
|
<div className='text-[13px] font-semibold flex items-center justify-between'>
|
|
227
227
|
<span>{formatMessage({ id: 'messages.compose.header', defaultMessage: 'Create New Message' })}</span>
|
|
228
228
|
{(sortedThreads.length > 0) && (
|
|
@@ -237,14 +237,14 @@ const MessagesModal = ({
|
|
|
237
237
|
</div>
|
|
238
238
|
<input
|
|
239
239
|
type='text'
|
|
240
|
-
className='border rounded px-3 py-2 outline-none focus:ring-2 focus:ring-[#FF6E26]'
|
|
240
|
+
className='border border-gray-100 rounded px-3 py-2 outline-none focus:ring-2 focus:ring-[#FF6E26]'
|
|
241
241
|
placeholder={formatMessage({ id: 'messages.compose.subjectPlaceholder', defaultMessage: 'Subject' })}
|
|
242
242
|
value={newSubject}
|
|
243
243
|
onChange={(e) => setNewSubject(e.target.value)}
|
|
244
244
|
/>
|
|
245
245
|
<textarea
|
|
246
246
|
rows={3}
|
|
247
|
-
className='border rounded px-3 py-2 outline-none focus:ring-2 focus:ring-[#FF6E26]'
|
|
247
|
+
className='border border-gray-100 rounded px-3 py-2 outline-none focus:ring-2 focus:ring-[#FF6E26]'
|
|
248
248
|
placeholder={formatMessage({ id: 'messages.compose.contentPlaceholder', defaultMessage: 'Write a message to the seller…' })}
|
|
249
249
|
value={newContent}
|
|
250
250
|
onChange={(e) => setNewContent(e.target.value)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormattedMessage } from 'react-intl';
|
|
3
3
|
import cn from 'classnames';
|
|
4
|
-
import {
|
|
4
|
+
import { Messages3 } from 'iconsax-react';
|
|
5
5
|
import ChatContent from './chatContent';
|
|
6
6
|
import { Send } from 'iconsax-react';
|
|
7
7
|
import Button from '@magento/venia-ui/lib/components/Button';
|
|
@@ -71,68 +71,38 @@ const liveChat = (props) => {
|
|
|
71
71
|
const { open, setOpen, chatData } = props;
|
|
72
72
|
const [{ isSignedIn }] = useUserContext();
|
|
73
73
|
|
|
74
|
-
const dataTabs =
|
|
75
|
-
[
|
|
76
|
-
{
|
|
77
|
-
id: isSignedIn ? 'login-chat' : 'guest-chat',
|
|
78
|
-
title: isSignedIn ? 'Login Chat' : 'Guest Chat',
|
|
79
|
-
content: <ChatContentComponent chatData={chatData} />
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: !isSignedIn ? 'login-chat' : 'guest-chat',
|
|
83
|
-
title: !isSignedIn ? 'Login Chat' : 'Guest Chat',
|
|
84
|
-
content: isSignedIn ? <ChatContentComponent chatData={chatData} /> : <LoginComponent />
|
|
85
|
-
}
|
|
86
|
-
];
|
|
87
|
-
|
|
88
74
|
return (
|
|
89
75
|
<>
|
|
90
76
|
<div
|
|
91
77
|
className={cn(
|
|
92
|
-
'
|
|
93
|
-
|
|
78
|
+
'flex flex-col w-full max-w-[150px] fixed z-50',
|
|
79
|
+
'bottom-[30px] right-[30px]'
|
|
94
80
|
)}
|
|
95
81
|
>
|
|
96
|
-
<
|
|
97
|
-
className='bg-darkblue-900 p-4 rounded-
|
|
98
|
-
|
|
82
|
+
<Link
|
|
83
|
+
className='bg-darkblue-900 p-4 px-6 rounded-[40px] cursor-pointer flex justify-between items-center'
|
|
84
|
+
to={'/messages'}
|
|
99
85
|
>
|
|
100
86
|
<span className='text-white font-medium'>
|
|
101
87
|
<FormattedMessage
|
|
102
|
-
id={'chat.
|
|
88
|
+
id={'chat.messageButton'}
|
|
103
89
|
defaultMessage={
|
|
104
|
-
'
|
|
90
|
+
'Messages'
|
|
105
91
|
}
|
|
106
92
|
/>
|
|
107
93
|
</span>
|
|
108
94
|
<span>
|
|
109
|
-
<
|
|
110
|
-
size="
|
|
95
|
+
<Messages3
|
|
96
|
+
size="24"
|
|
111
97
|
className={
|
|
112
98
|
cn(
|
|
113
|
-
'transition-all text-white'
|
|
114
|
-
open ? 'rotate-180' : '',
|
|
99
|
+
'transition-all text-white'
|
|
115
100
|
)
|
|
116
101
|
}
|
|
117
102
|
/>
|
|
118
103
|
</span>
|
|
119
104
|
|
|
120
|
-
</
|
|
121
|
-
<div
|
|
122
|
-
className={cn(
|
|
123
|
-
'border border-gray-100 p-4 w-full h-full flex flex-col gap-3',
|
|
124
|
-
'max-h-[468px]'
|
|
125
|
-
)}
|
|
126
|
-
>
|
|
127
|
-
<Tabs
|
|
128
|
-
data={dataTabs}
|
|
129
|
-
tabContentWrapperClassName='!p-0 h-full'
|
|
130
|
-
hasContent
|
|
131
|
-
tabWrapperClassName='justify-around'
|
|
132
|
-
rootClassName="mb-0"
|
|
133
|
-
tabTitleClassName="pt-0 pb-2 text-[12px]"
|
|
134
|
-
/>
|
|
135
|
-
</div>
|
|
105
|
+
</Link>
|
|
136
106
|
</div>
|
|
137
107
|
<style jsx="true">
|
|
138
108
|
{`
|
|
@@ -13,7 +13,7 @@ import LoadingIndicator from '@magento/venia-ui/lib/components/LoadingIndicator'
|
|
|
13
13
|
|
|
14
14
|
const quoteDetail = () => {
|
|
15
15
|
const { formatMessage } = useIntl();
|
|
16
|
-
const {
|
|
16
|
+
const { urlKey } = useParams();
|
|
17
17
|
const location = useLocation();
|
|
18
18
|
const locationRfq = location && location.state && location.state.rfq ? location.state.rfq : null;
|
|
19
19
|
const { loadRfqDetail, rfqDetailState, handleSendRfqMessage, startDetailPolling, stopDetailPolling, handleConvertQuickrfqToCart } = useRFQ();
|
|
@@ -31,15 +31,20 @@ const quoteDetail = () => {
|
|
|
31
31
|
// prefer image from info_buy_request if available; otherwise use placeholder
|
|
32
32
|
const urlImage = 'https://pwa-tcgcollective.local:8255/media/catalog/product/s/-/s-l1600_6__1.jpg?auto=webp&format=pjpg&width=495&height=618.75&fit=cover';
|
|
33
33
|
|
|
34
|
+
// Ensure we always pass a valid Int quickrfqId: prefer rfq.quickrfq_id, fallback to route param id
|
|
35
|
+
// Ensure we always pass a valid Int quickrfqId: prefer route param id, fallback to detailData.quickrfq_id
|
|
34
36
|
useEffect(() => {
|
|
35
37
|
if (!locationRfq) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const fromParam = urlKey ? parseInt(urlKey, 10) : NaN;
|
|
39
|
+
const fromData = detailData && detailData.quickrfq_id
|
|
40
|
+
? (typeof detailData.quickrfq_id === 'number' ? detailData.quickrfq_id : parseInt(detailData.quickrfq_id, 10))
|
|
41
|
+
: NaN;
|
|
42
|
+
const finalId = !isNaN(fromParam) ? fromParam : fromData;
|
|
43
|
+
if (!isNaN(finalId)) {
|
|
44
|
+
loadRfqDetail({ quickrfqId: finalId });
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
|
-
}, [
|
|
47
|
+
}, [urlKey, detailData, locationRfq, loadRfqDetail]);
|
|
43
48
|
|
|
44
49
|
// start polling messages every 5s while on detail page; stop on unmount
|
|
45
50
|
useEffect(() => {
|
|
@@ -50,7 +55,9 @@ const quoteDetail = () => {
|
|
|
50
55
|
}, [startDetailPolling, stopDetailPolling]);
|
|
51
56
|
|
|
52
57
|
const rfq = locationRfq || detailData || {};
|
|
53
|
-
const quickrfqIdValue = rfq && rfq.quickrfq_id
|
|
58
|
+
const quickrfqIdValue = rfq && rfq.quickrfq_id
|
|
59
|
+
? (typeof rfq.quickrfq_id === 'number' ? rfq.quickrfq_id : parseInt(rfq.quickrfq_id, 10))
|
|
60
|
+
: (urlKey ? parseInt(urlKey, 10) : null);
|
|
54
61
|
const [isConverting, setIsConverting] = useState(false);
|
|
55
62
|
const [convertError, setConvertError] = useState(null);
|
|
56
63
|
const [convertSuccess, setConvertSuccess] = useState(null);
|
|
@@ -95,7 +102,7 @@ const quoteDetail = () => {
|
|
|
95
102
|
<div className='relative grid gap-y-md'>
|
|
96
103
|
<StoreTitle>{PAGE_TITLE}</StoreTitle>
|
|
97
104
|
<div aria-live="polite" className="text-xl font-medium text-left">
|
|
98
|
-
{PAGE_TITLE} - #{
|
|
105
|
+
{PAGE_TITLE} - #{quickrfqIdValue}
|
|
99
106
|
</div>
|
|
100
107
|
<div className='rounded-md border border-gray-100 px-4 py-6 flex flex-col-reverse md_flex-row justify-between gap-x-10'>
|
|
101
108
|
<div className='flex flex-col gap-y-4 w-full md_w-6/12'>
|
|
@@ -16,6 +16,8 @@ const SellerMegaMenu = (props) => {
|
|
|
16
16
|
const { rootClassName, seller, sellerMegaMenuItemClassname, titleClassName } = props
|
|
17
17
|
const mainNavRef = useRef(null);
|
|
18
18
|
|
|
19
|
+
const sellerUrl = seller.url_key;
|
|
20
|
+
|
|
19
21
|
const classes = useStyle(defaultClasses, props.classes);
|
|
20
22
|
// const rootClass = cn(classes.sellerMegaMenu, rootClassName);
|
|
21
23
|
const rootClass = cn('flex items-end gap-[40px] px-[30px] py-0 rounded-[6px] border border-solid border-gray-100 xs_hidden xl_flex flex-grow justify-self-center', rootClassName);
|
|
@@ -29,7 +31,7 @@ const SellerMegaMenu = (props) => {
|
|
|
29
31
|
categoryUrlSuffix,
|
|
30
32
|
handleNavigate,
|
|
31
33
|
handleClickOutside
|
|
32
|
-
} = useSellerMegaMenu({ mainNavRef });
|
|
34
|
+
} = useSellerMegaMenu({ mainNavRef, sellerUrl });
|
|
33
35
|
|
|
34
36
|
// const allowedCategoryUids = props.allowedCategoryUids || ['NTI=', 'NTA=', 'NTM=', 'MjY='];
|
|
35
37
|
|
|
@@ -116,7 +116,7 @@ const SellerMegaMenuItem = props => {
|
|
|
116
116
|
'flex items-center'
|
|
117
117
|
)}
|
|
118
118
|
data-cy="SellerMegaMenu-SellerMegaMenuItem-link"
|
|
119
|
-
to={'/seller/' + seller?.url_key + categoryUrl}
|
|
119
|
+
to={isActive ? '#' : '/seller/' + seller?.url_key + categoryUrl}
|
|
120
120
|
>
|
|
121
121
|
{category.name}
|
|
122
122
|
</Link>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, { Fragment } from 'react';
|
|
1
|
+
import React, { useState, Fragment } from 'react';
|
|
2
2
|
import { Facebook, Instagram, Twitter, Linkedin } from 'react-feather';
|
|
3
3
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
4
4
|
import { Link } from 'react-router-dom';
|
|
5
5
|
import { shape, string } from 'prop-types';
|
|
6
6
|
import { useFooter } from '@magento/peregrine/lib/talons/Footer/useFooter';
|
|
7
7
|
import { useLocation } from 'react-router-dom';
|
|
8
|
-
|
|
8
|
+
import LiveChat from '@riosst100/pwa-marketplace/src/components/LiveChat';
|
|
9
9
|
import Logo from '@magento/venia-ui/lib/components/Logo';
|
|
10
10
|
import Newsletter from '@magento/venia-ui/lib/components/Newsletter';
|
|
11
11
|
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
@@ -14,12 +14,17 @@ import { DEFAULT_LINKS, LOREM_IPSUM } from './sampleData';
|
|
|
14
14
|
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
15
15
|
import cn from 'classnames';
|
|
16
16
|
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
17
|
-
|
|
17
|
+
import Button from '@magento/venia-ui/lib/components/Button';
|
|
18
18
|
const Footer = props => {
|
|
19
19
|
const { links } = props;
|
|
20
20
|
const classes = useStyle(defaultClasses, props.classes);
|
|
21
21
|
const talonProps = useFooter();
|
|
22
22
|
|
|
23
|
+
const [openChat, setOpenChat] = useState(false);
|
|
24
|
+
const toggleChat = () => {
|
|
25
|
+
setOpenChat(!openChat);
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
const location = useLocation();
|
|
24
29
|
const isCheckoutPage = location.pathname === '/checkout';
|
|
25
30
|
|
|
@@ -86,6 +91,10 @@ const Footer = props => {
|
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
>
|
|
94
|
+
<LiveChat
|
|
95
|
+
open={openChat}
|
|
96
|
+
setOpen={setOpenChat}
|
|
97
|
+
/>
|
|
89
98
|
{!isCheckoutPage && <div className={classes.links} style={{"display":"flex"}}>
|
|
90
99
|
{linkGroups}
|
|
91
100
|
{/* <div>
|
|
@@ -10,9 +10,9 @@ export const GET_STORE_CONFIG_DATA = gql`
|
|
|
10
10
|
`;
|
|
11
11
|
|
|
12
12
|
export const GET_MEGA_MENU = gql`
|
|
13
|
-
query getSellerMegaMenu {
|
|
13
|
+
query getSellerMegaMenu($sellerUrl: String!) {
|
|
14
14
|
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
15
|
-
sellerCategories {
|
|
15
|
+
sellerCategories(sellerUrl: $sellerUrl) {
|
|
16
16
|
uid
|
|
17
17
|
name
|
|
18
18
|
# eslint-disable-next-line @graphql-eslint/require-id-when-available
|
|
@@ -79,11 +79,12 @@ export const GET_MEGA_MENU = gql`
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
__typename
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
`;
|
|
85
86
|
|
|
86
87
|
export default {
|
|
87
|
-
|
|
88
|
+
getSellerMegaMenuQuery: GET_MEGA_MENU,
|
|
88
89
|
getStoreConfigQuery: GET_STORE_CONFIG_DATA
|
|
89
90
|
};
|
|
@@ -20,10 +20,11 @@ import DEFAULT_OPERATIONS from './megaMenu.gql';
|
|
|
20
20
|
*/
|
|
21
21
|
export const useSellerMegaMenu = (props = {}) => {
|
|
22
22
|
const operations = mergeOperations(DEFAULT_OPERATIONS, props.operations);
|
|
23
|
-
const {
|
|
23
|
+
const { getSellerMegaMenuQuery, getStoreConfigQuery } = operations;
|
|
24
24
|
|
|
25
25
|
const location = useLocation();
|
|
26
26
|
const [activeCategoryId, setActiveCategoryId] = useState(null);
|
|
27
|
+
const [activeCategory, setActiveCategory] = useState(null);
|
|
27
28
|
const [sellerSubMenuState, setSellerSubMenuState] = useState(false);
|
|
28
29
|
const [disableFocus, setDisableFocus] = useState(false);
|
|
29
30
|
|
|
@@ -32,9 +33,11 @@ export const useSellerMegaMenu = (props = {}) => {
|
|
|
32
33
|
nextFetchPolicy: 'cache-first'
|
|
33
34
|
});
|
|
34
35
|
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const { sellerUrl } = props;
|
|
37
|
+
|
|
38
|
+
const { data } = useQuery(getSellerMegaMenuQuery, {
|
|
39
|
+
variables: { sellerUrl: sellerUrl },
|
|
40
|
+
fetchPolicy: 'cache-and-network'
|
|
38
41
|
});
|
|
39
42
|
|
|
40
43
|
const categoryUrlSuffix = useMemo(() => {
|
|
@@ -66,7 +69,7 @@ export const useSellerMegaMenu = (props = {}) => {
|
|
|
66
69
|
|
|
67
70
|
const categoryUrlPath = `/${url_path}${categoryUrlSuffix || ''}`;
|
|
68
71
|
|
|
69
|
-
return location.pathname
|
|
72
|
+
return location.pathname.includes(categoryUrlPath);
|
|
70
73
|
},
|
|
71
74
|
[location.pathname, categoryUrlSuffix]
|
|
72
75
|
);
|
|
@@ -119,6 +122,29 @@ export const useSellerMegaMenu = (props = {}) => {
|
|
|
119
122
|
|
|
120
123
|
const history = useHistory();
|
|
121
124
|
|
|
125
|
+
const setQueryPath = ({ history, location, pathname, replace }) => {
|
|
126
|
+
// const { pathname } = location;
|
|
127
|
+
|
|
128
|
+
const destination = { pathname: pathname };
|
|
129
|
+
|
|
130
|
+
if (replace) {
|
|
131
|
+
history.replace(destination);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const setDefaultCategory = useCallback(
|
|
136
|
+
(pathname) => {
|
|
137
|
+
// Update the query parameter.
|
|
138
|
+
setQueryPath({
|
|
139
|
+
history,
|
|
140
|
+
location,
|
|
141
|
+
pathname,
|
|
142
|
+
replace: true
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
[history, location]
|
|
146
|
+
);
|
|
147
|
+
|
|
122
148
|
const setQueryParam = ({ history, location, parameter, replace, value }) => {
|
|
123
149
|
const { search } = location;
|
|
124
150
|
const queryParams = new URLSearchParams(search);
|
|
@@ -147,25 +173,19 @@ export const useSellerMegaMenu = (props = {}) => {
|
|
|
147
173
|
[history, location]
|
|
148
174
|
);
|
|
149
175
|
|
|
150
|
-
|
|
151
|
-
const
|
|
176
|
+
const hasCategoryPath = (pathname) => {
|
|
177
|
+
// const pathname = new URL(url).pathname;
|
|
178
|
+
const parts = pathname.split("/").filter(Boolean);
|
|
152
179
|
|
|
153
|
-
//
|
|
154
|
-
|
|
180
|
+
// cari index "seller"
|
|
181
|
+
const sellerIndex = parts.indexOf("seller");
|
|
155
182
|
|
|
156
|
-
|
|
157
|
-
// const label = defaultTopFilter.label;
|
|
158
|
-
// const value = defaultTopFilter.value;
|
|
183
|
+
if (sellerIndex === -1) return false;
|
|
159
184
|
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// true
|
|
165
|
-
// );
|
|
166
|
-
// }
|
|
167
|
-
// }
|
|
168
|
-
}, [category, location, setDefaultSubcategoryAndTopFilter]);
|
|
185
|
+
// seller/<store-name> → minimal 2 segment
|
|
186
|
+
// kalau lebih dari itu → ada category path
|
|
187
|
+
return parts.length > sellerIndex + 2;
|
|
188
|
+
}
|
|
169
189
|
|
|
170
190
|
const findActiveCategory = useCallback(
|
|
171
191
|
(pathname, category) => {
|
|
@@ -182,6 +202,59 @@ export const useSellerMegaMenu = (props = {}) => {
|
|
|
182
202
|
[isActive]
|
|
183
203
|
);
|
|
184
204
|
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
const activeCategory = findActiveCategory(
|
|
207
|
+
location.pathname,
|
|
208
|
+
megaMenuData
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
if (activeCategory) {
|
|
212
|
+
setActiveCategoryId(activeCategory.path[0]);
|
|
213
|
+
setActiveCategory(activeCategory);
|
|
214
|
+
} else {
|
|
215
|
+
setActiveCategoryId(null);
|
|
216
|
+
setActiveCategory(null);
|
|
217
|
+
}
|
|
218
|
+
}, [findActiveCategory, location.pathname, megaMenuData]);
|
|
219
|
+
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
const { search, pathname } = location;
|
|
222
|
+
|
|
223
|
+
if (!hasCategoryPath(pathname) && category && category.url_path) {
|
|
224
|
+
const url_path = category.url_path;
|
|
225
|
+
const categoryUrlPath = `/${url_path}${categoryUrlSuffix || ''}`;
|
|
226
|
+
const newPathname = pathname.replace(/\/+$/, "");
|
|
227
|
+
|
|
228
|
+
if (!newPathname.includes(categoryUrlPath)) {
|
|
229
|
+
setDefaultCategory(
|
|
230
|
+
newPathname + categoryUrlPath
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}, [category, location, setDefaultCategory]);
|
|
235
|
+
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
const { search } = location;
|
|
238
|
+
|
|
239
|
+
if (activeCategory && activeCategory.default_top_filter) {
|
|
240
|
+
const defaultTopFilter = activeCategory.default_top_filter;
|
|
241
|
+
|
|
242
|
+
const attrCode = defaultTopFilter.attribute_code;
|
|
243
|
+
const label = defaultTopFilter.label;
|
|
244
|
+
const value = defaultTopFilter.value;
|
|
245
|
+
|
|
246
|
+
if (!search.includes(attrCode)) {
|
|
247
|
+
setDefaultSubcategoryAndTopFilter(
|
|
248
|
+
label + ',' + value,
|
|
249
|
+
attrCode + '[filter]',
|
|
250
|
+
true
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}, [activeCategory, location, setDefaultSubcategoryAndTopFilter]);
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
185
258
|
const handleClickOutside = e => {
|
|
186
259
|
if (!props.mainNavRef.current.contains(e.target)) {
|
|
187
260
|
setSellerSubMenuState(false);
|
|
@@ -195,18 +268,7 @@ export const useSellerMegaMenu = (props = {}) => {
|
|
|
195
268
|
setSellerSubMenuState(true);
|
|
196
269
|
}, [setSellerSubMenuState]);
|
|
197
270
|
|
|
198
|
-
|
|
199
|
-
const activeCategory = findActiveCategory(
|
|
200
|
-
location.pathname,
|
|
201
|
-
megaMenuData
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
if (activeCategory) {
|
|
205
|
-
setActiveCategoryId(activeCategory.path[0]);
|
|
206
|
-
} else {
|
|
207
|
-
setActiveCategoryId(null);
|
|
208
|
-
}
|
|
209
|
-
}, [findActiveCategory, location.pathname, megaMenuData]);
|
|
271
|
+
|
|
210
272
|
|
|
211
273
|
/**
|
|
212
274
|
* Sets next root component to show proper loading effect
|
|
@@ -4,7 +4,7 @@ export const useSellerMegaMenuItem = props => {
|
|
|
4
4
|
const { category, activeCategoryId, sellerSubMenuState, disableFocus } = props;
|
|
5
5
|
|
|
6
6
|
const [isFocused, setIsFocused] = useState(false);
|
|
7
|
-
const isActive = category.
|
|
7
|
+
const isActive = category.uid === activeCategoryId;
|
|
8
8
|
|
|
9
9
|
const handleMenuItemFocus = useCallback(() => {
|
|
10
10
|
setIsFocused(true);
|
|
@@ -146,17 +146,21 @@ export const useProductContent = props => {
|
|
|
146
146
|
if (category && category.default_top_filter) {
|
|
147
147
|
const defaultTopFilter = category.default_top_filter;
|
|
148
148
|
|
|
149
|
+
// console.log('defaultTopFilter222',defaultTopFilter)
|
|
150
|
+
|
|
149
151
|
const attrCode = defaultTopFilter.attribute_code;
|
|
150
152
|
const label = defaultTopFilter.label;
|
|
151
153
|
const value = defaultTopFilter.value;
|
|
152
154
|
|
|
153
|
-
if (!search.includes(attrCode)) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
// if (!search.includes(attrCode)) {
|
|
156
|
+
// console.log('setDefaultSubcategoryAndTopFilter',attrCode)
|
|
157
|
+
|
|
158
|
+
// setDefaultSubcategoryAndTopFilter(
|
|
159
|
+
// label + ',' + value,
|
|
160
|
+
// attrCode + '[filter]',
|
|
161
|
+
// true
|
|
162
|
+
// );
|
|
163
|
+
// }
|
|
160
164
|
}
|
|
161
165
|
}, [category, location, setDefaultSubcategoryAndTopFilter]);
|
|
162
166
|
|