department-of-veterans-affairs/vets-website

View on GitHub
src/applications/check-in/components/BackToHome.jsx

Summary

Maintainability
A
0 mins
Test Coverage
import React, { useMemo } from 'react';
import { useSelector } from 'react-redux';
import { useTranslation } from 'react-i18next';

import withOnlyOnLocal from '../containers/withOnlyOnLocal';
import { makeSelectApp } from '../selectors';
import { APP_NAMES } from '../utils/appConstants';

function BackToHome() {
  const selectApp = useMemo(makeSelectApp, []);
  const { app } = useSelector(selectApp);
  const { t } = useTranslation();
  let restartURL =
    '/health-care/appointment-pre-check-in/?id=46bebc0a-b99c-464f-a5c5-560bc9eae287';
  if (app === APP_NAMES.CHECK_IN) {
    restartURL =
      '/health-care/appointment-check-in/?id=46bebc0a-b99c-464f-a5c5-560bc9eae287';
  }
  if (app === APP_NAMES.TRAVEL_CLAIM) {
    restartURL =
      '/my-health/appointment-travel-claim/?id=46bebc0a-b99c-464f-a5c5-560bc9eae287';
  }
  return (
    <div className="vads-l-grid-container vads-u-padding-bottom--5 vads-u-padding-top--2 local-start-again">
      <a data-testid="back-to-home-button" href={restartURL}>
        {t('start-again')}
      </a>
    </div>
  );
}

export default withOnlyOnLocal(BackToHome);