@riosst100/pwa-marketplace 3.2.6 → 3.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riosst100/pwa-marketplace",
3
3
  "author": "riosst100@gmail.com",
4
- "version": "3.2.6",
4
+ "version": "3.2.7",
5
5
  "main": "src/index.js",
6
6
  "pwa-studio": {
7
7
  "targets": {
@@ -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-collective").
247
- Your Store URL will be https://tcg.com/seller/tcg-collective.html`}
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-[960px] p-5'
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 with' })} {seller?.name}</h3>
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: 'Create New Message' })}
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 border rounded-[6px] p-3 flex flex-col gap-2'>
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)}
@@ -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>
@@ -11,7 +11,8 @@
11
11
 
12
12
  .sellerMegaMenuLinkActive {
13
13
  composes: sellerMegaMenuLink;
14
- composes: underline from global;
14
+ /* composes: underline from global; */
15
+ font-weight: bold;
15
16
  }
16
17
 
17
18
  .sellerMegaMenuItem_active {
@@ -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
- getMegaMenuQuery: GET_MEGA_MENU,
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 { getMegaMenuQuery, getStoreConfigQuery } = operations;
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 { data } = useQuery(getMegaMenuQuery, {
36
- fetchPolicy: 'cache-and-network',
37
- nextFetchPolicy: 'cache-first'
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 === categoryUrlPath;
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
- useEffect(() => {
151
- const { search } = location;
176
+ const hasCategoryPath = (pathname) => {
177
+ // const pathname = new URL(url).pathname;
178
+ const parts = pathname.split("/").filter(Boolean);
152
179
 
153
- // if (category && category.default_top_filter) {
154
- // const defaultTopFilter = category.default_top_filter;
180
+ // cari index "seller"
181
+ const sellerIndex = parts.indexOf("seller");
155
182
 
156
- // const attrCode = defaultTopFilter.attribute_code;
157
- // const label = defaultTopFilter.label;
158
- // const value = defaultTopFilter.value;
183
+ if (sellerIndex === -1) return false;
159
184
 
160
- // if (!search.includes(attrCode)) {
161
- // setDefaultSubcategoryAndTopFilter(
162
- // label + ',' + value,
163
- // attrCode + '[filter]',
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,70 @@ 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
+ console.log('megaMenuData',megaMenuData)
212
+ console.log('activeCategory',activeCategory)
213
+
214
+ if (activeCategory) {
215
+ setActiveCategoryId(activeCategory.path[0]);
216
+ setActiveCategory(activeCategory);
217
+ } else {
218
+ setActiveCategoryId(null);
219
+ setActiveCategory(null);
220
+ }
221
+ }, [findActiveCategory, location.pathname, megaMenuData]);
222
+
223
+ useEffect(() => {
224
+ const { search, pathname } = location;
225
+
226
+ console.log('category555',category)
227
+
228
+ if (!hasCategoryPath(pathname) && category && category.url_path) {
229
+ const url_path = category.url_path;
230
+ const categoryUrlPath = `/${url_path}${categoryUrlSuffix || ''}`;
231
+ const newPathname = pathname.replace(/\/+$/, "");
232
+
233
+ if (!newPathname.includes(categoryUrlPath)) {
234
+ setDefaultCategory(
235
+ newPathname + categoryUrlPath
236
+ );
237
+ }
238
+ }
239
+ }, [category, location, setDefaultCategory]);
240
+
241
+ useEffect(() => {
242
+ const { search } = location;
243
+
244
+ if (activeCategory && activeCategory.default_top_filter) {
245
+ const defaultTopFilter = activeCategory.default_top_filter;
246
+
247
+ console.log('activeCategory',activeCategory)
248
+ console.log('2defaultTopFilte344444',defaultTopFilter)
249
+ console.log('search',search)
250
+
251
+ const attrCode = defaultTopFilter.attribute_code;
252
+ const label = defaultTopFilter.label;
253
+ const value = defaultTopFilter.value;
254
+
255
+ if (!search.includes(attrCode)) {
256
+ console.log('setDefaultSubcategoryAndTopFilter',attrCode)
257
+
258
+ setDefaultSubcategoryAndTopFilter(
259
+ label + ',' + value,
260
+ attrCode + '[filter]',
261
+ true
262
+ );
263
+ }
264
+ }
265
+ }, [activeCategory, location, setDefaultSubcategoryAndTopFilter]);
266
+
267
+
268
+
185
269
  const handleClickOutside = e => {
186
270
  if (!props.mainNavRef.current.contains(e.target)) {
187
271
  setSellerSubMenuState(false);
@@ -195,18 +279,7 @@ export const useSellerMegaMenu = (props = {}) => {
195
279
  setSellerSubMenuState(true);
196
280
  }, [setSellerSubMenuState]);
197
281
 
198
- useEffect(() => {
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]);
282
+
210
283
 
211
284
  /**
212
285
  * 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.id === activeCategoryId;
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
- setDefaultSubcategoryAndTopFilter(
155
- label + ',' + value,
156
- attrCode + '[filter]',
157
- true
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