1- import React , { useEffect , useState } from 'react' ;
1+ import React , { useCallback , useEffect , useState } from 'react' ;
22import { linksApi } from '../api/links' ;
33import { requirementsApi } from '../api/requirements' ;
44import { testCasesApi } from '../api/testCases' ;
55import { LinkSource , LinkType } from '../types/api' ;
66import type { Link , LinkCreate , Requirement , TestCase } from '../types/api' ;
77import { LoadingSpinner } from '../components/LoadingSpinner' ;
8- import { useToast } from '../components/Toast ' ;
8+ import { useToast } from '../context/ToastContext ' ;
99
1010export const ManualLinksPage : React . FC = ( ) => {
1111 const [ links , setLinks ] = useState < Link [ ] > ( [ ] ) ;
@@ -21,7 +21,7 @@ export const ManualLinksPage: React.FC = () => {
2121 } ) ;
2222 const { showToast } = useToast ( ) ;
2323
24- const loadData = async ( ) => {
24+ const loadData = useCallback ( async ( ) => {
2525 try {
2626 setLoading ( true ) ;
2727 const [ linksData , reqData , tcData ] = await Promise . all ( [
@@ -38,11 +38,11 @@ export const ManualLinksPage: React.FC = () => {
3838 } finally {
3939 setLoading ( false ) ;
4040 }
41- } ;
41+ } , [ showToast ] ) ;
4242
4343 useEffect ( ( ) => {
4444 loadData ( ) ;
45- } , [ ] ) ;
45+ } , [ loadData ] ) ;
4646
4747 const handleSubmit = async ( e : React . FormEvent ) => {
4848 e . preventDefault ( ) ;
@@ -52,9 +52,10 @@ export const ManualLinksPage: React.FC = () => {
5252 setShowModal ( false ) ;
5353 resetForm ( ) ;
5454 await loadData ( ) ;
55- } catch ( error : any ) {
55+ } catch ( error : unknown ) {
5656 console . error ( 'Error creating link:' , error ) ;
57- const message = error . response ?. data ?. detail || 'Failed to create link' ;
57+ const axiosError = error as { response ?: { data ?: { detail ?: string } } } ;
58+ const message = axiosError ?. response ?. data ?. detail ?? 'Failed to create link' ;
5859 showToast ( message , 'error' ) ;
5960 }
6061 } ;
0 commit comments