Skip to content

The open alternative to Salesforce, designed for AI.

495 B
Raw Blame
import { toText } from 'src/logic-functions/utils/to-text';
import { type LinksValue } from 'src/types/links-value';
import { isDefined } from 'src/utils/is-defined';

export const buildLinks = ({
  url,
  label,
}: {
  url: unknown;
  label?: unknown;
}): LinksValue | undefined => {
  const primaryLinkUrl = toText(url);

  if (!isDefined(primaryLinkUrl)) {
    return undefined;
  }

  return {
    primaryLinkUrl,
    primaryLinkLabel: toText(label) ?? '',
    secondaryLinks: null,
  };
};