@mxenabled/connect-widget 0.10.3 → 0.11.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.
package/dist/index.es.js CHANGED
@@ -74061,8 +74061,10 @@ const getStyles$l = (tokens) => ({
74061
74061
  flexDirection: "column"
74062
74062
  },
74063
74063
  svg: {
74064
+ display: "flex",
74065
+ alignItems: "center",
74064
74066
  margin: "0 auto",
74065
- width: 200
74067
+ width: 240
74066
74068
  },
74067
74069
  title: {
74068
74070
  marginBottom: tokens.Spacing.XSmall
@@ -74889,46 +74891,73 @@ const getViewByStatus = (status) => {
74889
74891
  const VerifyExistingMember = (props) => {
74890
74892
  useAnalyticsPath(...PageviewInfo.CONNECT_VERIFY_EXISTING_MEMBER);
74891
74893
  const { api } = useApi();
74894
+ const config = useSelector(selectConfig);
74892
74895
  const dispatch = useDispatch();
74893
74896
  const { members, onAddNew } = props;
74894
- const iavMembers = members.filter(
74895
- (member) => member.verification_is_enabled && member.is_managed_by_user
74896
- // Only show user-managed members that support verification
74897
- );
74898
- const [selectedMember, setSelectedMember] = useState(null);
74899
- const [{ isLoadingInstitution, institutionError }, setInstitution] = useState({
74900
- isLoadingInstitution: false,
74901
- institutionError: null
74902
- });
74897
+ const iavMembers = useMemo(() => {
74898
+ return members.filter(
74899
+ (member) => member.verification_is_enabled && member.is_managed_by_user
74900
+ // Only show user-managed members that support verification
74901
+ );
74902
+ }, [members]);
74903
+ const [institutions, setInstitutions] = useState(/* @__PURE__ */ new Map());
74904
+ const [loading, setLoading] = useState(true);
74905
+ const [error, setError] = useState(null);
74903
74906
  const tokens = useTokens();
74904
74907
  const styles = getStyles$g(tokens);
74905
- const handleMemberClick = (selectedMember2) => {
74906
- setSelectedMember(selectedMember2);
74907
- setInstitution((state) => ({ ...state, isLoadingInstitution: true }));
74908
- };
74908
+ const handleMemberClick = useCallback(
74909
+ (selectedMember) => {
74910
+ const institution = institutions.get(selectedMember.institution_guid);
74911
+ if (institution) {
74912
+ if (selectedMember.is_oauth) {
74913
+ dispatch(startOauth$1(selectedMember, institution));
74914
+ } else {
74915
+ dispatch(verifyExistingConnection$1(selectedMember, institution));
74916
+ }
74917
+ }
74918
+ },
74919
+ [dispatch, institutions]
74920
+ );
74909
74921
  useEffect(() => {
74910
74922
  focusElement(document.getElementById("connect-select-institution"));
74911
74923
  }, []);
74912
74924
  useEffect(() => {
74913
- if (!isLoadingInstitution || !selectedMember) return;
74914
- api.loadInstitutionByGuid(selectedMember.institution_guid).then((institution) => {
74915
- if (selectedMember.is_oauth) {
74916
- dispatch(startOauth$1(selectedMember, institution));
74917
- } else {
74918
- dispatch(verifyExistingConnection$1(selectedMember, institution));
74925
+ const fetchInstitutionsProgressively = async () => {
74926
+ setLoading(true);
74927
+ setError(null);
74928
+ const institutionMap = /* @__PURE__ */ new Map();
74929
+ for (const member of iavMembers) {
74930
+ try {
74931
+ const institution = await api.loadInstitutionByGuid(member.institution_guid);
74932
+ if (institution) {
74933
+ institutionMap.set(member.institution_guid, institution);
74934
+ }
74935
+ } catch (err) {
74936
+ setError(err);
74937
+ }
74919
74938
  }
74920
- }).catch((error) => {
74921
- setInstitution((state) => ({
74922
- ...state,
74923
- isLoadingInstitution: false,
74924
- institutionError: error
74925
- }));
74939
+ setInstitutions(new Map(institutionMap));
74940
+ setLoading(false);
74941
+ };
74942
+ if (iavMembers.length > 0) {
74943
+ fetchInstitutionsProgressively();
74944
+ } else {
74945
+ setLoading(false);
74946
+ }
74947
+ }, [api, iavMembers]);
74948
+ const productSupportingMembers = useMemo(() => {
74949
+ return iavMembers.filter((member) => {
74950
+ const institution = institutions.get(member.institution_guid);
74951
+ if (institution) {
74952
+ return instutionSupportRequestedProducts(config, institution);
74953
+ }
74954
+ return false;
74926
74955
  });
74927
- }, [isLoadingInstitution, selectedMember]);
74928
- if (isLoadingInstitution) {
74956
+ }, [config, institutions, iavMembers]);
74957
+ if (loading) {
74929
74958
  return /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingSpinner, { showText: true });
74930
74959
  }
74931
- if (institutionError) {
74960
+ if (error) {
74932
74961
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
74933
74962
  GenericError,
74934
74963
  {
@@ -74975,12 +75004,12 @@ const VerifyExistingMember = (props) => {
74975
75004
  children: _n(
74976
75005
  "%1 Connected institution",
74977
75006
  "%1 Connected institutions",
74978
- iavMembers.length,
74979
- iavMembers.length
75007
+ productSupportingMembers.length,
75008
+ productSupportingMembers.length
74980
75009
  )
74981
75010
  }
74982
75011
  ),
74983
- iavMembers.map((member) => {
75012
+ productSupportingMembers.map((member) => {
74984
75013
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
74985
75014
  UtilityRow,
74986
75015
  {