MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / ApiKeys

Function ApiKeys

frontend/src/components/apiKey/index.tsx:19–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17import { useTranslation } from 'react-i18next';
18import { createApiKeys, getApiKeysList, getApiKeys, updateApiKeys, deleteApiKeys } from '../../axios/apiKeys.ts'
19function ApiKeys() {
20 const { apiKeyLists } = useSelector((state: any) => state.apikey);
21 const dispatch = useDispatch()
22 const { t } = useTranslation();
23 const { apikeysTableColumn } = CommonComponents();
24 const { tooltipEditTitle, tooltipDeleteTitle, tooltipShowTitle, tooltipHideTitle } = tooltipTitle();
25
26 useEffect(() => {
27 if (apiKeyLists.data.length > 0) {
28 const data = apiKeyLists.data.map((item: any) => {
29 return {
30 ...item,
31 key: item.apikey_id
32 }
33 })
34 setApiKeysList(data)
35 }else {
36 setApiKeysList([])
37 }
38 }, [apiKeyLists])
39 const [form] = Form.useForm();
40 const [form1] = Form.useForm();
41 const [deleteForm] = Form.useForm();
42 const [openEditAPIKey, setOpenEditAPIKey] = useState(false)
43 const [openCreateAPIKey, setOpenCreateAPIKey] = useState(false)
44 const [createNameValue, setCreateNameValue] = useState('')
45
46 const [openDeleteModal, setOpenDeleteModal] = useState(false)
47 const [apiKeysList, setApiKeysList] = useState<any[]>([])
48 const [loading, setLoading] = useState(false);
49 const [confirmLoading, setConfirmLoading] = useState(false)
50 const [tableLoading, setTableLoading] = useState(false)
51 const [deleteLoading, setDeleteLoading] = useState(false);
52 const [record, setRecord] = useState<any>({});
53 const [initialValues, setInitialValues] = useState({
54 name: '',
55 })
56 const [id, setId] = useState('');
57 const [disabled, setDisabled] = useState(true);
58 const handleNewInstance = async () => {
59 await form.setFieldValue('name', '')
60 await setCreateNameValue('')
61 setId('')
62 setOpenCreateAPIKey(true)
63 await form.resetFields()
64 }
65
66 const fetchData = async (params: Record<string, any>) => {
67 try {
68 setTableLoading(true)
69 const res = await getApiKeysList(params)
70 const data = res.data.map((item: any) => {
71 return {
72 ...item,
73 key: item.apikey_id
74 }
75 })
76 setApiKeysList(data)

Callers

nothing calls this directly

Calls 4

CommonComponentsFunction · 0.85
handleShowFunction · 0.85
handleEditFunction · 0.70
handleDeleteFunction · 0.70

Tested by

no test coverage detected