import * as React from 'react'; import { submissionService } from '../apps'; /** The value returned from `usePendingSubmissions()` hook */ export type PendingSubmissionsContextValue = { /** `true` if the pending submissions are currently loading */ isLoading: boolean; /** An Error object if loading pending submissions fails */ loadError: Error | null; /** * The submissions that were submitted offline and can be processed when back * online */ pendingSubmissions: submissionService.PendingFormSubmission[]; /** `true` submissions that where submitted offline are being processed */ isProcessingPendingQueue: boolean; /** A function to trigger processing of the pending queue */ processPendingQueue: () => unknown; /** * A function to trigger loading of the submissions that were submitted * offline */ reloadPendingSubmissions: () => unknown; /** A function to remove a submission from the pending submissions */ deletePendingSubmission: (pendingTimestamp: string) => unknown; /** `true` if a submission being processed fails */ isShowingFailedNotification: boolean; /** A function to hide the notification when a submission fails to process */ hideFailedNotification: () => unknown; /** `true` if a submission being processed completes successfully. */ isShowingSuccessNotification: boolean; /** * A function to hide the notification after a submission completed * successfully */ hideSuccessNotification: () => unknown; }; /** * React Component that provides the context for the `usePendingSubmissions()` * hook to be used by components further down your component tree. **It should * only be included in your component tree once and ideally at the root of the * application.** * * #### Example * * ```jsx * import * as React from 'react' * import { * PendingSubmissionsContextProvider, * usePendingSubmissions, * } from '@oneblink/apps-react' * * function Component() { * const pendingSubmissionsContext = usePendingSubmissions() * // use pending submissions here * } * * function App() { * return ( * * * * ) * } * * const root = document.getElementById('root') * if (root) { * ReactDOM.render(, root) * } * ``` * * @param props * @returns * @group Components */ export declare function PendingSubmissionsContextProvider({ isPendingQueueEnabled, successNotificationTimeoutMs, children, }: { /** * `true` if pending queue is enabled, otherwise `false`. Can be used prevent * offline submissions from being processed. */ isPendingQueueEnabled: boolean; /** * When a submission is processed successfully the * `isShowingSuccessNotification` will be temporarily set to `true`, it will * be set back to `false` after 5 seconds. This prop will allow you to * customise how long to wait before hiding the notification with a * milliseconds value. */ successNotificationTimeoutMs?: number; /** Your application components */ children: React.ReactNode; }): import("react/jsx-runtime").JSX.Element; /** * React hook to get the context value for Pending Submissions. Will throw an * Error if used outside of the `` * component. * * @returns * @group Hooks */ export default function usePendingSubmissions(): PendingSubmissionsContextValue;