mirror of https://github.com/halo-dev/halo
25 lines
741 B
TypeScript
25 lines
741 B
TypeScript
import { apiClient } from "@/utils/api-client";
|
|
import type { FormKitNode, FormKitTypeDefinition } from "@formkit/core";
|
|
import { select, selects, defaultIcon } from "@formkit/inputs";
|
|
|
|
function optionsHandler(node: FormKitNode) {
|
|
node.on("created", async () => {
|
|
const { data } =
|
|
await apiClient.extension.category.listcontentHaloRunV1alpha1Category();
|
|
|
|
node.props.options = data.items.map((category) => {
|
|
return {
|
|
value: category.metadata.name,
|
|
label: category.spec.displayName,
|
|
};
|
|
});
|
|
});
|
|
}
|
|
|
|
export const categorySelect: FormKitTypeDefinition = {
|
|
...select,
|
|
props: ["placeholder"],
|
|
forceTypeProp: "select",
|
|
features: [optionsHandler, selects, defaultIcon("select", "select")],
|
|
};
|