How to use append-query - 10 common examples

To help you get started, we’ve selected a few append-query examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github department-of-veterans-affairs / vets-website / src / applications / disability-benefits / 686 / components / AuthorizationMessage.jsx View on Github external
import React from 'react';
import appendQuery from 'append-query';
import PropTypes from 'prop-types';

import isBrandConsolidationEnabled from '../../../../platform/brand-consolidation/feature-flag';
import CallVBACenter from '../../../../platform/brand-consolidation/components/CallVBACenter';

import disabilityIncreaseManifest from '../../526EZ/manifest.json';

const propertyName = isBrandConsolidationEnabled() ? 'VA.gov' : 'Vets.gov';
const { rootUrl: increaseRootUrl } = disabilityIncreaseManifest;
import { profileStatuses } from '../helpers';

const { SERVER_ERROR, NOT_FOUND } = profileStatuses;
const nextQuery = { next: window.location.pathname };
const signInUrl = appendQuery('/', nextQuery);
const verifyUrl = appendQuery('/verify', nextQuery);

export default class AuthorizationMessage extends React.Component {
  redirectToAuthentication = () => {
    if (!this.props.user.isLoggedIn) window.location.replace(signInUrl);
    else if (!this.props.user.isVerified) window.location.replace(verifyUrl);
  };

