Skip to content

Commit

Permalink
Merge pull request #161 from weni-ai/fix/graph-funnel-i18n
Browse files Browse the repository at this point in the history
[ENGAGE-1790] - Fix graph funnel number format and click outside event in generate insights modal
  • Loading branch information
mateuseduardomedeiros authored Oct 8, 2024
2 parents 89533f7 + be3ea7a commit f8b88c6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import InsightModalFooter from './InsightModalFooter.vue';
import firebaseService from '@/services/api/resources/GPT';
import mitt from 'mitt';
import { formatSecondsToHumanString } from '@/utils/time';
import { onClickOutside } from '@vueuse/core';
import { ref } from 'vue';
const emitter = mitt();
Expand All @@ -81,6 +83,18 @@ export default {
emits: ['close'],
setup(_, context) {
const insightModal = ref(null);
onClickOutside(insightModal, (event) => {
if (event?.pointerType === 'mouse') context.emit('close');
});
return {
insightModal,
};
},
data() {
return {
generatedInsight: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export default {
},
},
beforeUnmount() {
// If it is closed while typing, in the next iteration the text will be shown in full, which is why we emit this event for this case
if (this.isTyping) this.$emit('typingComplete');
},
methods: {
async typeWriter(text, speed) {
this.isTyping = true;
Expand Down
9 changes: 8 additions & 1 deletion src/store/modules/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const mutations = {
UPDATE_CURRENT_WIDGET_EDITING: 'UPDATE_CURRENT_WIDGET_EDITING',
};

import i18n from '@/utils/plugins/i18n';

export default {
namespaced: true,
state: {
Expand Down Expand Up @@ -126,7 +128,12 @@ export default {
const percentage = ((item.title / totalValue) * 100 || 0).toFixed(2);
return {
description: item.description,
title: `${percentage}% (${item.title.toLocaleString()})`,
title: `${parseFloat(percentage).toLocaleString(
i18n.global.locale || 'en-US',
{
minimumFractionDigits: 2,
},
)}% (${item.title.toLocaleString(i18n.global.locale || 'en-US')})`,
percentage: parseFloat(percentage), // Add percentage as a number for sorting
};
})
Expand Down

0 comments on commit f8b88c6

Please sign in to comment.