import { useRouter } from 'next/router';
import { useWindowDimensions } from '@sentecacommerce-theme/lib';
export function useProfileState() {
  var _router$query$tab, _router$query$tab2;

  var router = useRouter();
  var {
    width
  } = useWindowDimensions();

  if (((_router$query$tab = router.query.tab) == null ? void 0 : _router$query$tab[0]) === undefined && width > 768) {
    return {
      profileTab: 'personal-info'
    };
  }

  return {
    profileTab: ((_router$query$tab2 = router.query.tab) == null ? void 0 : _router$query$tab2[0]) || ''
  };
}
export function useProfileDispatch() {
  var router = useRouter();
  var actions = {
    change: payload => {
      if (payload === 'favorites') router.push('/favorites');
      router.push("/profile/" + payload, undefined, {
        shallow: true
      });
    },
    reset: () => {
      router.push("/profile");
    }
  };
  return (_ref) => {
    var {
      type,
      payload
    } = _ref;

    if (!actions[type]) {
      throw new Error('useProfileDispatch action type not found');
    }

    actions[type](payload);
  };
}
//# sourceMappingURL=profile.context.js.map