import * as CRMTypes from '@/graphql/crm.types';
import { useStore } from '@/stores/hooks';
import { useQuery } from '@apollo/client';
import { observer } from 'mobx-react-lite';

const CurrencyAddon = observer(() => {
  const { $calculation } = useStore();

  const currencyid = $calculation.element('selectSupplierCurrency').getValue();

  const { data } = useQuery(CRMTypes.GetTransactionCurrencyDocument, {
    skip: !currencyid,
    variables: {
      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
      currencyid: currencyid!,
    },
  });

  return <span>{data?.transactioncurrency?.currencysymbol}</span>;
});

export default <CurrencyAddon />;
