/**
 * Copyright 2024 Phenix Real Time Solutions, Inc. Confidential and Proprietary. All Rights Reserved.
 */
import React from 'react';
import {Link, LinkProps, useLocation} from 'react-router-dom';

const LinkWithSearch = (props: LinkProps): React.JSX.Element => {
  const {to, children} = props;
  const {search} = useLocation();

  return (
    <Link {...props} to={`${to}/${search || ''}`}>
      {children}
    </Link>
  );
};

export default LinkWithSearch;
