/*
 * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
 *
 * SPDX-License-Identifier: AGPL-3.0-only
 */
import { CopyableField } from '../../../../../common/copyable/copyable-field/copyable-field'
import React from 'react'
import { useNoteLinks } from '../../../../../../hooks/common/use-note-links'

export enum LinkType {
  EDITOR = 'n',
  SLIDESHOW = 'p',
  DOCUMENT = 's'
}

export interface LinkFieldProps {
  type: LinkType
}

/**
 * Renders a specific URL to the current note.
 * @param type defines the URL type. (editor, read only document, slideshow, etc.)
 */
export const NoteUrlField: React.FC<LinkFieldProps> = ({ type }) => {
  const noteLinks = useNoteLinks()
  const url = noteLinks[type]
  return !url ? null : <CopyableField content={url} shareOriginUrl={url} />
}
