diff --git a/resources/js/Pages/Settings.vue b/resources/js/Pages/Settings.vue index 09438ac..b1ff826 100644 --- a/resources/js/Pages/Settings.vue +++ b/resources/js/Pages/Settings.vue @@ -4,8 +4,8 @@ import AgendaSettings from './Settings/AgendaSettings.vue' import LabelImport from './Settings/LabelImport.vue' import MacroAssignments from './Settings/MacroAssignments.vue' import MacroImport from './Settings/MacroImport.vue' -import { Head } from '@inertiajs/vue3' -import { onMounted, ref } from 'vue' +import { Head, router } from '@inertiajs/vue3' +import { computed, onMounted, ref } from 'vue' const props = defineProps({ settings: { type: Object, default: () => ({}) }, @@ -22,6 +22,7 @@ const submenus = [ { key: 'macros', label: 'Makro-Import' }, { key: 'labels', label: 'Label-Import' }, { key: 'agenda', label: 'Agenda' }, + { key: 'ccli', label: 'CCLI Import' }, ] const activeSubmenu = ref('assignments') @@ -37,6 +38,35 @@ function switchSubmenu(key) { activeSubmenu.value = key window.location.hash = key } + +// Fetch bookmarklet href from the server endpoint +const bookmarkletHref = ref('javascript:void(0)') +onMounted(async () => { + try { + const res = await fetch(route('bookmarklets.ccli')) + if (res.ok) { + bookmarkletHref.value = await res.text() + } + } catch { + // fallback: keep void + } +}) + +async function updateSetting(key, value) { + try { + await fetch(route('settings.update'), { + method: 'PATCH', + headers: { + 'Content-Type': 'application/json', + 'X-XSRF-TOKEN': decodeURIComponent(document.cookie.split('; ').find(r => r.startsWith('XSRF-TOKEN='))?.split('=')[1] ?? ''), + 'Accept': 'application/json', + }, + body: JSON.stringify({ key, value }), + }) + } catch { + // silent fail + } +}