@mindbill/react 0.77.49 → 0.77.50

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
@@ -12783,15 +12783,21 @@ function RfaPracticePicker({ profile, value, onChange, managePracticeHref, manag
12783
12783
  const practices = profile?.billingProviders ?? [];
12784
12784
  const [practice, setPractice] = useState23(() => practices.find((item) => item.name === value?.name)?.id ?? "");
12785
12785
  const [location, setLocation] = useState23(() => practice ? (profile?.locations ?? []).find((item) => item.active !== false && item.street === value?.address && (!item.billingProviderId || item.billingProviderId === practice))?.id ?? "" : "");
12786
- const located = (chosen, phone) => ({ address: chosen.street, city: chosen.city, state: chosen.state, zip: chosen.zip, ...chosen.contact?.name ? { contactName: chosen.contact.name } : {}, ...chosen.contact?.phone || phone ? { phone: chosen.contact?.phone || phone } : {}, ...chosen.contact?.fax ? { fax: chosen.contact.fax } : {}, ...chosen.contact?.email ? { email: chosen.contact.email } : {} });
12786
+ const contactOf = (saved) => saved?.contact ?? {};
12787
+ const contactFields = (provider, chosen) => {
12788
+ const own = chosen?.contact ?? {}, shared = contactOf(provider);
12789
+ const name = own.name || shared.name, fax = own.fax || shared.fax, email = own.email || shared.email;
12790
+ return { phone: own.phone || shared.phone || provider?.phone || "", ...name ? { contactName: name } : {}, ...fax ? { fax } : {}, ...email ? { email } : {} };
12791
+ };
12792
+ const located = (chosen, provider) => ({ address: chosen.street, city: chosen.city, state: chosen.state, zip: chosen.zip, ...contactFields(provider, chosen) });
12787
12793
  const savedPractice = practices.find((item) => item.id === practice), savedLocation = (profile?.locations ?? []).find((item) => item.id === location);
12788
- const savedKey = JSON.stringify([savedPractice?.name, savedPractice?.phone, savedPractice?.billingStreet, savedPractice?.billingCity, savedPractice?.billingState, savedPractice?.billingZip, savedLocation?.street, savedLocation?.city, savedLocation?.state, savedLocation?.zip, savedLocation?.contact]);
12794
+ const savedKey = JSON.stringify([savedPractice?.name, savedPractice?.phone, savedPractice?.billingStreet, savedPractice?.billingCity, savedPractice?.billingState, savedPractice?.billingZip, contactOf(savedPractice), savedLocation?.street, savedLocation?.city, savedLocation?.state, savedLocation?.zip, savedLocation?.contact]);
12789
12795
  const appliedKey = useRef18(savedKey);
12790
12796
  useEffect20(() => {
12791
12797
  if (appliedKey.current === savedKey) return;
12792
12798
  appliedKey.current = savedKey;
12793
12799
  if (!savedPractice) return;
12794
- onChange({ ...value, name: savedPractice.name, phone: savedPractice.phone ?? "", address: savedPractice.billingStreet ?? "", city: savedPractice.billingCity ?? "", state: savedPractice.billingState ?? "", zip: savedPractice.billingZip ?? "", ...savedLocation ? located(savedLocation, savedPractice.phone) : {} });
12800
+ onChange({ ...value, name: savedPractice.name, address: savedPractice.billingStreet ?? "", city: savedPractice.billingCity ?? "", state: savedPractice.billingState ?? "", zip: savedPractice.billingZip ?? "", ...contactFields(savedPractice), ...savedLocation ? located(savedLocation, savedPractice) : {} });
12795
12801
  }, [savedKey]);
12796
12802
  const [practiceQuery, setPracticeQuery] = useState23("");
12797
12803
  const [locationQuery, setLocationQuery] = useState23("");
@@ -12805,7 +12811,7 @@ function RfaPracticePicker({ profile, value, onChange, managePracticeHref, manag
12805
12811
  const primary = matching.filter((item) => item.isPrimary);
12806
12812
  const chosen = matching.length === 1 ? matching[0] : primary.length === 1 ? primary[0] : void 0;
12807
12813
  setLocation(chosen?.id ?? "");
12808
- onChange({ ...value, name: provider.name, phone: provider.phone ?? "", address: provider.billingStreet ?? "", city: provider.billingCity ?? "", state: provider.billingState ?? "", zip: provider.billingZip ?? "", ...chosen ? located(chosen, provider.phone) : {} });
12814
+ onChange({ ...value, name: provider.name, address: provider.billingStreet ?? "", city: provider.billingCity ?? "", state: provider.billingState ?? "", zip: provider.billingZip ?? "", ...contactFields(provider), ...chosen ? located(chosen, provider) : {} });
12809
12815
  };
12810
12816
  const onlyPractice = practices.length === 1 && !practice && !value?.name?.trim() && !value?.address?.trim() ? practices[0].id : "";
12811
12817
  useEffect20(() => {
@@ -12829,7 +12835,7 @@ function RfaPracticePicker({ profile, value, onChange, managePracticeHref, manag
12829
12835
  setLocation(id);
12830
12836
  setLocationQuery("");
12831
12837
  onChosen?.();
12832
- onChange({ ...value, ...located(chosen, practices.find((item) => item.id === practice)?.phone) });
12838
+ onChange({ ...value, ...located(chosen, practices.find((item) => item.id === practice)) });
12833
12839
  };
12834
12840
  const ADD = "__add__";
12835
12841
  return /* @__PURE__ */ jsxs36(Fragment21, { children: [