utopia-ui 3.0.0-alpha.75 → 3.0.0-alpha.76

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/dist/index.js CHANGED
@@ -3902,31 +3902,41 @@ var TagView = function (_a) {
3902
3902
  };
3903
3903
 
3904
3904
  function OverlayProfile() {
3905
- var _a, _b, _c, _d, _e, _f;
3905
+ var _a, _b;
3906
3906
  var location = useLocation();
3907
3907
  var items = useItems();
3908
- var _g = useState({}), item = _g[0], setItem = _g[1];
3908
+ var _c = useState({}), item = _c[0], setItem = _c[1];
3909
3909
  var map = useMap();
3910
3910
  var windowDimension = useWindowDimensions();
3911
3911
  var tags = useTags();
3912
3912
  var user = useAuth().user;
3913
3913
  var navigate = useNavigate();
3914
- var _h = useState(), owner = _h[0], setOwner = _h[1];
3914
+ var _d = useState(), owner = _d[0], setOwner = _d[1];
3915
+ var _e = useState([]), offers = _e[0], setOffers = _e[1];
3916
+ var _f = useState([]), needs = _f[0], setNeeds = _f[1];
3915
3917
  var addFilterTag = useAddFilterTag();
3916
- React.useEffect(function () {
3917
- var _a, _b;
3918
+ useEffect(function () {
3918
3919
  var itemId = location.pathname.split("/")[2];
3919
3920
  var item = items.find(function (i) { return i.id === itemId; });
3920
3921
  item && setItem(item);
3921
- console.log(item);
3922
- console.log(user);
3923
- ((_a = item === null || item === void 0 ? void 0 : item.layer) === null || _a === void 0 ? void 0 : _a.itemOwnerField) && setOwner(getValue(item, (_b = item.layer) === null || _b === void 0 ? void 0 : _b.itemOwnerField));
3924
3922
  var bounds = map.getBounds();
3925
3923
  var x = bounds.getEast() - bounds.getWest();
3926
3924
  if (windowDimension.width > 768)
3927
3925
  if (item === null || item === void 0 ? void 0 : item.position.coordinates[0])
3928
3926
  map.setView(new LatLng(item === null || item === void 0 ? void 0 : item.position.coordinates[1], (item === null || item === void 0 ? void 0 : item.position.coordinates[0]) + x / 4));
3929
3927
  }, [location, items]);
3928
+ useEffect(function () {
3929
+ var _a, _b, _c, _d;
3930
+ ((_a = item === null || item === void 0 ? void 0 : item.layer) === null || _a === void 0 ? void 0 : _a.itemOwnerField) && setOwner(getValue(item, (_b = item.layer) === null || _b === void 0 ? void 0 : _b.itemOwnerField));
3931
+ ((_c = item.layer) === null || _c === void 0 ? void 0 : _c.itemOffersField) && getValue(item, item.layer.itemOffersField).map(function (o) {
3932
+ var tag = tags.find(function (t) { return t.id === o.tags_id; });
3933
+ tag && setOffers(function (current) { return __spreadArray(__spreadArray([], current, true), [tag], false); });
3934
+ });
3935
+ ((_d = item.layer) === null || _d === void 0 ? void 0 : _d.itemNeedsField) && getValue(item, item.layer.itemNeedsField).map(function (n) {
3936
+ var tag = tags.find(function (t) { return t.id === n.tags_id; });
3937
+ tag && setNeeds(function (current) { return __spreadArray(__spreadArray([], current, true), [tag], false); });
3938
+ });
3939
+ }, [item]);
3930
3940
  return (React.createElement(MapOverlayPage, { className: 'tw-mx-4 tw-mt-4 tw-max-h-[calc(100dvh-96px)] tw-h-[calc(100dvh-96px)] md:tw-w-[calc(50%-32px)] tw-w-[calc(100%-32px)] tw-max-w-3xl !tw-left-auto tw-top-0 tw-bottom-0' }, item &&
3931
3941
  React.createElement(React.Fragment, null,
3932
3942
  React.createElement("div", { className: 'tw-flex tw-flex-row' },
@@ -3941,20 +3951,14 @@ function OverlayProfile() {
3941
3951
  React.createElement("path", { d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" }))) : ""),
3942
3952
  React.createElement("div", { className: 'tw-overflow-y-auto tw-h-full tw-pt-4 fade' },
3943
3953
  React.createElement("div", { className: 'tw-grid tw-grid-cols-1 xl:tw-grid-cols-2' },
3944
- ((_c = item.layer) === null || _c === void 0 ? void 0 : _c.itemOffersField) && getValue(item, item.layer.itemOffersField).length > 0 ?
3954
+ offers.length > 0 ?
3945
3955
  React.createElement("div", { className: 'tw-col-span-1' },
3946
3956
  React.createElement("h3", { className: '-tw-mb-2' }, "Offers"),
3947
- React.createElement("div", { className: 'tw-flex tw-flex-wrap tw-mb-2' }, ((_d = item.layer) === null || _d === void 0 ? void 0 : _d.itemOffersField) && getValue(item, item.layer.itemOffersField).map(function (o) {
3948
- var tag = tags.find(function (t) { return t.id === o.tags_id; });
3949
- return (tag ? React.createElement(TagView, { key: tag === null || tag === void 0 ? void 0 : tag.id, tag: tag, onClick: function () { return addFilterTag(tag); } }) : "");
3950
- }))) : "",
3951
- ((_e = item.layer) === null || _e === void 0 ? void 0 : _e.itemNeedsField) && getValue(item, item.layer.itemNeedsField).length > 0 ?
3957
+ React.createElement("div", { className: 'tw-flex tw-flex-wrap tw-mb-2' }, offers.map(function (o) { return React.createElement(TagView, { key: o === null || o === void 0 ? void 0 : o.id, tag: o, onClick: function () { return addFilterTag(o); } }); }))) : "",
3958
+ needs.length > 0 ?
3952
3959
  React.createElement("div", { className: 'tw-col-span-1' },
3953
3960
  React.createElement("h3", { className: '-tw-mb-2 tw-col-span-1' }, "Needs"),
3954
- React.createElement("div", { className: 'tw-flex tw-flex-wrap tw-mb-4' }, ((_f = item.layer) === null || _f === void 0 ? void 0 : _f.itemNeedsField) && getValue(item, item.layer.itemNeedsField).map(function (o) {
3955
- var tag = tags.find(function (t) { return t.id === o.tags_id; });
3956
- return (tag ? React.createElement(TagView, { key: tag === null || tag === void 0 ? void 0 : tag.id, tag: tag, onClick: function () { return addFilterTag(tag); } }) : "");
3957
- }))) : ""),
3961
+ React.createElement("div", { className: 'tw-flex tw-flex-wrap tw-mb-4' }, needs.map(function (n) { return React.createElement(TagView, { key: n === null || n === void 0 ? void 0 : n.id, tag: n, onClick: function () { return addFilterTag(n); } }); }))) : ""),
3958
3962
  React.createElement(TextView, { item: item })))));
3959
3963
  }
3960
3964