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

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

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

  const { data } = useQuery(CRMTypes.GetTransactionCurrencyDocument, {
    variables: {
      currencyid: currencyid!,
    },
    skip: !currencyid,
  });

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

export default <CurrencyAddon />;
