diff --git a/apps/showcase/components/layout/AppDesigner.vue b/apps/showcase/components/layout/AppDesigner.vue index 7f21aba609..e3e6cf3273 100644 --- a/apps/showcase/components/layout/AppDesigner.vue +++ b/apps/showcase/components/layout/AppDesigner.vue @@ -65,27 +65,30 @@ export default { this.deferredTabs = true; }, async downloadTheme(theme) { - try { - const response = await $fetch(this.designerApiBase + '/theme/download/' + this.$appState.designer.licenseKey + '/' + theme.t_key, { - responseType: 'blob' - }); + if (!this.$appState.designer.licenseKey) { + this.$toast.add({ severity: 'error', summary: 'Not Available', detail: 'A license is required to download', life: 3000 }); + } else { + try { + const response = await $fetch(this.designerApiBase + '/theme/download/' + this.$appState.designer.licenseKey + '/' + theme.t_key, { + responseType: 'blob' + }); - if (response.error) { - this.$toast.add({ severity: 'error', summary: 'An Error Occurred', detail: error.message, life: 3000 }); - } else { - const blobUrl = window.URL.createObjectURL(response); - const link = document.createElement('a'); + if (response.error) { + this.$toast.add({ severity: 'error', summary: 'An Error Occurred', detail: error.message, life: 3000 }); + } else { + const blobUrl = window.URL.createObjectURL(response); + const link = document.createElement('a'); - link.href = blobUrl; - link.download = theme.t_name + '.zip'; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - window.URL.revokeObjectURL(blobUrl); + link.href = blobUrl; + link.download = theme.t_name + '.zip'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + window.URL.revokeObjectURL(blobUrl); + } + } catch (err) { + this.$toast.add({ severity: 'error', summary: 'An Error Occurred', detail: 'Failed to download file', life: 3000 }); } - } catch (err) { - console.log(err); - this.$toast.add({ severity: 'error', summary: 'An Error Occurred', detail: 'Failed to download file', life: 3000 }); } }, async updateTheme(theme) { @@ -104,7 +107,10 @@ export default { } }, applyTheme(theme) { - this.updateTheme(theme); + if (this.$appState.designer.licenseKey) { + this.updateTheme(theme); + } + updatePreset(theme.preset); EventBus.emit('theme-palette-change'); }, diff --git a/apps/showcase/components/layout/designer/create/DesignCreateTheme.vue b/apps/showcase/components/layout/designer/create/DesignCreateTheme.vue index 9b8c1d699a..81f1c559c8 100644 --- a/apps/showcase/components/layout/designer/create/DesignCreateTheme.vue +++ b/apps/showcase/components/layout/designer/create/DesignCreateTheme.vue @@ -96,43 +96,55 @@ export default { document.body.classList.remove('material'); } - const { data, error } = await $fetch(this.designerApiBase + '/theme/create', { - method: 'POST', - body: { - name: this.themeName, - preset: newPreset, - license_key: this.$appState.designer.licenseKey, - config: { - font_size: '14px', - font_family: 'Inter var' + if (this.$appState.designer.licenseKey) { + const { data, error } = await $fetch(this.designerApiBase + '/theme/create', { + method: 'POST', + body: { + name: this.themeName, + preset: newPreset, + license_key: this.$appState.designer.licenseKey, + config: { + font_size: '14px', + font_family: 'Inter var' + } } - } - }); + }); - if (error) { - this.$toast.add({ severity: 'error', summary: 'An error occured', detail: error.message, life: 3000 }); + if (error) { + this.$toast.add({ severity: 'error', summary: 'An error occured', detail: error.message, life: 3000 }); + } else { + this.loadThemeEditor(data.t_key, newPreset); + } } else { - this.loadThemeEditor(data.t_key, newPreset); + this.loadThemeEditor('trial', newPreset); } }, async createThemeFromFigma() { - const { data, error } = await $fetch(this.designerApiBase + '/theme/figma', { - method: 'POST', - body: { - name: this.themeName, - figma_tokens: this.figmaData, - license_key: this.$appState.designer.licenseKey, - config: { - font_size: '14px', - font_family: 'Inter var' + if (this.figmaData) { + if (this.$appState.designer.licenseKey) { + const { data, error } = await $fetch(this.designerApiBase + '/theme/figma', { + method: 'POST', + body: { + name: this.themeName, + figma_tokens: this.figmaData, + license_key: this.$appState.designer.licenseKey, + config: { + font_size: '14px', + font_family: 'Inter var' + } + } + }); + + if (error) { + this.$toast.add({ severity: 'error', summary: 'An error occured', detail: error.message, life: 3000 }); + } else { + this.loadThemeEditor(data.t_key, newPreset); } + } else { + this.$toast.add({ severity: 'error', summary: 'An error occured', detail: 'A valid license required', life: 3000 }); } - }); - - if (error) { - this.$toast.add({ severity: 'error', summary: 'An error occured', detail: error.message, life: 3000 }); } else { - this.loadThemeEditor(data.t_key, newPreset); + this.$toast.add({ severity: 'error', summary: 'An error occured', detail: 'File is required', life: 3000 }); } }, onFileSelect(event) { diff --git a/apps/showcase/components/layout/designer/dashboard/DesignDashboard.vue b/apps/showcase/components/layout/designer/dashboard/DesignDashboard.vue index e9f0115bfd..55f0ebd1d9 100644 --- a/apps/showcase/components/layout/designer/dashboard/DesignDashboard.vue +++ b/apps/showcase/components/layout/designer/dashboard/DesignDashboard.vue @@ -1,16 +1,17 @@