@plasmicpkgs/commerce-shopify 0.0.9 → 0.0.12

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.
@@ -1412,12 +1412,14 @@ export const normalizePages = (edges: PageEdge[], locale?: string): Page[] =>
1412
1412
  var normalizeCategory = function normalizeCategory(_ref10) {
1413
1413
  var name = _ref10.title,
1414
1414
  handle = _ref10.handle,
1415
- id = _ref10.id;
1415
+ id = _ref10.id,
1416
+ products = _ref10.products;
1416
1417
  return {
1417
1418
  id: id,
1418
1419
  name: name,
1419
1420
  slug: handle,
1420
- path: "/" + handle
1421
+ path: "/" + handle,
1422
+ isEmpty: products.edges.length === 0
1421
1423
  };
1422
1424
  };
1423
1425
 
@@ -1463,13 +1465,20 @@ var checkoutToCart = function checkoutToCart(checkoutPayload) {
1463
1465
  return normalizeCart(checkoutPayload == null ? void 0 : checkoutPayload.checkout);
1464
1466
  };
1465
1467
 
1468
+ var simpleProductConnection = "\nfragment simpleProductConnection on ProductConnection {\n edges {\n node {\n id\n }\n }\n}\n";
1469
+ var collectionFieldsFragment = "\n fragment collectionFieldsFragment on Collection {\n id\n title\n handle,\n products(first: $first) {\n ...simpleProductConnection\n }\n }\n " + simpleProductConnection + "\n";
1470
+ var getCollectionQueryById =
1471
+ /* GraphQL */
1472
+ "\n query getSiteCollection($id: ID!, $first: Int = 1) {\n collection(id: $id) {\n ...collectionFieldsFragment\n }\n }\n " + collectionFieldsFragment + "\n";
1473
+
1466
1474
  /*
1467
1475
  Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
1468
1476
  Changes: None
1469
1477
  */
1478
+
1470
1479
  var getSiteCollectionsQuery =
1471
1480
  /* GraphQL */
1472
- "\n query getSiteCollections($first: Int!) {\n collections(first: $first) {\n edges {\n node {\n id\n title\n handle\n }\n }\n }\n }\n";
1481
+ "\n query getSiteCollections($first: Int!) {\n collections(first: $first) {\n edges {\n node {\n ...collectionFieldsFragment\n }\n }\n }\n }\n\n " + collectionFieldsFragment + "\n";
1473
1482
 
1474
1483
  /*
1475
1484
  Forked from https://github.com/vercel/commerce/tree/main/packages/shopify/src
@@ -2152,31 +2161,49 @@ var handler$6 = {
2152
2161
  },
2153
2162
  fetcher: function fetcher(_ref) {
2154
2163
  return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2155
- var _data$collections$edg, _data$collections, _data$collections$edg2;
2164
+ var input, options, fetch, categoryId, _data$collections$edg, _data$collections, _data$collections$edg2, data, _data;
2156
2165
 
2157
- var fetch, data;
2158
2166
  return runtime_1.wrap(function _callee$(_context) {
2159
2167
  while (1) {
2160
2168
  switch (_context.prev = _context.next) {
2161
2169
  case 0:
2162
- fetch = _ref.fetch;
2163
- _context.next = 3;
2170
+ input = _ref.input, options = _ref.options, fetch = _ref.fetch;
2171
+ categoryId = input.categoryId;
2172
+
2173
+ if (categoryId) {
2174
+ _context.next = 9;
2175
+ break;
2176
+ }
2177
+
2178
+ _context.next = 5;
2164
2179
  return fetch({
2165
- query: getSiteCollectionsQuery,
2180
+ query: options.query,
2166
2181
  variables: {
2167
2182
  first: 250
2168
2183
  }
2169
2184
  });
2170
2185
 
2171
- case 3:
2186
+ case 5:
2172
2187
  data = _context.sent;
2173
- console.log("dale", "useCategories", data);
2174
- return _context.abrupt("return", (_data$collections$edg = (_data$collections = data.collections) == null ? void 0 : (_data$collections$edg2 = _data$collections.edges) == null ? void 0 : _data$collections$edg2.map(function (_ref2) {
2188
+ return _context.abrupt("return", (_data$collections$edg = data == null ? void 0 : (_data$collections = data.collections) == null ? void 0 : (_data$collections$edg2 = _data$collections.edges) == null ? void 0 : _data$collections$edg2.map(function (_ref2) {
2175
2189
  var node = _ref2.node;
2176
2190
  return normalizeCategory(node);
2177
2191
  })) != null ? _data$collections$edg : []);
2178
2192
 
2179
- case 6:
2193
+ case 9:
2194
+ _context.next = 11;
2195
+ return fetch({
2196
+ query: getCollectionQueryById,
2197
+ variables: {
2198
+ id: categoryId
2199
+ }
2200
+ });
2201
+
2202
+ case 11:
2203
+ _data = _context.sent;
2204
+ return _context.abrupt("return", !!(_data != null && _data.collection) ? [normalizeCategory(_data == null ? void 0 : _data.collection)] : []);
2205
+
2206
+ case 13:
2180
2207
  case "end":
2181
2208
  return _context.stop();
2182
2209
  }
@@ -2188,6 +2215,7 @@ var handler$6 = {
2188
2215
  var useData = _ref3.useData;
2189
2216
  return function (input) {
2190
2217
  var response = useData({
2218
+ input: [['categoryId', input == null ? void 0 : input.categoryId]],
2191
2219
  swrOptions: _extends({
2192
2220
  revalidateOnFocus: false
2193
2221
  }, input == null ? void 0 : input.swrOptions)