diff --git a/src/app/model/base.ts b/src/app/model/base.ts index 57aacf50..0473de0e 100644 --- a/src/app/model/base.ts +++ b/src/app/model/base.ts @@ -35,6 +35,7 @@ export const setSeed = createEvent(); export const generateSeedFx = createEffect(generateSeed); export const $seed = restore(setSeed, ['', false] as Seed); +export const $words = $seed.map(([seed]) => seed.split(' ')); $seed.reset(generateSeedFx); $seed.on(generateSeedFx.doneData, (state, payload) => [payload, false]); diff --git a/src/app/pages/intro/create/SeedConfirm.tsx b/src/app/pages/intro/create/SeedConfirm.tsx index 54ea9cac..ad03e701 100644 --- a/src/app/pages/intro/create/SeedConfirm.tsx +++ b/src/app/pages/intro/create/SeedConfirm.tsx @@ -3,7 +3,7 @@ import React, { useState } from 'react'; import { Button, Footer, Window } from 'app/uikit'; import { ArrowRightIcon } from '@app/icons'; -import { $ids, $seed, generateSeedFx } from '@app/model/base'; +import { $ids, $words, generateSeedFx } from '@app/model/base'; import { useStore } from 'effector-react'; import { setView, View } from '@app/model/view'; import SeedList from '@pages/intro/seed'; @@ -11,19 +11,19 @@ import SeedList from '@pages/intro/seed'; const SEED_CONFIRM_COUNT = 6; const SeedConfirm: React.FC = () => { - const [seed] = useStore($seed); + const seed = useStore($words); const ids = useStore($ids); const [errors, setErrors] = useState( new Array(SEED_CONFIRM_COUNT).fill(null), ); - const valid = errors.every((value) => value === false); + const valid = errors.every((value) => value === true); const handleInput: React.ChangeEventHandler = (event) => { event.preventDefault(); const { name, value } = event.target; const index = parseInt(name, 10); - const result = seed[index] !== value; + const result = seed[index] === value; const target = ids.indexOf(index); if (errors[target] !== result) {