@timardex/cluemart-shared 1.3.64 → 1.3.66

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.cjs CHANGED
@@ -182,6 +182,8 @@ __export(index_exports, {
182
182
  useGetEventsByRegion: () => useGetEventsByRegion,
183
183
  useGetEventsNearMe: () => useGetEventsNearMe,
184
184
  useGetGoogleImportedMarkets: () => useGetGoogleImportedMarkets,
185
+ useGetGoogleImportedMarketsByRegion: () => useGetGoogleImportedMarketsByRegion,
186
+ useGetGoogleImportedMarketsNearMe: () => useGetGoogleImportedMarketsNearMe,
185
187
  useGetNotificationCount: () => useGetNotificationCount,
186
188
  useGetNotificationCountSubscription: () => useGetNotificationCountSubscription,
187
189
  useGetPartner: () => useGetPartner,
@@ -233,6 +235,7 @@ __export(index_exports, {
233
235
  useResetPassword: () => useResetPassword,
234
236
  useResetPasswordForm: () => useResetPasswordForm,
235
237
  useSearchEvents: () => useSearchEvents,
238
+ useSearchGoogleImportedMarkets: () => useSearchGoogleImportedMarkets,
236
239
  useSearchPartners: () => useSearchPartners,
237
240
  useSearchVendors: () => useSearchVendors,
238
241
  useSelectPackage: () => useSelectPackage,
@@ -5744,40 +5747,40 @@ var APP_SETTINGS_FIELDS_FRAGMENT = import_client64.gql`
5744
5747
  var GOOGLE_IMPORTED_MARKETS_FIELDS_FRAGMENT = import_client64.gql`
5745
5748
  fragment GoogleImportedMarketsFields on GoogleImportedMarketType {
5746
5749
  _id
5747
- name
5748
- slug
5749
- image
5750
+ accessibilityOptions
5750
5751
  address
5751
- location {
5752
- lat
5753
- lng
5754
- }
5755
- googlePlaceId
5756
- website
5757
- phone
5758
- openingHours
5759
- rating
5760
- reviewCount
5761
- photos
5762
- googleMapsUrl
5763
- businessStatus
5764
5752
  addressComponents {
5765
5753
  longName
5766
5754
  shortName
5767
5755
  types
5768
5756
  }
5769
- accessibilityOptions
5770
5757
  allowsDogs
5758
+ businessStatus
5759
+ claimed
5760
+ createdAt
5771
5761
  goodForChildren
5772
5762
  goodForGroups
5763
+ googleMapsUrl
5764
+ googlePlaceId
5765
+ image
5766
+ importedAt
5773
5767
  liveMusic
5768
+ location {
5769
+ lat
5770
+ lng
5771
+ }
5772
+ name
5773
+ openingHours
5774
5774
  parkingOptions
5775
5775
  paymentOptions
5776
+ phone
5777
+ photos
5778
+ rating
5776
5779
  restroom
5777
- importedAt
5778
- claimed
5779
- createdAt
5780
+ reviewCount
5781
+ slug
5780
5782
  updatedAt
5783
+ website
5781
5784
  }
5782
5785
  `;
5783
5786
  var GET_APP_SETTINGS = import_client64.gql`
@@ -5796,6 +5799,38 @@ var GET_GOOGLE_IMPORTED_MARKETS = import_client64.gql`
5796
5799
  }
5797
5800
  ${GOOGLE_IMPORTED_MARKETS_FIELDS_FRAGMENT}
5798
5801
  `;
5802
+ var GET_GOOGLE_IMPORTED_MARKETS_BY_REGION = import_client64.gql`
5803
+ query getGoogleImportedMarketsByRegion($region: String!) {
5804
+ googleImportedMarketsByRegion(region: $region) {
5805
+ ...GoogleImportedMarketsFields
5806
+ }
5807
+ }
5808
+ ${GOOGLE_IMPORTED_MARKETS_FIELDS_FRAGMENT}
5809
+ `;
5810
+ var SEARCH_GOOGLE_IMPORTED_MARKETS = import_client64.gql`
5811
+ query searchGoogleImportedMarkets($search: String!, $region: String) {
5812
+ googleImportedMarketsSearch(search: $search, region: $region) {
5813
+ ...GoogleImportedMarketsFields
5814
+ }
5815
+ }
5816
+ ${GOOGLE_IMPORTED_MARKETS_FIELDS_FRAGMENT}
5817
+ `;
5818
+ var GET_GOOGLE_IMPORTED_MARKETS_NEAR_ME = import_client64.gql`
5819
+ query getGoogleImportedMarketsNearMe(
5820
+ $latitude: Float!
5821
+ $longitude: Float!
5822
+ $radius: Int
5823
+ ) {
5824
+ googleImportedMarketsNearMe(
5825
+ lat: $latitude
5826
+ lng: $longitude
5827
+ radius: $radius
5828
+ ) {
5829
+ ...GoogleImportedMarketsFields
5830
+ }
5831
+ }
5832
+ ${GOOGLE_IMPORTED_MARKETS_FIELDS_FRAGMENT}
5833
+ `;
5799
5834
 
5800
5835
  // src/graphql/hooks/appSettings/hooksMutation.ts
5801
5836
  var useUpdateAppSettings = () => {
@@ -5829,6 +5864,38 @@ var useGetGoogleImportedMarkets = () => {
5829
5864
  const googleImportedMarkets = data?.googleImportedMarkets || [];
5830
5865
  return { error, googleImportedMarkets, loading, refetch };
5831
5866
  };
5867
+ var useGetGoogleImportedMarketsByRegion = (region) => {
5868
+ const { loading, error, data, refetch } = (0, import_client66.useQuery)(GET_GOOGLE_IMPORTED_MARKETS_BY_REGION, {
5869
+ fetchPolicy: "network-only",
5870
+ skip: !region,
5871
+ variables: { region }
5872
+ });
5873
+ const googleImportedMarketsByRegion = data?.googleImportedMarketsByRegion || [];
5874
+ return { error, googleImportedMarketsByRegion, loading, refetch };
5875
+ };
5876
+ var useSearchGoogleImportedMarkets = (search, region) => {
5877
+ const { loading, error, data, refetch } = (0, import_client66.useQuery)(SEARCH_GOOGLE_IMPORTED_MARKETS, {
5878
+ fetchPolicy: "network-only",
5879
+ skip: search.length < 3,
5880
+ variables: { region, search }
5881
+ });
5882
+ const googleImportedMarketsSearch = data?.googleImportedMarketsSearch || [];
5883
+ return { error, googleImportedMarketsSearch, loading, refetch };
5884
+ };
5885
+ var useGetGoogleImportedMarketsNearMe = (latitude, longitude, radius) => {
5886
+ const { loading, error, data, refetch } = (0, import_client66.useQuery)(GET_GOOGLE_IMPORTED_MARKETS_NEAR_ME, {
5887
+ fetchPolicy: "network-only",
5888
+ skip: !latitude || !longitude,
5889
+ variables: {
5890
+ latitude,
5891
+ longitude,
5892
+ radius: radius || 1e4
5893
+ // Default to 10km if no radius is provided
5894
+ }
5895
+ });
5896
+ const googleImportedMarketsNearMe = data?.googleImportedMarketsNearMe || [];
5897
+ return { error, googleImportedMarketsNearMe, loading, refetch };
5898
+ };
5832
5899
 
5833
5900
  // src/hooks/useLocationSearch.ts
5834
5901
  var handleApiError = (error, message) => {
@@ -5838,13 +5905,31 @@ var useLocationSearch = (googleApi) => {
5838
5905
  const getPredictions = async (text) => {
5839
5906
  try {
5840
5907
  const response = await fetch(
5841
- `https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${text}&components=country:nz&key=${googleApi}`
5908
+ "https://places.googleapis.com/v1/places:autocomplete",
5909
+ {
5910
+ body: JSON.stringify({
5911
+ includedRegionCodes: ["nz"],
5912
+ input: text,
5913
+ languageCode: "en"
5914
+ }),
5915
+ headers: {
5916
+ "Content-Type": "application/json",
5917
+ "X-Goog-Api-Key": googleApi,
5918
+ "X-Goog-FieldMask": "suggestions.placePrediction.placeId,suggestions.placePrediction.text.text"
5919
+ },
5920
+ method: "POST"
5921
+ }
5842
5922
  );
5843
5923
  if (!response.ok) {
5844
5924
  throw new Error(`HTTP error! Status: ${response.status}`);
5845
5925
  }
5846
5926
  const data = await response.json();
5847
- return data.predictions;
5927
+ const suggestions = data.suggestions ?? [];
5928
+ const predictions = suggestions.map((suggestion) => suggestion.placePrediction).filter(Boolean).map((prediction) => ({
5929
+ description: prediction?.text?.text || "",
5930
+ place_id: prediction?.placeId || ""
5931
+ })).filter((prediction) => prediction.place_id && prediction.description);
5932
+ return predictions;
5848
5933
  } catch (error) {
5849
5934
  console.error("Error fetching predictions:", error);
5850
5935
  handleApiError(error, "Failed to fetch address predictions.");
@@ -5853,42 +5938,47 @@ var useLocationSearch = (googleApi) => {
5853
5938
  const getPlaceDetails = async (placeId) => {
5854
5939
  try {
5855
5940
  const response = await fetch(
5856
- `https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeId}&key=${googleApi}`
5941
+ `https://places.googleapis.com/v1/places/${placeId}`,
5942
+ {
5943
+ headers: {
5944
+ "X-Goog-Api-Key": googleApi,
5945
+ "X-Goog-FieldMask": "addressComponents,formattedAddress,location"
5946
+ }
5947
+ }
5857
5948
  );
5858
5949
  if (!response.ok) {
5859
5950
  throw new Error(`HTTP error! Status: ${response.status}`);
5860
5951
  }
5861
- const data = await response.json();
5862
- const { result } = data;
5863
- const { lat, lng } = result.geometry.location;
5864
- const { address_components, formatted_address } = result;
5865
- const address = address_components.reduce((acc, item) => {
5952
+ const result = await response.json();
5953
+ const { latitude, longitude } = result.location;
5954
+ const { addressComponents, formattedAddress } = result;
5955
+ const address = addressComponents.reduce((acc, item) => {
5866
5956
  if (item.types.includes("street_number")) {
5867
- return { ...acc, streetNumber: item.long_name };
5957
+ return { ...acc, streetNumber: item.longText };
5868
5958
  }
5869
5959
  if (item.types.includes("route")) {
5870
- return { ...acc, streetName: item.long_name };
5960
+ return { ...acc, streetName: item.longText };
5871
5961
  }
5872
5962
  if (item.types.includes("locality")) {
5873
- return { ...acc, city: item.long_name };
5963
+ return { ...acc, city: item.longText };
5874
5964
  }
5875
5965
  if (item.types.includes("administrative_area_level_1")) {
5876
- return { ...acc, region: item.long_name };
5966
+ return { ...acc, region: item.longText };
5877
5967
  }
5878
5968
  if (item.types.includes("country")) {
5879
- return { ...acc, country: item.long_name };
5969
+ return { ...acc, country: item.longText };
5880
5970
  }
5881
5971
  return acc;
5882
5972
  }, {});
5883
5973
  const newLocation = {
5884
- city: address.city.toLowerCase(),
5885
- coordinates: [lng, lat],
5974
+ city: address.city ? address.city.toLowerCase() : "",
5975
+ coordinates: [longitude, latitude],
5886
5976
  // [longitude, latitude]
5887
5977
  country: address.country,
5888
- fullAddress: formatted_address,
5889
- latitude: lat,
5890
- longitude: lng,
5891
- region: address.region.replace(/ Region$/, ""),
5978
+ fullAddress: formattedAddress,
5979
+ latitude,
5980
+ longitude,
5981
+ region: address.region ? address.region.replace(/ Region$/, "") : "",
5892
5982
  // Remove " Region" suffix
5893
5983
  type: "Point"
5894
5984
  // Mongoose GeoJSON type
@@ -7927,6 +8017,8 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
7927
8017
  useGetEventsByRegion,
7928
8018
  useGetEventsNearMe,
7929
8019
  useGetGoogleImportedMarkets,
8020
+ useGetGoogleImportedMarketsByRegion,
8021
+ useGetGoogleImportedMarketsNearMe,
7930
8022
  useGetNotificationCount,
7931
8023
  useGetNotificationCountSubscription,
7932
8024
  useGetPartner,
@@ -7978,6 +8070,7 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
7978
8070
  useResetPassword,
7979
8071
  useResetPasswordForm,
7980
8072
  useSearchEvents,
8073
+ useSearchGoogleImportedMarkets,
7981
8074
  useSearchPartners,
7982
8075
  useSearchVendors,
7983
8076
  useSelectPackage,