mozrest-sdk-react-dev 0.2.18 → 0.2.20

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.
Files changed (2) hide show
  1. package/mozrest-sdk.es.js +27 -31
  2. package/package.json +1 -1
package/mozrest-sdk.es.js CHANGED
@@ -35493,9 +35493,11 @@ const TemplateUpdate = ({
35493
35493
  return reply2;
35494
35494
  };
35495
35495
  useEffect(() => {
35496
- if (template) {
35496
+ if (template && template !== "change") {
35497
35497
  setFieldValue("comment", handleChange(template));
35498
35498
  setTemplate("");
35499
+ } else if (template === "change") {
35500
+ setFieldValue("comment", "");
35499
35501
  }
35500
35502
  }, [template]);
35501
35503
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
@@ -43977,7 +43979,8 @@ const SuggestReviewReply = async ({
43977
43979
  };
43978
43980
  const ContextVenue = React__default.createContext([
43979
43981
  null,
43980
- null,
43982
+ (value2) => {
43983
+ },
43981
43984
  null,
43982
43985
  []
43983
43986
  ]);
@@ -44000,11 +44003,11 @@ const Review = ({
44000
44003
  multiVenue,
44001
44004
  setShowTemplate
44002
44005
  }) => {
44003
- const [venue, venueListingId, venueListing, issues] = useContext(ContextVenue);
44006
+ const [venueListingId, , venueListing, issues] = useContext(ContextVenue);
44004
44007
  const [, setTemplate] = useContext(ContextTemplate);
44005
44008
  const { execute, isExecuting, data: data2 } = useService(SuggestReviewReply);
44006
44009
  const onSuggestTemplate = () => {
44007
- const filteredIssues = issues.filter((i) => id2 !== i.id);
44010
+ const filteredIssues = issues.filter((i) => id2 !== i.id && i.comment && i.reply && i.reply.comment);
44008
44011
  const toSend = {
44009
44012
  reviewer_data: {
44010
44013
  reviewer_name: reviewer2.name,
@@ -44018,9 +44021,9 @@ const Review = ({
44018
44021
  Description: venueListing.descriptionLong ? venueListing.descriptionLong : venueListing.descriptionShort ? venueListing.descriptionShort : null,
44019
44022
  Price: "Moderate",
44020
44023
  Attributes: venueListing.attributesNames,
44021
- Address: venue.address,
44022
- City: venue.city,
44023
- Country: venue.countryCode
44024
+ Address: venueListing.address,
44025
+ City: venueListing.city,
44026
+ Country: venueListing.country && venueListing.country.id
44024
44027
  },
44025
44028
  example: {
44026
44029
  review_1: filteredIssues.length > 0 ? filteredIssues[0].comment : null,
@@ -44182,8 +44185,11 @@ const ContextReview = React__default.createContext([
44182
44185
  const Reviews = ({ reviews, isEmpty, onReload, multiVenue, setShowTemplate }) => {
44183
44186
  const { t: t2 } = useTranslation();
44184
44187
  const [, setReview] = useContext(ContextReview);
44188
+ const [, setVenueListingId, ,] = useContext(ContextVenue);
44189
+ const [, setTemplate] = useContext(ContextTemplate);
44185
44190
  const [reviewSelected, setReviewSelected] = useState();
44186
44191
  const handleToggleForm = (id2) => () => {
44192
+ setTemplate("change");
44187
44193
  setReviewSelected((current) => {
44188
44194
  if (current === id2) {
44189
44195
  return "";
@@ -44193,6 +44199,7 @@ const Reviews = ({ reviews, isEmpty, onReload, multiVenue, setShowTemplate }) =>
44193
44199
  const selected = reviews.find((review) => review.id === id2);
44194
44200
  if (selected) {
44195
44201
  setReview(selected);
44202
+ setVenueListingId(selected.venueListingId);
44196
44203
  }
44197
44204
  };
44198
44205
  return /* @__PURE__ */ React__default.createElement(Card, {
@@ -50369,17 +50376,6 @@ var styles$1s = {
50369
50376
  grid,
50370
50377
  footer: footer$e
50371
50378
  };
50372
- const getVenue = async ({ venueId }) => {
50373
- const data2 = await instance$1.get(`/venues/${venueId}`);
50374
- return data2;
50375
- };
50376
- const GetVenueListingId = async ({
50377
- venueId,
50378
- externalId
50379
- }) => {
50380
- const data2 = await instance$1.get(`listing/venue-listing-id?venueId=${venueId || externalId}`);
50381
- return { id: data2.venueListingId };
50382
- };
50383
50379
  var lib$1 = {};
50384
50380
  var runtime = { exports: {} };
50385
50381
  (function(module2) {
@@ -51008,7 +51004,7 @@ const GetVenueListing = async ({
51008
51004
  venueListingId,
51009
51005
  accessToken
51010
51006
  }) => {
51011
- if (venueListingId && venueListingId !== null) {
51007
+ if (venueListingId && venueListingId !== null && venueListingId !== "") {
51012
51008
  const data2 = await instance$1.get(`/listing/venue-listing/${venueListingId}`, {
51013
51009
  headers: {
51014
51010
  Authorization: `Bearer ${accessToken}`
@@ -51159,6 +51155,7 @@ const ReviewsPage = ({
51159
51155
  const { t: t2 } = useTranslation();
51160
51156
  const [context, setContext] = useState("");
51161
51157
  const [review, setReview] = useState();
51158
+ const [venueListingId, setVenueListingId] = useState(null);
51162
51159
  const [showReplyTemplates, setShowReplyTemplates] = useState(false);
51163
51160
  const [filter2, setFilters] = useState({
51164
51161
  range: {
@@ -51172,17 +51169,9 @@ const ReviewsPage = ({
51172
51169
  const { data: data2 } = useFetch(GetVenueListingsOptions, {
51173
51170
  cacheId: `venueListing-options`
51174
51171
  });
51175
- const { data: venue } = useFetch(getVenue, {
51176
- cacheId: `venue-data`,
51177
- venueId
51178
- });
51179
- const { data: venueListingId } = useFetch(GetVenueListingId, {
51180
- cacheId: `venue-listing-${venueId}`,
51181
- venueId
51182
- });
51183
51172
  const { data: venueListing, reload: reloadVenueListing } = useFetch(GetVenueListing, {
51184
- cacheId: `venue-listing-${venueListingId ? venueListingId.id : null}`,
51185
- venueListingId: venueListingId ? venueListingId.id : null
51173
+ cacheId: `venue-listing-${venueListingId ? venueListingId : null}`,
51174
+ venueListingId: venueListingId ? venueListingId : ""
51186
51175
  });
51187
51176
  const multiVenue = (data2 == null ? void 0 : data2.total) > 1;
51188
51177
  const {
@@ -51199,7 +51188,7 @@ const ReviewsPage = ({
51199
51188
  params: filter2
51200
51189
  });
51201
51190
  useEffect(() => {
51202
- if (venueListingId && venueListingId.id) {
51191
+ if (venueListingId && venueListingId) {
51203
51192
  reloadVenueListing();
51204
51193
  }
51205
51194
  }, [venueListingId]);
@@ -51217,7 +51206,7 @@ const ReviewsPage = ({
51217
51206
  venueId
51218
51207
  })
51219
51208
  }, /* @__PURE__ */ React__default.createElement(ContextVenue.Provider, {
51220
- value: [venue, venueListingId ? venueListingId.id : null, venueListing, issues]
51209
+ value: [venueListingId, setVenueListingId, venueListing, issues]
51221
51210
  }, /* @__PURE__ */ React__default.createElement(ContextTemplate.Provider, {
51222
51211
  value: [context, setContext]
51223
51212
  }, /* @__PURE__ */ React__default.createElement(ContextReview.Provider, {
@@ -79735,6 +79724,13 @@ const WorkingPage = () => {
79735
79724
  allowFullScreen: true
79736
79725
  }));
79737
79726
  };
79727
+ const GetVenueListingId = async ({
79728
+ venueId,
79729
+ externalId
79730
+ }) => {
79731
+ const data2 = await instance$1.get(`listing/venue-listing-id?venueId=${venueId || externalId}`);
79732
+ return { id: data2.venueListingId };
79733
+ };
79738
79734
  const VenueListingIdProvider = ({
79739
79735
  children,
79740
79736
  venueId = "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozrest-sdk-react-dev",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "main": "mozrest-sdk.es.js",
5
5
  "keywords": ["mozrest"],
6
6
  "author": {