department-of-veterans-affairs/vets-website

View on GitHub
src/applications/vaos/referral-appointments/components/ReferralTaskCardWithReferral.jsx

Summary

Maintainability
A
0 mins
Test Coverage
import React from 'react';
import { useLocation } from 'react-router-dom';

import { useGetReferralById } from '../hooks/useGetReferralById';
import ReferralTaskCard from './ReferralTaskCard';

export default function ReferralTaskCardWithReferral() {
  const { search } = useLocation();

  const params = new URLSearchParams(search);
  const id = params.get('id');

  const { currentReferral } = useGetReferralById(id);

  if (!currentReferral) {
    return null;
  }

  return <ReferralTaskCard data={currentReferral} />;
}