2024-01-13 17:57:24 +00:00
|
|
|
<template>
|
2024-04-04 22:20:42 +00:00
|
|
|
<form class="license-form flex items-stretch" @submit.prevent="validateLicenseKey">
|
|
|
|
<TextInput
|
2024-03-19 22:48:12 +00:00
|
|
|
v-model="licenseKey"
|
|
|
|
v-koel-focus
|
2024-04-04 22:20:42 +00:00
|
|
|
:disabled="loading"
|
|
|
|
class="!rounded-r-none"
|
2024-01-13 17:57:24 +00:00
|
|
|
name="license"
|
|
|
|
placeholder="Enter your license key"
|
|
|
|
required
|
2024-04-04 22:20:42 +00:00
|
|
|
/>
|
|
|
|
<Btn :disabled="loading" class="!rounded-l-none" type="submit">Activate</Btn>
|
2024-01-13 17:57:24 +00:00
|
|
|
</form>
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref } from 'vue'
|
|
|
|
import { plusService } from '@/services'
|
|
|
|
import { forceReloadWindow, logger } from '@/utils'
|
|
|
|
import { useDialogBox } from '@/composables'
|
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
import Btn from '@/components/ui/form/Btn.vue'
|
|
|
|
import TextInput from '@/components/ui/form/TextInput.vue'
|
2024-01-13 17:57:24 +00:00
|
|
|
|
|
|
|
const { showSuccessDialog, showErrorDialog } = useDialogBox()
|
|
|
|
const licenseKey = ref('')
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
const validateLicenseKey = async () => {
|
|
|
|
try {
|
|
|
|
loading.value = true
|
|
|
|
await plusService.activateLicense(licenseKey.value)
|
|
|
|
await showSuccessDialog('Thanks for purchasing Koel Plus! Koel will now refresh to activate the changes.')
|
|
|
|
forceReloadWindow()
|
|
|
|
} catch (e) {
|
|
|
|
logger.error(e)
|
|
|
|
await showErrorDialog('Failed to activate Koel Plus. Please try again.')
|
|
|
|
} finally {
|
|
|
|
loading.value = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|