UNPKG

@crazy-web/feedback

Version:

A feedback form handler package that shows a popup based on allowed URLs.

76 lines (75 loc) 3.21 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.fetchOrganizationData = void 0; const config_1 = require("../lib/config"); const fetchOrganizationData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ organizationId, websiteId, source = "feedback", page = 1 }) { // const dummyData: Organization[] = [ // { // id: "1", //formid // name: "Organization One", // title:"Submit feedback", // description: "Sample organization", // metadata: { // title: "First Form", // description:"This is my first form", // openAfter: 1, // theme: "system", // primaryColor: "#39C3EF", // whiteLabel: false, // frequency: frequencyTypes.everyTime // }, // allowed_urls: ["/"], // }, // { // id: "2", // name: "Organization Two", // title:"Submit feedback", // description: "Another organization", // metadata: { // title: "Second Form", // description:"This is my second form", // openAfter: 1, // theme:"light", // primaryColor: "red", // whiteLabel:false, // frequency: frequencyTypes.everySession // }, // allowed_urls: ["/about"], // }, // { // id: "3", // name: "Organization Two", // title:"Submit feedback", // description: "Another organization", // metadata: { // title: "Third Form", // description:"This is my third form", // openAfter: 1, // theme:"dark", // primaryColor: "#1753EE", // whiteLabel:true, // frequency: frequencyTypes.everyTime // }, // allowed_urls: ["/services"], // }, // ]; var _b; // const orgData = dummyData.filter(org => org.id === organizationId); const url = config_1.serverUrl + `/feedback?id=${organizationId}&type=${source}&page=${page}&website_id=${websiteId}`; const res = yield fetch(url); const result = yield res.json(); if (source === "announcement") { return result; } return (_b = result === null || result === void 0 ? void 0 : result.data) !== null && _b !== void 0 ? _b : []; }); exports.fetchOrganizationData = fetchOrganizationData;