import { CopyTypePath } from 'src/types/deeplinks';

import { linkTypesBuilder } from './constants';

export const copyToClipboard = async (
  type: CopyTypePath,
  id?: number | string,
  subId?: number,
  hash?: string,
  callback?: () => void,
) => {
  const baseUrl = (import.meta.env.VITE_WEB_URL as string).replace(/\/$/, '');
  const path = `${baseUrl}${linkTypesBuilder[type](id, subId, hash)}`;
  await navigator.clipboard.writeText(path);
  callback?.();
};
