Skip to content

Commit 923368e

Browse files
committed
fix: fix toast error info
1 parent ba26769 commit 923368e

File tree

7 files changed

+12
-47
lines changed

7 files changed

+12
-47
lines changed

frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8" />
66
<link rel="icon" type="image/svg+xml" href="./LOGO2.svg" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<title>TaskingAI | Authentication</title>
8+
<title>TaskingAI | Console</title>
99
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap">
1010

1111
</head>

frontend/src/components/modalTable/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function ModalTable({ columns, ifAllowNew, hangleFilterData, ifOnlyId, defaultSe
5353
}
5454
containerWidth = tableContainer.offsetWidth;
5555
containerHeight = tableContainerH.offsetHeight;
56+
5657
setScroll({
5758
x: containerWidth,
5859
y: containerHeight * 0.9
@@ -80,7 +81,7 @@ function ModalTable({ columns, ifAllowNew, hangleFilterData, ifOnlyId, defaultSe
8081

8182
};
8283
updateScroll();
83-
}, []);
84+
},[]);
8485
useEffect(() => {
8586
setOriginalDataSource(dataSource)
8687
}, [])

frontend/src/components/modelModal/index.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import MistralAI from '@/assets/img/MistralAI.svg?react'
1212

1313
import NoModel from '../../assets/img/NO_MODEL.svg?react'
1414
import CohereIcon from '../../assets/img/cohereIcon.svg?react'
15-
import CustomError from '../../contant/index.ts'
1615
import { Modal, Pagination, Button, Spin, Input, Form } from 'antd'
1716
import { getAiModelsList, createModels, getAiModelsForm, getModelProviderList } from '../../axios/models'
1817
import { toast } from 'react-toastify'
@@ -104,16 +103,15 @@ const ModelModal = react.forwardRef((props: modelModalProps, ref) => {
104103
const imgReverse = (providerId: string) => {
105104
if (providerId === 'openai') {
106105
return <ModelProvider width='16px' height='16px' />
107-
}
108-
else if (providerId === 'anthropic') {
106+
}else if (providerId === 'anthropic') {
109107
return <Anthropic width='16px' height='16px' />
110108
} else if (providerId === 'azure_openai') {
111109
return <Frame width='16px' height='16px' />
112110
} else if (providerId === 'google_gemini') {
113111
return <GoogleIcon width='16px' height='16px' />
114112
} else if (providerId === 'cohere') {
115113
return <CohereIcon width='16px' height='16px' />
116-
}else if (providerId === 'mistralai') {
114+
} else if (providerId === 'mistralai') {
117115
return <MistralAI width='16px' height='16px' />
118116
}
119117
}
@@ -134,10 +132,7 @@ const ModelModal = react.forwardRef((props: modelModalProps, ref) => {
134132
props.getOptionsList({ limit: 20 }, props.modelType as string)
135133
props.handleSetModelConfirmOne(false)
136134
} catch (e) {
137-
console.log(e)
138-
if (e instanceof CustomError) {
139-
toast.error(e.response.data.error.message)
140-
}
135+
toast.error(e.response.data.error.message)
141136
} finally {
142137
setConfirmLoading(false)
143138
}
@@ -326,7 +321,7 @@ const ModelModal = react.forwardRef((props: modelModalProps, ref) => {
326321
]}
327322
>
328323
<div>
329-
<div className='description'>{(property as { description: string }).description}</div>
324+
<div className='description'>{(property as { description: string }).description}</div>
330325

331326
<Input placeholder={`Enter ${key}`} className='input' />
332327
</div>

frontend/src/components/modelsPage/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import ModelModal from '@/components/modelModal';
1919
import closeIcon from '../../assets/img/x-close.svg'
2020
import { toast } from 'react-toastify';
2121
import { RecordType,ChildRefType,formDataType } from '../../contant/index.ts'
22-
import CustomError from '../../contant/index.ts'
2322
function ModelsPage() {
2423
const [form] = Form.useForm()
2524
const [form1] = Form.useForm()
@@ -193,9 +192,7 @@ function ModelsPage() {
193192
}
194193
await fetchData(params1)
195194
} catch (error) {
196-
if (error instanceof CustomError) {
197195
toast.error(error.response.data.error.message)
198-
}
199196
}
200197

201198

frontend/src/components/retrieval/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import DeleteIcon from '../../assets/img/deleteIcon.svg?react'
88
import EditIcon from '../../assets/img/editIcon.svg?react'
99
import ModalTable from '../modalTable/index';
1010
import ModelModal from '../modelModal/index'
11-
import CustomError from '../../contant/index.ts'
1211
// import {TKNegativeModal} from '@taskingai/taskingai-ui'
1312
import { modelsTableColumn, collectionTableColumn } from '../../contents/index.tsx'
1413
import { ChildRefType } from '../../contant/index.ts'
@@ -189,9 +188,7 @@ function Retrieval() {
189188
setUpdateRetrievalPrevButton(true)
190189

191190
} catch (error) {
192-
if (error instanceof CustomError) {
193191
toast.error(error.response.data.error.message)
194-
}
195192
}
196193
}
197194

@@ -232,9 +229,7 @@ function Retrieval() {
232229
setUpdateRetrievalPrevButton(true)
233230

234231
} catch (error) {
235-
if (error instanceof CustomError) {
236232
toast.error(error.response.data.error.message)
237-
}
238233
}
239234
}
240235
const handleNameChange = (e:React.ChangeEvent<HTMLInputElement>) => {

frontend/src/contant/index.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11

2-
interface CustomErrorResponse {
3-
data: {
4-
error: {
5-
message: string;
6-
};
7-
};
8-
}
9-
10-
class CustomError extends Error {
11-
response: CustomErrorResponse;
122

13-
constructor(message: string, response: CustomErrorResponse) {
14-
super(message);
15-
this.name = 'CustomError';
16-
this.response = response;
17-
}
18-
}
193
interface projectHomeType {
204
key: string;
215
[key: string]: any;
@@ -87,5 +71,4 @@ interface contentRefType {
8771
scrollHeight?:any;
8872
scrollTo?:any
8973
}
90-
export type {contentRefType,formDataType,settingModalProps,promptListType, projectIdType,ModelProviderType,projectHomeType,RecordType,ChildRefType,TableProps,modelModalProps}
91-
export default CustomError
74+
export type {contentRefType,formDataType,settingModalProps,promptListType, projectIdType,ModelProviderType,projectHomeType,RecordType,ChildRefType,TableProps,modelModalProps}

frontend/src/views/login/index.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import { useNavigate } from "react-router-dom";
22
import { Form, Input, Button } from 'antd';
3-
import { useState, useEffect } from 'react';
3+
import { useState } from 'react';
44
import aiIcon from "../../assets/img/LOGO+TEXT.svg";
55
import Beta from "../../assets/img/CommunityTag.svg?react";
66
import { toast } from 'react-toastify';
77
import 'react-toastify/dist/ReactToastify.css';
88
import style from './login.module.scss'
9-
import CustomError from '@/contant/index'
109
import { fetchLogin } from '@/axios/index'
1110

1211
function Login() {
13-
useEffect(() => {
14-
document.title = 'TaskingAI | Authentication';
15-
}, [])
1612
const [loading, setLoading] = useState(false)
1713
const navigate = useNavigate()
1814
const onFinish = async (val: object) => {
@@ -24,14 +20,12 @@ function Login() {
2420
await navigate('/project/models')
2521
toast.success('Signin successful')
2622
} catch (error) {
27-
if (error instanceof CustomError) {
28-
toast.error(error.response.data.error.message)
29-
}
23+
toast.error(error.response.data.error.message)
3024
}
3125
setLoading(false)
3226

3327
}
34-
28+
3529
return (
3630
<>
3731
<div className={style.login}>
@@ -49,7 +43,7 @@ function Login() {
4943
required: true,
5044
message: 'Please input your username.',
5145
},
52-
46+
5347
]}
5448
>
5549
<Input placeholder='Enter your username' className={style["input-edit"]} />

0 commit comments

Comments
 (0)