@bruit/component
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -0,4 +1,5 @@ | ||
import { BrtFieldType } from '@bruit/types/dist/enums/brt-field-type'; | ||
import { NavigatorTool } from '../bruit-tools/navigator'; | ||
import { ScreenTool } from '../bruit-tools/screen'; | ||
import { Api } from './api'; | ||
import { ScreenTool } from '../bruit-tools/screen'; | ||
import { NavigatorTool } from '../bruit-tools/navigator'; | ||
export class Feedback { | ||
@@ -32,12 +33,9 @@ constructor(apiKey) { | ||
} | ||
async send(formData, data = [], dataFn) { | ||
async send(formFields, data = [], dataFn) { | ||
try { | ||
const agreementField = formData.find(field => field.id === 'agreement'); | ||
const agreementField = formFields.find(field => field.id === 'agreement'); | ||
const agreement = agreementField ? agreementField.value : true; | ||
const dataFromFn = await this.getDataFromFn(dataFn); | ||
this.data = [ | ||
...formData.map(ff => ({ type: ff.type, value: ff.value, label: ff.label, id: ff.id })), | ||
...data, | ||
...dataFromFn | ||
]; | ||
const formData = formFields.map(field => this.fieldToData(field)); | ||
this.data = [...formData, ...data, ...dataFromFn]; | ||
return Api.postFeedback({ | ||
@@ -72,2 +70,9 @@ apiKey: this.apiKey, | ||
} | ||
fieldToData(field) { | ||
const data = { type: field.type, value: field.value, label: field.label, id: field.id }; | ||
if (data.type === BrtFieldType.RATING) { | ||
data.max = field.max || 5; | ||
} | ||
return data; | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { BrtFeedback, BrtCookies, BrtNavigatorInfo, BrtScreenInfo, BrtLog, BrtData, BrtField, BrtServiceWorker } from '@bruit/types'; | ||
import { BrtCookies, BrtData, BrtFeedback, BrtField, BrtLog, BrtNavigatorInfo, BrtScreenInfo, BrtServiceWorker } from '@bruit/types'; | ||
export declare class Feedback implements BrtFeedback { | ||
@@ -16,7 +16,7 @@ apiKey: string; | ||
* | ||
* @param formData | ||
* @param formFields | ||
* @param data | ||
* @param dataFn | ||
*/ | ||
send(formData: Array<BrtField>, data?: Array<BrtData>, dataFn?: () => Array<BrtData> | Promise<Array<BrtData>>): Promise<any>; | ||
send(formFields: Array<BrtField>, data?: Array<BrtData>, dataFn?: () => Array<BrtData> | Promise<Array<BrtData>>): Promise<any>; | ||
/** | ||
@@ -29,2 +29,9 @@ * | ||
private getDataFromFn; | ||
/** | ||
* | ||
* @param field : BrtField from form | ||
* | ||
* @return a BrtData | ||
*/ | ||
private fieldToData; | ||
} |
{ | ||
"name": "@bruit/component", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": "send your feedbacks with bruit.io", | ||
@@ -30,3 +30,4 @@ "keywords": [ | ||
"test.watch": "stencil test --spec --e2e --watchAll", | ||
"docs": "stencil build --docs" | ||
"docs": "stencil build --docs", | ||
"prepublishOnly": "npm i && npm run build && node script/git-tag" | ||
}, | ||
@@ -33,0 +34,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2407594
20049