All files / src/components/check-status-responses CheckStatusShippingFedex.tsx

100% Statements 4/4
87.5% Branches 7/8
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114                                2x         2x   2x   2x                                                                                                                                                                                
import { MouseEventHandler } from 'react'
 
import { Trans, useTranslation } from 'next-i18next'
 
import { StatusDisplayData } from '../../lib/types'
import ActionButton from '../ActionButton'
import AlertBlock from '../AlertBlock'
import ExternalLink from '../ExternalLink'
import Timeline from '../Timeline'
 
export interface CheckStatusShippingFedexProps {
  displayData: StatusDisplayData
  checkAnotherHandler: MouseEventHandler<HTMLButtonElement>
  trackingNumber?: string
}
 
export const CheckStatusShippingFedex = ({
  checkAnotherHandler,
  displayData,
  trackingNumber,
}: CheckStatusShippingFedexProps) => {
  const { t } = useTranslation(['status', 'common', 'timeline'])
 
  const { timelineExists, timelineData } = displayData
 
  return (
    <div id="response-result">
      <AlertBlock page="status-shipped-fedex" />
      <h1
        id="main-header"
        data-testid="shipped-fedex"
        className="h1"
        tabIndex={-1}
      >
        {t('shipped-fedex.header')}
      </h1>
      <div className="flex flex-col sm:flex-row">
        <div className="max-w-prose">
          <p>{t('shipped-fedex.printed-mailed')}</p>
          {timelineExists && (
            <div className="flex w-full justify-center sm:hidden">
              <Timeline entries={timelineData} />
            </div>
          )}
          <h2 data-testid="shipped-fedex-mailing" className="h2 mt-0">
            {t('shipped-fedex.shipping-information.header')}
          </h2>
          <p>
            `${t('shipped-fedex.shipping-information.sending-via')} $
            {trackingNumber ? (
              <Trans
                i18nKey="status-check-tracking.number"
                ns="status"
                tOptions={{ trackingNumber }}
              />
            ) : (
              t('shipped-fedex.shipping-information.take-up-to')
            )}
            `
          </p>
          {trackingNumber && (
            <>
              <p>
                <Trans
                  i18nKey={'status-check-tracking.can-track'}
                  ns="status"
                  components={{
                    Link: (
                      <ExternalLink
                        data-gc-analytics-exempt={true}
                        href={t('status-check-tracking.link.fedex', {
                          trackingNumber: encodeURIComponent(trackingNumber),
                        })}
                      />
                    ),
                  }}
                />
              </p>
            </>
          )}
          <p className="mb-2 mt-6">
            {t('shipped-fedex.shipping-information.dont-receive')}
          </p>
          <p>
            <Trans
              i18nKey="status-check-call"
              ns="status"
              components={{
                Link: <ExternalLink href={t('common:contact-us-link')} />,
              }}
            />
          </p>
          <div className="mt-8">
            <ActionButton
              onClick={checkAnotherHandler}
              text={t('status:check-another')}
              style="primary"
            />
          </div>
        </div>
        {timelineExists && (
          <div className="hidden w-full justify-center sm:flex">
            <div className="-mt-6">
              <Timeline entries={timelineData} />
            </div>
          </div>
        )}
      </div>
    </div>
  )
}
 
export default CheckStatusShippingFedex