All files / libs/lti/components/src/lib/forms/hooks use-currency-symbol-for-plan.ts

0% Statements 0/14
0% Branches 0/1
0% Functions 0/1
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15                             
import { useAuthenticatedContext } from '@amalia/kernel/auth/state';
import { useLtiPlanSharePriceByGrantType } from '@amalia/lti/state';
import { type LtiPlan } from '@amalia/lti/types';

export const useCurrencySymbolForPlan = (ltiGrantType?: LtiPlan['grantType'] | null) => {
  const { data: sharePrice } = useLtiPlanSharePriceByGrantType();
  const { authenticatedContext } = useAuthenticatedContext();

  if (!ltiGrantType) {
    return authenticatedContext.user.company.currency;
  }

  return sharePrice?.[ltiGrantType]?.currency || authenticatedContext.user.company.currency;
};