@plasmicpkgs/commerce-shopify 0.0.10 → 0.0.13

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