// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useEffect, useState } from 'react'; import { storiesOf } from '@storybook/react'; import { setupI18n } from '../../util/setupI18n'; import enMessages from '../../../_locales/en/messages.json'; import type { Loadable } from '../../util/loadable'; import { LoadingState } from '../../util/loadable'; import { InstallScreenQrCodeNotScannedStep } from './InstallScreenQrCodeNotScannedStep'; const i18n = setupI18n('en', enMessages); const story = storiesOf( 'Components/InstallScreen/InstallScreenQrCodeNotScannedStep', module ); const Simulation = ({ finalResult }: { finalResult: Loadable }) => { const [provisioningUrl, setProvisioningUrl] = useState>({ loadingState: LoadingState.Loading, }); useEffect(() => { const timeout = setTimeout(() => { setProvisioningUrl(finalResult); }, 2000); return () => { clearTimeout(timeout); }; }, [finalResult]); return ( ); }; story.add('QR code loading', () => ( )); story.add('QR code failed to load', () => ( )); story.add('QR code loaded', () => ( )); story.add('Simulated loading', () => ( )); story.add('Simulated failure', () => ( ));