()
| 69 | } |
| 70 | |
| 71 | export function PluginForm() { |
| 72 | const router = useRouter(); |
| 73 | const [mode, setMode] = useState<"auto" | "manual">("auto"); |
| 74 | |
| 75 | const [parsed, setParsed] = useState<ParsedPlugin | null>(null); |
| 76 | const [editedName, setEditedName] = useState(""); |
| 77 | const [editedDescription, setEditedDescription] = useState(""); |
| 78 | const [parseError, setParseError] = useState<string | null>(null); |
| 79 | const [publishError, setPublishError] = useState<string | null>(null); |
| 80 | const [editedComponents, setEditedComponents] = useState<ComponentDraft[]>( |
| 81 | [], |
| 82 | ); |
| 83 | |
| 84 | const [autoLogo, setAutoLogo] = useState<string | null>(null); |
| 85 | |
| 86 | const [manualName, setManualName] = useState(""); |
| 87 | const [manualDescription, setManualDescription] = useState(""); |
| 88 | const [manualLogo, setManualLogo] = useState<string | null>(null); |
| 89 | const [manualRepository, setManualRepository] = useState(""); |
| 90 | const [manualHomepage, setManualHomepage] = useState(""); |
| 91 | const [manualKeywords, setManualKeywords] = useState(""); |
| 92 | const [manualComponents, setManualComponents] = useState<ComponentDraft[]>([ |
| 93 | newComponentDraft(), |
| 94 | ]); |
| 95 | |
| 96 | const form = useForm<z.infer<typeof autoFormSchema>>({ |
| 97 | resolver: zodResolver(autoFormSchema), |
| 98 | defaultValues: { url: "" }, |
| 99 | }); |
| 100 | |
| 101 | const { execute: executeParse, isExecuting: isParsing } = useAction( |
| 102 | parseGitHubPluginAction, |
| 103 | { |
| 104 | onSuccess: ({ data }) => { |
| 105 | if (data) { |
| 106 | setParsed(data); |
| 107 | setEditedName(data.name); |
| 108 | setEditedDescription(data.description); |
| 109 | setEditedComponents( |
| 110 | data.components.map((c) => ({ |
| 111 | id: crypto.randomUUID(), |
| 112 | type: c.type as ComponentType, |
| 113 | slug: c.slug, |
| 114 | name: c.name, |
| 115 | description: c.description ?? "", |
| 116 | content: c.content ?? "", |
| 117 | })), |
| 118 | ); |
| 119 | setParseError(null); |
| 120 | } |
| 121 | }, |
| 122 | onError: ({ error }) => { |
| 123 | setParseError(error.serverError ?? "Failed to parse repository"); |
| 124 | setParsed(null); |
| 125 | }, |
| 126 | }, |
| 127 | ); |
| 128 |
nothing calls this directly
no test coverage detected