This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import * as Domain from "@/domain"
|
||||
import { Box, Button, Callout, Flex, IconButton, Text, TextArea } from "@radix-ui/themes"
|
||||
import { TextAreaInput } from "@/lib/TextAreaInput"
|
||||
import { Box, Button, Flex, IconButton } from "@radix-ui/themes"
|
||||
import { GetRandomValues, makeUuid4 } from "@typed/id"
|
||||
import { Chunk, Effect, Match, Option, ParseResult, Ref, Runtime, Schema, SubscriptionRef } from "effect"
|
||||
import { Chunk, Effect, Match, Option, Ref, Runtime, Schema, SubscriptionRef } from "effect"
|
||||
import { Component, Memo } from "effect-fc"
|
||||
import { Hooks } from "effect-fc/hooks"
|
||||
import { SubscriptionSubRef } from "effect-fc/types"
|
||||
@@ -10,6 +11,8 @@ import { FaDeleteLeft } from "react-icons/fa6"
|
||||
import { TodosState } from "./TodosState.service"
|
||||
|
||||
|
||||
const StringTextAreaInput = TextAreaInput(Schema.String)
|
||||
|
||||
const makeTodo = makeUuid4.pipe(
|
||||
Effect.map(id => Domain.Todo.Todo.make({
|
||||
id,
|
||||
@@ -41,26 +44,14 @@ export class Todo extends Component.makeUntraced(function* Todo(props: TodoProps
|
||||
), [props._tag, props.index])
|
||||
|
||||
const [size] = yield* Hooks.useSubscribeRefs(state.sizeRef)
|
||||
const contentInput = yield* Hooks.useInput({ ref: contentRef, schema: Schema.Any })
|
||||
|
||||
const StringTextAreaInputFC = yield* StringTextAreaInput
|
||||
|
||||
return (
|
||||
<Flex direction="column" align="stretch" gap="2">
|
||||
{Option.isSome(contentInput.error) &&
|
||||
<Callout.Root color="red">
|
||||
<Callout.Text>
|
||||
{ParseResult.ArrayFormatter.formatErrorSync(contentInput.error.value).map(e => <>
|
||||
<Text>• {e.message}</Text><br />
|
||||
</>)}
|
||||
</Callout.Text>
|
||||
</Callout.Root>
|
||||
}
|
||||
|
||||
<Flex direction="row" align="center" gap="2">
|
||||
<Box flexGrow="1">
|
||||
<TextArea
|
||||
value={contentInput.value}
|
||||
onChange={contentInput.onChange}
|
||||
/>
|
||||
<StringTextAreaInputFC ref={contentRef} />
|
||||
</Box>
|
||||
|
||||
{props._tag === "edit" &&
|
||||
|
||||
Reference in New Issue
Block a user