From 3356fa8dbd0a2f76190e73f5fd842ddf9e83eafb Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Mon, 23 Dec 2024 11:59:35 +0100 Subject: [PATCH] adding steps --- .../deployment/wizard/DeploymentSteps.svelte | 86 ++-------- .../wizard/FieldDefinitionButtons.svelte | 25 ++- .../deployment/wizard/deploymentStore.ts | 30 ++++ .../deployment/wizard/getDeploymentSteps.ts | 76 +++++++++ packages/ui-components/src/lib/index.ts | 9 +- .../src/lib/types/deploymentSteps.ts | 156 +++++++++--------- .../src/lib/types/wizardSteps.ts | 9 +- 7 files changed, 238 insertions(+), 153 deletions(-) create mode 100644 packages/ui-components/src/lib/components/deployment/wizard/deploymentStore.ts create mode 100644 packages/ui-components/src/lib/components/deployment/wizard/getDeploymentSteps.ts diff --git a/packages/ui-components/src/lib/components/deployment/wizard/DeploymentSteps.svelte b/packages/ui-components/src/lib/components/deployment/wizard/DeploymentSteps.svelte index 177e65b75..3c469daff 100644 --- a/packages/ui-components/src/lib/components/deployment/wizard/DeploymentSteps.svelte +++ b/packages/ui-components/src/lib/components/deployment/wizard/DeploymentSteps.svelte @@ -4,14 +4,6 @@ import SelectToken from '../SelectToken.svelte'; import TokenInputButtons from './TokenInputButtons.svelte'; import TokenOutputButtons from './TokenOutputButtons.svelte'; - import type { - WizardStep, - SelectTokenStep, - FieldStep, - DepositStep, - TokenInputStep, - TokenOutputStep - } from '../../../types/wizardSteps'; import type { DotrainOrderGui, @@ -22,6 +14,8 @@ Vault } from '@rainlanguage/orderbook/js_api'; import { Button } from 'flowbite-svelte'; + import { getDeploymentSteps } from './getDeploymentSteps'; + import deploymentStore from './deploymentStore'; export let gui: DotrainOrderGui; export let selectTokens: SelectTokens; @@ -36,65 +30,24 @@ export let handleAddOrder: () => Promise; export let tokenInfos: TokenInfos; - $: if (currentStep) { - const fieldValues = gui.getAllFieldValues(); - console.log(fieldValues); - } - - let deploymentSteps: WizardStep[] = [ - ...(selectTokens.size > 0 && isLimitStrat - ? Array.from(selectTokens.entries()).map( - ([token]): SelectTokenStep => ({ - type: 'tokens', - token, - gui, - selectTokens - }) - ) - : []), + let deploymentSteps = getDeploymentSteps( + selectTokens, + isLimitStrat, + allFieldDefinitions, + gui, + allDeposits, + allTokenInputs, + allTokenOutputs, + inputVaultIds, + outputVaultIds, + tokenInfos + ); - ...allFieldDefinitions.map( - (fieldDefinition): FieldStep => ({ - type: 'fields', - fieldDefinition, - gui - }) - ), + deploymentStore.populateDeploymentSteps(deploymentSteps); - ...allDeposits.map( - (deposit): DepositStep => ({ - type: 'deposits', - deposit, - gui, - tokenInfos - }) - ), - - ...allTokenInputs.map( - (input, i): TokenInputStep => ({ - type: 'tokenInput', - input, - gui, - tokenInfos, - i, - inputVaultIds - }) - ), - ...allTokenOutputs.map( - (output, i): TokenOutputStep => ({ - type: 'tokenOutput', - output, - gui, - tokenInfos, - i, - outputVaultIds - }) - ) - ]; + $: console.log('DEPLOYMENT STEPS', $deploymentStore.deploymentSteps); let currentStep = deploymentSteps[0]; - $: console.log('current step in parent', currentStep); - $: console.log('all steps in parent', deploymentSteps); const nextStep = () => { if (deploymentSteps.indexOf(currentStep) < deploymentSteps.length - 1) @@ -124,14 +77,7 @@ {/if} -
- {#if deploymentSteps.indexOf(currentStep) > 0} {/if} diff --git a/packages/ui-components/src/lib/components/deployment/wizard/FieldDefinitionButtons.svelte b/packages/ui-components/src/lib/components/deployment/wizard/FieldDefinitionButtons.svelte index b4f81df15..078101eef 100644 --- a/packages/ui-components/src/lib/components/deployment/wizard/FieldDefinitionButtons.svelte +++ b/packages/ui-components/src/lib/components/deployment/wizard/FieldDefinitionButtons.svelte @@ -1,12 +1,21 @@