88 type FieldMetadata ,
99} from '@conform-to/react'
1010import { getZodConstraint , parseWithZod } from '@conform-to/zod'
11- import { type Note , type NoteImage } from '@prisma/client'
1211import { useState } from 'react'
13- import { Form , useActionData , type useLoaderData } from 'react-router'
12+ import { Form } from 'react-router'
1413import { z } from 'zod'
1514import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
1615import { floatingToolbarClassName } from '#app/components/floating-toolbar.tsx'
@@ -21,7 +20,7 @@ import { Label } from '#app/components/ui/label.tsx'
2120import { StatusButton } from '#app/components/ui/status-button.tsx'
2221import { Textarea } from '#app/components/ui/textarea.tsx'
2322import { cn , getNoteImgSrc , useIsPending } from '#app/utils/misc.tsx'
24- import { type action } from './__note-editor.server '
23+ import { type Info } from './+types/notes.$noteId_.edit.ts '
2524
2625const titleMinLength = 1
2726const titleMaxLength = 100
@@ -43,8 +42,6 @@ const ImageFieldsetSchema = z.object({
4342
4443export type ImageFieldset = z . infer < typeof ImageFieldsetSchema >
4544
46- type SerializeFrom < T > = ReturnType < typeof useLoaderData < T > >
47-
4845export const NoteEditorSchema = z . object ( {
4946 id : z . string ( ) . optional ( ) ,
5047 title : z . string ( ) . min ( titleMinLength ) . max ( titleMaxLength ) ,
@@ -54,14 +51,11 @@ export const NoteEditorSchema = z.object({
5451
5552export function NoteEditor ( {
5653 note,
54+ actionData,
5755} : {
58- note ?: SerializeFrom <
59- Pick < Note , 'id' | 'title' | 'content' > & {
60- images : Array < Pick < NoteImage , 'id' | 'altText' > >
61- }
62- >
56+ note ?: Info [ 'loaderData' ] [ 'note' ]
57+ actionData ?: Info [ 'actionData' ]
6358} ) {
64- const actionData = useActionData < typeof action > ( )
6559 const isPending = useIsPending ( )
6660
6761 const [ form , fields ] = useForm ( {
0 commit comments