diff --git a/components/domain/wishes/createWish/CreateWish.tsx b/components/domain/wishes/createWish/CreateWish.tsx index c6362bf..b5533c3 100644 --- a/components/domain/wishes/createWish/CreateWish.tsx +++ b/components/domain/wishes/createWish/CreateWish.tsx @@ -1,85 +1,75 @@ -import { FC, FormEvent, SyntheticEvent, useState } from 'react' +import { FC, FormEvent, SyntheticEvent, useEffect, useState } from 'react' import { result } from '../../../common/result' import { createWish, Wish } from '../models' +import { v4 as uuid } from 'uuid' interface CreateWishProps { onFocus: () => void + hasFocus: boolean onSubmit: (wish: Wish) => void + wish: Wish } const CreateWish: FC = (props) => { - const [focused, setFocused] = useState(false) - - const onSubmit = (e: SyntheticEvent) => { - e.preventDefault() - - const target = e.target as typeof e.target & { - wishName: { value: string } - wishDescription: { value?: string } - wishLink: { value?: string } - } - - const wishRes = createWish( - target.wishName.value, - target.wishDescription.value, - target.wishLink.value - ) - - result.tap(wishRes, (wish) => { - props.onSubmit(wish) - }) - } - return ( -
setFocused(true)}> - -
-
-
-
- -
- -
-
-
- +
props.onFocus()}> +
+
+ + props.onSubmit({ ...props.wish, name: e.target.value }) + } + value={props.wish.name} + /> +
+
- - +
+
) } -const InnerWishPrompt: FC = (props) => { +interface InnerWishPromptInterface { + wish: Wish + onChange: (wish: Wish) => void +} + +const InnerWishPrompt: FC = (props) => { return (