<script setup="setup">

const { etherpadUrl, etherpadPrefix } = useRuntimeConfig().public

const store = usePojmiStore()

const props = defineProps({
  naslov: String,
  revisionId: String
})

//const pojem = computed(() => store.pojmi[props.naslov])

//await store.naloziPojme()

// const UREJAM = !!pojem.value
const UREJAM = false

let naslov = ''
let tekst = ''
let email = ''

const oddajPredlog = data => {
  console.log('oddajam predlog!', naslov, tekst, email)
  store.ustvariPojem(data)
}

const etherNalozen = ev => {
  window.location.hash = props.revisionId
}

</script>

<template>
  <section class="pojem">
    <div v-if="UREJAM">UREJAM</div>
    <form class="pojem" @submit.prevent="oddajPredlog">
      <label for="naslov">Naslov</label>
      <input name="naslov" type="text" v-model="naslov">

      <label for="tekst">Besedilo</label>
      <EtherpadTextarea :onLoad="etherNalozen" :revisionId="props.revisionId" />

      <label for="email">E-poštni naslov</label>
      <input name="email" type="email" v-model="email">

      <input type="submit" value="Predlagaj">
    </form>
  </section>
</template>
