diff --git a/copperc/src/app/u/datasets/_modals/addattribute.tsx b/copperc/src/app/u/datasets/_modals/addattribute.tsx index 7e1f1dc7..9dc684ed 100644 --- a/copperc/src/app/u/datasets/_modals/addattribute.tsx +++ b/copperc/src/app/u/datasets/_modals/addattribute.tsx @@ -5,7 +5,7 @@ import { useMutation } from "@tanstack/react-query"; import { edgeclient } from "@/lib/api/client"; import { components } from "@/lib/api/openapi"; import { ReactElement, useState } from "react"; -import { DataType, dataTypes, getAttrTypeInfo } from "@/lib/attributes"; +import { AttrDataType, attrDataTypes, getAttrTypeInfo } from "@/lib/attributes"; export function useAddAttributeModal(params: { dataset_id: number; @@ -20,7 +20,7 @@ export function useAddAttributeModal(params: { response: string | null; }>({ type: null, response: null }); - const [newAttrType, setNewAttrType] = useState(null); + const [newAttrType, setNewAttrType] = useState(null); // Get input ui for attr-specific parameters let NewAttrForm: @@ -101,7 +101,7 @@ export function useAddAttributeModal(params: { { - const int = value === null ? null : parseInt(value); - if (int === selectedDataset) { - return; - } - - if (int === null || datasets.data === undefined) { - setSelectedDataset(null); - params.setSelectedClass(null); - return; - } - setSelectedDataset(int); - params.setSelectedClass(null); - }} - /> - - { + const int = value === null ? null : parseInt(value); + if (int === selectedDataset) { + return; + } + + if (int === null || datasets.data === undefined) { + setSelectedDataset(null); + params.setSelectedClass(null); + params.setSelectedDataset(null); + return; + } + + setSelectedDataset(int); params.setSelectedClass(null); - return; + params.setSelectedDataset(null); + }} + /> + + { if (value === null) { @@ -342,21 +363,15 @@ function TableHeader(params: { setSelectedAttr(null); } }} - data={params.item_class.attributes - .map((a) => ({ - label: a.name, - value: a.id.toString(), - disabled: - params.columns.find( - (c) => c.id === `attr-${a.id}`, - ) !== undefined, - })) - .filter((v) => !v.disabled)} + data={available_attrs} />