import { useEffect } from 'react';

import { useDrawerV2 } from '@material-hu/hooks/useDrawerV2';

import { type PolicyTypes } from 'src/types/vacations';

import { getPolicyBalanceDetailDrawer } from '../Drawers/PolicyBalanceDetailDrawer';

type PolicyBalanceDetailDeepLinkProps = {
  policyType: PolicyTypes;
};

const PolicyBalanceDetailDeepLink = ({
  policyType,
}: PolicyBalanceDetailDeepLinkProps) => {
  const {
    drawer: policyBalanceDetailDrawer,
    showDrawer: showPolicyBalanceDetailDrawer,
  } = useDrawerV2(args =>
    getPolicyBalanceDetailDrawer({ ...args, policyType }),
  );

  useEffect(() => {
    showPolicyBalanceDetailDrawer({});
  }, [policyType.id]);

  return <>{policyBalanceDetailDrawer}</>;
};

export default PolicyBalanceDetailDeepLink;
