UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

41 lines 2.13 kB
import { CurrentOrigin } from '../../../../components/molecules/source-props/WindowLocationConstants'; import { hubSelects } from '../interfaces/IFPSHubSiteDataDocsApi'; // import { check4This } from '@mikezimm/fps-core-v7/lib/logic/Links/CheckSearch'; /** * cleanSearchedWebs will go through results from the Search API for Hubs and Subs and clean up the results. * - it also adds some duplicate properties that are already used in other web parts like Pivot Tiles and Hub Connections. * @param searchedWebs * @returns */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export function cleanSearchedWebs(searchedWebs) { // get Cleaned Search // eslint-disable-next-line @typescript-eslint/no-explicit-any const cleanWebs = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any searchedWebs.map((item) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const thisItem = {}; hubSelects.map((prop, idx2) => { if (item.Cells[idx2]) thisItem[prop] = item.Cells[idx2].Value; }); // commonize some props for easier compatibility with other web parts if (!thisItem.imageUrl) thisItem.imageUrl = thisItem.SiteLogo ? thisItem.SiteLogo : thisItem.PictureThumbnailURL; if (!thisItem.title) thisItem.title = thisItem.Title; // Added this beause includes ServerRelativeUrl but not Path but searchedWebs include Path and not ServerRelativeUrl if (!thisItem.ServerRelativeUrl) thisItem.ServerRelativeUrl = thisItem.Path ? thisItem.Path.replace(CurrentOrigin, '') : ''; if (!thisItem.href) thisItem.href = thisItem.ServerRelativeUrl ? thisItem.ServerRelativeUrl : thisItem.Path; if (!thisItem.description) thisItem.description = thisItem.Description; if (!thisItem.sourceType) thisItem.sourceType = thisItem.sourceType = `sites`; cleanWebs.push(thisItem); }); return cleanWebs; } //# sourceMappingURL=cleanSearchedWebs.js.map