Skip to content
Snippets Groups Projects
parts.tsx 1.35 KiB
Newer Older
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
import { openFromOtherPage } from "../components/Buttons";
Liliana Sanfilippo's avatar
Liliana Sanfilippo committed
export function Parts() {
  const location = useLocation();
  useEffect(() => {
      // Scroll to the section specified by the collapseId in the URL
      const params = new URLSearchParams(location.search);
      const collapseId = params.get('collapseId');

      if (collapseId) {
          const element = document.getElementById(collapseId);
          if (element) {
              const elementTop = element.getBoundingClientRect().top + window.pageYOffset;
              const offset = window.innerHeight / 2 - element.offsetHeight / 2;
              const scrollPosition = elementTop - offset;

              window.scrollTo({
                  top: scrollPosition,
                  behavior: 'smooth',
              });
          }
      }
  }, [location.search]);
    useEffect(() => {
      const params = new URLSearchParams(location.search);
      const tabId = params.get('tab');
      if (tabId) {
          openFromOtherPage(tabId)({ currentTarget: document.getElementById(tabId)! });
      }
  }, [location.search]);
Liliana Sanfilippo's avatar
Liliana Sanfilippo committed
    return (
      <>
        <div className="row">
          <div className="col">
Liliana Sanfilippo's avatar
Liliana Sanfilippo committed
          </div>
        </div>
        <div className="row">
      
        </div>
      </>
    );
  }