From b4e23beb68e930a6d89f70d2522b64387e3fac4c Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Wed, 2 Nov 2022 12:03:30 +0100 Subject: [PATCH 1/2] [New #188] Add simulation of possible values endpoint --- .storybook/preview.js | 6 ++++++ src/stories/SForms.stories.tsx | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.storybook/preview.js b/.storybook/preview.js index 120376b3..6082c8e4 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -50,6 +50,12 @@ export const globalTypes = { defaultValue: false, control: { type: "boolean" }, }, + timeOut: { + name: "Time Out (ms)", + description: "Set time-out for possible values (in ms)", + defaultValue: 1500, + control: { type: "number", min: 0, max: 10000, step: 500 }, + }, }; const options = { diff --git a/src/stories/SForms.stories.tsx b/src/stories/SForms.stories.tsx index f3ac866a..cfb6a9f0 100644 --- a/src/stories/SForms.stories.tsx +++ b/src/stories/SForms.stories.tsx @@ -12,6 +12,7 @@ import occurrenceReportingForm from "./assets/form/occurrenceReportingForm.json" import queryString from "query-string"; import Constants from "../constants/Constants"; import IntlContextProvider from "../contexts/IntlContextProvider"; +import possibleValues from "./assets/possibleValues.json"; const getP = (queryParameterName: string, defaultValue: string) => { return { @@ -39,7 +40,7 @@ export default { const Template: ComponentStory = ( args, - { globals: { iconBehavior, locale, debugMode, horizontalNavBar } } + { globals: { iconBehavior, locale, debugMode, horizontalNavBar, timeOut } } ) => { const options = { i18n: { @@ -82,9 +83,20 @@ const Template: ComponentStory = ( }, ], }; + + const fetchTypeAheadValues = () => { + return new Promise((resolve) => + setTimeout(() => resolve(possibleValues), timeOut) + ); + }; + return ( - + ); }; From 8298ed23122572506bad9ece732ce5ede0a9c262 Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Wed, 2 Nov 2022 12:28:28 +0100 Subject: [PATCH 2/2] [Fix #188] Fix fetch type ahead values prop --- src/stories/SForms.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stories/SForms.stories.tsx b/src/stories/SForms.stories.tsx index cfb6a9f0..e76d5587 100644 --- a/src/stories/SForms.stories.tsx +++ b/src/stories/SForms.stories.tsx @@ -95,7 +95,7 @@ const Template: ComponentStory = ( );