  // eslint-disable-next-line consistent-return
  render() {
    const {
      has30PercentDisabilityRating,
      user: { profileStatus, isLoggedIn, isVerified },
    } = this.props;
    if (profileStatus === SERVER_ERROR) {
      // If va_profile is null, show a system down message.
github department-of-veterans-affairs / vets-website / src / platform / user / authorization / components / RequiredLoginView.jsx View on Github external
import appendQuery from 'append-query';
import PropTypes from 'prop-types';
import React from 'react';
import { intersection } from 'lodash';

import LoadingIndicator from '@department-of-veterans-affairs/formation-react/LoadingIndicator';
import SystemDownView from '@department-of-veterans-affairs/formation-react/SystemDownView';
import SubmitSignInForm from '../../../static-data/SubmitSignInForm';

import backendServices from '../../profile/constants/backendServices';
import { hasSession } from '../../profile/utilities';

const nextQuery = { next: window.location.pathname };
const signInUrl = appendQuery('/', nextQuery);
const verifyUrl = appendQuery('/verify', nextQuery);

class RequiredLoginView extends React.Component {
  componentDidMount() {
    this.redirectIfNeeded();
  }

  componentDidUpdate() {
    this.redirectIfNeeded();
  }

  shouldSignIn = () => !this.props.user.login.currentlyLoggedIn;

  shouldVerify = () => {
    const { user, verify } = this.props;

    // Certain sign-in methods can grant access to the service,
github department-of-veterans-affairs / vets-website / src / platform / user / authorization / containers / MHVApp.jsx View on Github external
const { accountState } = this.props.mhvAccount;

    // Unverified accounts should have been handled before this component
    // rendered, but if it hasn't for some reason, we will redirect now.
    if (accountState === 'needs_identity_verification') {
      const nextQuery = { next: window.location.pathname };
      const verifyUrl = appendQuery('/verify', nextQuery);
      window.location.replace(verifyUrl);
      return;
    }

    switch (accountState) {
      case 'needs_terms_acceptance': {
        const redirectQuery = { tc_redirect: window.location.pathname }; // eslint-disable-line camelcase
        const termsConditionsUrl = appendQuery('/health-care/medical-information-terms-conditions', redirectQuery);
        window.location.replace(termsConditionsUrl);
        break;
      }

      case 'no_account':
        this.props.createMHVAccount();
        break;

      case 'existing':
      case 'registered':
        this.props.upgradeMHVAccount();
        break;

      case 'upgraded': {
        const forceCacheClear = true;
        this.props.refreshProfile(forceCacheClear);
github department-of-veterans-affairs / vets-website / src / platform / site-wide / cta-widget / index.js View on Github external
const redirectToTermsAndConditions = () => {
      const redirectQuery = { tc_redirect: window.location.pathname }; // eslint-disable-line camelcase
      const termsConditionsUrl = appendQuery(
        '/health-care/medical-information-terms-conditions/',
        redirectQuery,
      );
      window.location = termsConditionsUrl;
    };
github department-of-veterans-affairs / vets-website / src / applications / gi / actions / index.js View on Github external
export function fetchProgramAutocompleteSuggestions(term, version) {
  const url = appendQuery(`${api.url}/institution_programs/autocomplete`, {
    term,
    version,
  });
  return dispatch =>
    fetch(url, api.settings)
      .then(res => res.json())
      .then(
        payload => dispatch({ type: AUTOCOMPLETE_SUCCEEDED, payload }),
        err => dispatch({ type: AUTOCOMPLETE_FAILED, err }),
      );
}
github department-of-veterans-affairs / vets-website / src / platform / user / authorization / components / RequiredLoginView.jsx View on Github external
import appendQuery from 'append-query';
import PropTypes from 'prop-types';
import React from 'react';
import { intersection } from 'lodash';

import LoadingIndicator from '@department-of-veterans-affairs/formation-react/LoadingIndicator';
import SystemDownView from '@department-of-veterans-affairs/formation-react/SystemDownView';
import SubmitSignInForm from '../../../static-data/SubmitSignInForm';

import backendServices from '../../profile/constants/backendServices';
import { hasSession } from '../../profile/utilities';

const nextQuery = { next: window.location.pathname };
const signInUrl = appendQuery('/', nextQuery);
const verifyUrl = appendQuery('/verify', nextQuery);

class RequiredLoginView extends React.Component {
  componentDidMount() {
    this.redirectIfNeeded();
  }

  componentDidUpdate() {
    this.redirectIfNeeded();
  }

  shouldSignIn = () => !this.props.user.login.currentlyLoggedIn;

  shouldVerify = () => {
    const { user, verify } = this.props;
github department-of-veterans-affairs / vets-website / src / platform / utilities / api / index.js View on Github external
.then(response => {
      const data = isJson(response)
        ? response.json()
        : Promise.resolve(response);

      if (!response.ok) {
        const { pathname } = window.location;
        const shouldRedirectToLogin =
          response.status === 401 && !pathname.includes('auth/login/callback');

        if (shouldRedirectToLogin) {
          const loginUrl = appendQuery(environment.BASE_URL, {
            next: pathname,
          });
          window.location.href = loginUrl;
        }

        return data.then(Promise.reject.bind(Promise));
      }

      return data;
    })
    .then(success)
github department-of-veterans-affairs / vets-website / src / applications / personalization / beta-enrollment / containers / BetaEnrollmentButton.jsx View on Github external
onClick = () => {
    if (this.props.user.login.currentlyLoggedIn) {
      this.setState({ isEnrolling: true });
      this.props.registerBeta(this.props.feature).then(this.onRegistered).catch(this.onError);
    } else {
      const nextQuery = { next: window.location.pathname };
      const signInUrl = appendQuery('/', nextQuery);
      window.location.replace(signInUrl);
    }
  }
github department-of-veterans-affairs / vets-website / src / applications / gi / actions / index.js View on Github external
export function fetchInstitutionAutocompleteSuggestions(term, version) {
  const url = appendQuery(`${api.url}/institutions/autocomplete`, {
    term,
    version,
  });
  return dispatch =>
    fetch(url, api.settings)
      .then(res => res.json())
      .then(
        payload => dispatch({ type: AUTOCOMPLETE_SUCCEEDED, payload }),
        err => dispatch({ type: AUTOCOMPLETE_FAILED, err }),
      );
}
github department-of-veterans-affairs / vets-website / src / applications / disability-benefits / 526EZ / components / DisabilityWizard.jsx View on Github external
authenticate = e => {
    e.preventDefault();
    const nextQuery = { next: e.target.getAttribute('href') };
    const nextPath = appendQuery('/', nextQuery);
    history.pushState({}, e.target.textContent, nextPath);
    this.props.toggleLoginModal(true);
  };

append-query

Append querystring params to a URL.

MIT
Latest version published 4 years ago

Package Health Score

47 / 100
Full package analysis

Popular append-query functions