@carlonicora/nextjs-jsonapi 1.56.2 → 1.57.0

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.
@@ -47,7 +47,7 @@ import {
47
47
  TabsList,
48
48
  TabsTrigger,
49
49
  useCurrentUserContext
50
- } from "../chunk-HDFJZTQH.mjs";
50
+ } from "../chunk-4FJZ7JFQ.mjs";
51
51
  import {
52
52
  getRoleId,
53
53
  getStripePublishableKey
@@ -8344,7 +8344,7 @@ __name(FormCheckbox, "FormCheckbox");
8344
8344
  import dynamic from "next/dynamic";
8345
8345
  import React14 from "react";
8346
8346
  import { jsx as jsx67 } from "react/jsx-runtime";
8347
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-RWQN3I3L.mjs"), {
8347
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-QWW2LB2K.mjs"), {
8348
8348
  ssr: false
8349
8349
  });
8350
8350
  var BlockNoteEditorContainer = React14.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -8942,6 +8942,53 @@ function FormPlaceAutocomplete({
8942
8942
  setIsLoading(false);
8943
8943
  }
8944
8944
  }, "fetchSuggestions");
8945
+ const fetchPlaceDetails = /* @__PURE__ */ __name(async (placeId) => {
8946
+ const defaults = {
8947
+ street_number: "",
8948
+ street: "",
8949
+ city: "",
8950
+ province: "",
8951
+ region: "",
8952
+ postcode: "",
8953
+ country: "",
8954
+ country_code: ""
8955
+ };
8956
+ if (!apiKey || !placeId) return defaults;
8957
+ try {
8958
+ const response = await fetch(`https://places.googleapis.com/v1/places/${placeId}`, {
8959
+ headers: {
8960
+ "X-Goog-Api-Key": apiKey,
8961
+ "X-Goog-FieldMask": "addressComponents"
8962
+ }
8963
+ });
8964
+ if (!response.ok) return defaults;
8965
+ const data = await response.json();
8966
+ const components = data.addressComponents ?? [];
8967
+ const result = { ...defaults };
8968
+ for (const comp of components) {
8969
+ const types = comp.types ?? [];
8970
+ if (types.includes("street_number")) {
8971
+ result.street_number = comp.longText ?? "";
8972
+ } else if (types.includes("route")) {
8973
+ result.street = comp.longText ?? "";
8974
+ } else if (types.includes("locality")) {
8975
+ result.city = comp.longText ?? "";
8976
+ } else if (types.includes("administrative_area_level_2")) {
8977
+ result.province = comp.longText ?? "";
8978
+ } else if (types.includes("administrative_area_level_1")) {
8979
+ result.region = comp.longText ?? "";
8980
+ } else if (types.includes("postal_code")) {
8981
+ result.postcode = comp.longText ?? "";
8982
+ } else if (types.includes("country")) {
8983
+ result.country = comp.longText ?? "";
8984
+ result.country_code = comp.shortText ?? "";
8985
+ }
8986
+ }
8987
+ return result;
8988
+ } catch {
8989
+ return defaults;
8990
+ }
8991
+ }, "fetchPlaceDetails");
8945
8992
  const handleInputChange = /* @__PURE__ */ __name((value) => {
8946
8993
  setInputValue(value);
8947
8994
  form.setValue(id, value);
@@ -8958,13 +9005,18 @@ function FormPlaceAutocomplete({
8958
9005
  setIsLoading(false);
8959
9006
  }
8960
9007
  }, "handleInputChange");
8961
- const handleSuggestionSelect = /* @__PURE__ */ __name((suggestion) => {
9008
+ const handleSuggestionSelect = /* @__PURE__ */ __name(async (suggestion) => {
8962
9009
  setInputValue(suggestion.description);
8963
9010
  form.setValue(id, suggestion.description);
8964
9011
  setShowSuggestions(false);
8965
9012
  setSuggestions([]);
9013
+ const addressComponents = await fetchPlaceDetails(suggestion.place_id);
9014
+ const enrichedSuggestion = {
9015
+ ...suggestion,
9016
+ addressComponents
9017
+ };
8966
9018
  if (onPlaceSelect) {
8967
- onPlaceSelect(suggestion);
9019
+ onPlaceSelect(enrichedSuggestion);
8968
9020
  }
8969
9021
  }, "handleSuggestionSelect");
8970
9022
  useEffect16(() => {
@@ -18758,4 +18810,4 @@ export {
18758
18810
  useOAuthClients,
18759
18811
  useOAuthClient
18760
18812
  };
18761
- //# sourceMappingURL=chunk-HDFJZTQH.mjs.map
18813
+ //# sourceMappingURL=chunk-4FJZ7JFQ.mjs.map