From 91911bc6e5ef34dbf7a3354a5d338d82d36d3639 Mon Sep 17 00:00:00 2001 From: Julien Nahum Date: Sat, 10 Feb 2024 12:20:45 +0100 Subject: [PATCH] Multiple bug fixing --- client/components/global/ScrollShadow.vue | 18 +++++++++++------- client/components/open/forms/OpenForm.vue | 1 + .../open/forms/components/FormEditor.vue | 12 +++++++++--- .../form-components/FormCustomization.vue | 5 ----- .../forms/fields/components/FieldOptions.vue | 1 + client/components/open/tables/OpenTable.vue | 6 +++--- .../pages/forms/create/CreateFormBaseModal.vue | 4 +++- client/composables/useCrisp.js | 1 - client/lib/forms/FormLogicConditionChecker.js | 6 +++--- client/package-lock.json | 6 ++++++ client/package.json | 1 + client/pages/forms/[slug]/edit.vue | 4 +++- client/pages/settings.vue | 4 ++-- client/plugins/sentry.js | 14 -------------- client/stores/auth.js | 17 ++++++++--------- client/stores/working_form.js | 2 -- 16 files changed, 51 insertions(+), 51 deletions(-) diff --git a/client/components/global/ScrollShadow.vue b/client/components/global/ScrollShadow.vue index caebcb3..0c67a8c 100644 --- a/client/components/global/ScrollShadow.vue +++ b/client/components/global/ScrollShadow.vue @@ -4,7 +4,7 @@ ref="scrollContainer" :class="[$style['scroll-container'],{'no-scrollbar':hideScrollbar}]" :style="{ width: width?width:'auto', height }" - @scroll.passive="toggleShadow" + @scroll.passive="throttled.toggleShadow" > { - if (error.response.status === 422) { + if (error?.response.status === 422) { this.validationErrorResponse = error.response.data this.showValidationErrors() + } else { + useAlert().error('An error occurred while saving the form, please try again.') + captureException(error) } }).finally(() => { this.updateFormLoading = false @@ -282,10 +286,12 @@ export default { this.displayFormModificationAlert(response) useRouter().push({ name: 'forms-slug-show-share', params: { slug: this.createdFormSlug, new_form: response.users_first_form } }) }).catch((error) => { - console.error(error) - if (error.response && error.response.status === 422) { + if (error?.response?.status === 422) { this.validationErrorResponse = error.response this.showValidationErrors() + } else { + useAlert().error('An error occurred while saving the form, please try again.') + captureException(error) } }).finally(() => { this.updateFormLoading = false diff --git a/client/components/open/forms/components/form-components/FormCustomization.vue b/client/components/open/forms/components/form-components/FormCustomization.vue index 27e9aa4..0528f76 100644 --- a/client/components/open/forms/components/form-components/FormCustomization.vue +++ b/client/components/open/forms/components/form-components/FormCustomization.vue @@ -17,11 +17,6 @@ ]" :form="form" label="Form Theme" /> -
- - Need another theme? Send us some suggestions! - -
{ return option.name }).join('\n') diff --git a/client/components/open/tables/OpenTable.vue b/client/components/open/tables/OpenTable.vue index 5c086e6..be0c023 100644 --- a/client/components/open/tables/OpenTable.vue +++ b/client/components/open/tables/OpenTable.vue @@ -53,8 +53,8 @@ - @@ -91,7 +91,7 @@ import {hash} from "~/lib/utils.js"; export default { components: {ResizableTh, RecordOperations}, - emits: ["updated", "deleted"], + emits: ["updated", "deleted", "resize"], props: { columns: { type: Array, diff --git a/client/components/pages/forms/create/CreateFormBaseModal.vue b/client/components/pages/forms/create/CreateFormBaseModal.vue index 66478db..861d5ba 100644 --- a/client/components/pages/forms/create/CreateFormBaseModal.vue +++ b/client/components/pages/forms/create/CreateFormBaseModal.vue @@ -145,7 +145,9 @@ export default { this.fetchGeneratedForm(generationId) } }).catch(error => { - this.useAlert.error(error.data.message) + if (error?.data?.message){ + this.useAlert.error(error.data.message) + } this.state = 'default' this.loading = false }) diff --git a/client/composables/useCrisp.js b/client/composables/useCrisp.js index 90244e4..4efe800 100644 --- a/client/composables/useCrisp.js +++ b/client/composables/useCrisp.js @@ -25,7 +25,6 @@ export const useCrisp = () => { function openAndShowChat(message = null) { if (!crisp) return - showChat() openChat() if (message) sendTextMessage(message) } diff --git a/client/lib/forms/FormLogicConditionChecker.js b/client/lib/forms/FormLogicConditionChecker.js index bfce0fc..c32eddc 100644 --- a/client/lib/forms/FormLogicConditionChecker.js +++ b/client/lib/forms/FormLogicConditionChecker.js @@ -65,7 +65,7 @@ function checkContains (condition, fieldValue) { function checkListContains (condition, fieldValue) { if (!fieldValue) return false - + if (Array.isArray(condition.value)) { return condition.value.every(r => fieldValue.includes(r)) } else { @@ -74,11 +74,11 @@ function checkListContains (condition, fieldValue) { } function checkStartsWith (condition, fieldValue) { - return fieldValue.startsWith(condition.value) + return fieldValue?.startsWith(condition.value) } function checkendsWith (condition, fieldValue) { - return fieldValue && fieldValue.endsWith(condition.value) + return fieldValue?.endsWith(condition.value) } function checkIsEmpty (condition, fieldValue) { diff --git a/client/package-lock.json b/client/package-lock.json index b61c222..27421e3 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -28,6 +28,7 @@ "fuse.js": "^6.4.6", "js-sha256": "^0.10.0", "libphonenumber-js": "^1.10.44", + "lodash.throttle": "^4.1.1", "nuxt3-notifications": "^1.1.9", "object-to-formdata": "^4.5.1", "pinia": "^2.1.7", @@ -8517,6 +8518,11 @@ "lodash._reinterpolate": "^3.0.0" } }, + "node_modules/lodash.throttle": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", + "integrity": "sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==" + }, "node_modules/lodash.uniq": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", diff --git a/client/package.json b/client/package.json index 4340ba1..d44fab6 100644 --- a/client/package.json +++ b/client/package.json @@ -43,6 +43,7 @@ "fuse.js": "^6.4.6", "js-sha256": "^0.10.0", "libphonenumber-js": "^1.10.44", + "lodash.throttle": "^4.1.1", "nuxt3-notifications": "^1.1.9", "object-to-formdata": "^4.5.1", "pinia": "^2.1.7", diff --git a/client/pages/forms/[slug]/edit.vue b/client/pages/forms/[slug]/edit.vue index 1f69865..4559a15 100644 --- a/client/pages/forms/[slug]/edit.vue +++ b/client/pages/forms/[slug]/edit.vue @@ -33,7 +33,9 @@ const error = ref(null) const formInitialHash = ref(null) function isDirty() { - return formInitialHash.value && updatedForm.value && formInitialHash.value !== hash(JSON.stringify(updatedForm.value.data() ?? null)) + return formInitialHash.value && + updatedForm.value && + formInitialHash.value !== hash(JSON.stringify(updatedForm?.value?.data() ?? null)) } function initUpdatedForm() { diff --git a/client/pages/settings.vue b/client/pages/settings.vue index 9badc12..9bf166c 100644 --- a/client/pages/settings.vue +++ b/client/pages/settings.vue @@ -71,14 +71,14 @@ } ] - if (user.value.is_subscribed) { + if (user?.value?.is_subscribed) { tabs.splice(1, 0, { name: 'Billing', route: 'settings-billing' }) } - if (user.value.admin) { + if (user?.value?.admin) { tabs.push({ name: 'Admin', route: 'settings-admin' diff --git a/client/plugins/sentry.js b/client/plugins/sentry.js index 1542c5c..25ae3ac 100644 --- a/client/plugins/sentry.js +++ b/client/plugins/sentry.js @@ -1,16 +1,5 @@ import * as Sentry from "@sentry/vue"; -async function lazyLoadSentryIntegrations() { - // don't load on server - if (!process.client) return; - - const {Replay} = await import("@sentry/vue"); - Sentry.addIntegration(new Replay({ - maskAllText: false, - blockAllMedia: false, - })); -} - function getSentryIntegrations() { // don't load on server if (!process.client) return []; @@ -65,8 +54,5 @@ export default defineNuxtPlugin({ return event; }, }) - - // Lazy-load the replay integration to reduce bundle size - lazyLoadSentryIntegrations() } }); diff --git a/client/stores/auth.js b/client/stores/auth.js index 75c79e4..7e16b76 100644 --- a/client/stores/auth.js +++ b/client/stores/auth.js @@ -1,4 +1,5 @@ import {defineStore} from 'pinia' +import {setUser as sentrySetUser} from "@sentry/vue"; export const useAuthStore = defineStore('auth', { state: () => { @@ -65,18 +66,16 @@ export const useAuthStore = defineStore('auth', { useCrisp().setUser(this.user) // Init sentry - // console.log(process) - // $sentry.configureScope((scope) => { - // scope.setUser({ - // id: this.user.id, - // email: this.user.email, - // subscription: this.user?.is_subscribed - // }) - // }) + sentrySetUser({ + id: this.user.id, + email: this.user.email, + subscription: this.user?.is_subscribed + }) }, logout() { - opnFetch('logout', {method: 'POST'}).catch((error) => {}) + opnFetch('logout', {method: 'POST'}).catch((error) => { + }) this.user = null this.setToken(null) diff --git a/client/stores/working_form.js b/client/stores/working_form.js index 2a71eb0..94aab8f 100644 --- a/client/stores/working_form.js +++ b/client/stores/working_form.js @@ -1,7 +1,5 @@ import { defineStore } from 'pinia' - - export const useWorkingFormStore = defineStore('working_form', { state: () => ({ content: null,