[FIX] Update NPS banner when changing score (#20611)

pull/20649/head
Diego Sampaio 5 years ago committed by GitHub
parent 94ab098f77
commit 59ff820f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      server/modules/core-apps/nps.module.ts
  2. 17
      server/modules/core-apps/nps/createModal.ts
  3. 1
      server/services/nps/service.ts

@ -8,8 +8,9 @@ export class Nps implements IUiKitCoreApp {
async blockAction(payload: any): Promise<any> {
const {
triggerId,
actionId,
container: {
id: bannerId,
id: viewId,
},
payload: {
value: score,
@ -18,10 +19,13 @@ export class Nps implements IUiKitCoreApp {
user,
} = payload;
const bannerId = viewId.replace(`${ npsId }-`, '');
return createModal({
type: actionId === 'nps-score' ? 'modal.update' : 'modal.open',
id: `${ npsId }-${ bannerId }`,
appId: this.appId,
npsId,
bannerId,
triggerId,
score,
user,
@ -37,7 +41,7 @@ export class Nps implements IUiKitCoreApp {
payload: {
view: {
state,
id: bannerId,
id: viewId,
},
},
user: {
@ -48,9 +52,11 @@ export class Nps implements IUiKitCoreApp {
const [npsId] = Object.keys(state);
const bannerId = viewId.replace(`${ npsId }-`, '');
const {
[npsId]: {
score,
'nps-score': score,
comment,
},
} = state;

@ -5,25 +5,26 @@ import { settings } from '../../../../app/settings/server';
import { IUser } from '../../../../definition/IUser';
export type ModalParams = {
id: string;
type: string;
appId: string;
npsId: string;
bannerId: string;
triggerId: string;
score: string;
user: IUser;
}
export const createModal = Meteor.bindEnvironment(({ appId, npsId, bannerId, triggerId, score, user }: ModalParams): any => {
export const createModal = Meteor.bindEnvironment(({ type = 'modal.open', id, appId, npsId, triggerId, score, user }: ModalParams): any => {
const language = user.language || settings.get('Language') || 'en';
return {
type: 'modal.open',
type,
triggerId,
appId,
view: {
appId,
type: 'modal',
id: bannerId,
id,
title: {
type: 'plain_text',
text: TAPi18n.__('We_appreciate_your_feedback', { lng: language }),
@ -49,14 +50,14 @@ export const createModal = Meteor.bindEnvironment(({ appId, npsId, bannerId, tri
},
blocks: [{
blockId: npsId,
type: 'input',
element: {
type: 'actions',
elements: [{
type: 'linear_scale',
initialValue: score,
actionId: 'score',
actionId: 'nps-score',
preLabel: { type: 'plain_text', text: TAPi18n.__('Not_likely', { lng: language }) },
postLabel: { type: 'plain_text', text: TAPi18n.__('Extremely_likely', { lng: language }) },
},
}],
label: {
type: 'plain_text',
text: TAPi18n.__('Score', { lng: language }),

@ -110,6 +110,7 @@ export class NPSService extends ServiceClass implements INPSService {
},
}, {
projection: {
_id: 0,
identifier: 1,
roles: 1,
score: 1,

Loading…
Cancel
Save