UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

82 lines (80 loc) 5.05 kB
/** * CodeAnalizerComment: Updated 1 imports on 2024-09-22 14:49:52 * Update:: import { IStateSource } to '@mikezimm/fps-core-v7/lib/components/molecules/state-source/IStateSource;' */ /** * CodeAnalizerComment: Updated 3 imports on 2024-09-21 23:07:24 * Update:: import { IStateSource } to '@mikezimm/fps-core-v7/lib/components/molecules/state-source/IStateSource;' * Update:: import { ISourceProps } to '@mikezimm/fps-core-v7/lib/components/molecules/source-props/ISourceProps;' * Update:: import { check4This } to '@mikezimm/fps-core-v7/lib/logic/Links/CheckSearch;' */ import * as React from 'react'; import { Spinner, SpinnerSize, } from '@fluentui/react/lib/Spinner'; import { GetGoToWebLink } from '../Links/GetGoToWebLink'; import { GetGoToListLink } from '../Links/GetGoToListLink'; import { check4This, Check4 } from "@mikezimm/fps-core-v7/lib/logic/Links/CheckSearch"; const SpinnerContainerStyles = { display: 'flex', backgroundColor: 'lightyellow', textAlign: 'center', flexDirection: 'column', alignItems: 'center', padding: '20px', fontSize: 'larger', fontWeight: 600, }; export function FPSFetchStatus(primarySource, stateSource, disableSpinner) { if (!primarySource || !stateSource || (stateSource && stateSource.errorInfo && stateSource.errorInfo.returnMess)) { if (check4This(Check4.testingLog_Eq_true) === true) console.log('testingLog FPSFetchStatus 1:', primarySource, stateSource); return FPSFetchError(primarySource, stateSource); } if (disableSpinner !== true && stateSource && stateSource.loaded !== true) { if (check4This(Check4.testingLog_Eq_true) === true) console.log('testingLog FPSFetchStatus 2:', disableSpinner, stateSource); return FPSFetchSpinner(primarySource, stateSource); } if (check4This(Check4.testingLog_Eq_true) === true) console.log('testingLog FPSFetchStatus 3:', primarySource, disableSpinner, stateSource); return undefined; } export function FPSFetchSpinner(primarySource, stateSource) { // This is duplicated in SearchPage.tsx and SourcePages.tsx as well const spinnerStyles = { label: { fontSize: '20px', fontWeight: '600', } }; const FetchingSpinner = stateSource && stateSource.loaded === true ? undefined : (primarySource === null || stateSource === null) ? React.createElement("div", { style: SpinnerContainerStyles }, primarySource === null ? React.createElement("div", null, "NO Source Props defined") : React.createElement("div", null, primarySource.key, " is not defined"), stateSource === null ? React.createElement("div", null, "NO State Source defined") : React.createElement("div", null, " State Source Status: ", stateSource.status, " ")) : React.createElement("div", { style: SpinnerContainerStyles }, React.createElement(Spinner, { size: SpinnerSize.medium, label: "Fetching more information ...", labelPosition: 'right', style: { paddingBottom: 10 }, styles: spinnerStyles }), React.createElement("div", null, "Currently trying to fetch: ", primarySource.key), React.createElement("div", null, " State Source Status: ", stateSource.status, " ")); return FetchingSpinner; } export function FPSFetchError(primarySource, stateSource) { const GoToWebLink1 = GetGoToWebLink({ primarySource: primarySource, altWebText: 'Site Url:', }); // GetGoToListLink, GetGoToItemLink, GetGoToWebLink const GoToWebLink2 = GetGoToWebLink({ primarySource: primarySource, altWebText: 'Go to site:', showWebIcon: true, webLinkCSS: { color: null, fontSize: null, marginRight: '60px' } }); // GetGoToListLink, GetGoToItemLink, GetGoToWebLink const gotoListLink = GetGoToListLink({ primarySource: primarySource, }); // GetGoToListLink, GetGoToItemLink, GetGoToWebLink const errorMessage = stateSource && stateSource.errorInfo && stateSource.errorInfo.returnMess ? true : false; const theMessage = errorMessage === false ? '' : stateSource.errorInfo.returnMess.split('"value":"'); const errorElement = errorMessage !== true ? undefined : React.createElement("div", { style: { background: 'yellow', color: 'red', height: '200px', paddingTop: '25px', textAlign: 'center' } }, GoToWebLink1, React.createElement("div", { style: { fontSize: 'x-large', paddingBottom: '5px', fontWeight: 700 } }, stateSource.errorInfo.friendly), React.createElement("div", { style: { fontSize: 'large', paddingBottom: '15px' } }, theMessage[theMessage.length - 1].replace('"}}}', '')), GoToWebLink2, gotoListLink); return errorElement; } //# sourceMappingURL=FPSFetchStatus.js.map