1
1
import ReplayIcon from "@mui/icons-material/Replay" ;
2
2
import { Box , Button , Container , Typography } from "@mui/material" ;
3
- import React , { FC } from "react" ;
4
- import { Link } from "react-router-dom" ;
3
+ import React , { FC , useMemo } from "react" ;
4
+ import { Link , useLocation } from "react-router-dom" ;
5
5
import { useToggle } from "react-use" ;
6
6
7
7
import { useAsyncWithThrow } from "../hooks/useAsyncWithThrow" ;
@@ -17,13 +17,22 @@ import { aironeApiClient } from "repository/AironeApiClient";
17
17
import { JobList as ConstJobList } from "services/Constants" ;
18
18
19
19
export const JobListPage : FC = ( ) => {
20
- const [ page , changePage ] = usePage ( ) ;
20
+ const location = useLocation ( ) ;
21
21
22
+ const [ page , changePage ] = usePage ( ) ;
22
23
const [ refresh , toggleRefresh ] = useToggle ( false ) ;
23
24
25
+ const { targetId } = useMemo ( ( ) => {
26
+ const params = new URLSearchParams ( location . search ) ;
27
+ const targetId = params . get ( "target_id" ) ;
28
+ return {
29
+ targetId : targetId ? Number ( targetId ) : undefined ,
30
+ } ;
31
+ } , [ location . search ] ) ;
32
+
24
33
const jobs = useAsyncWithThrow ( async ( ) => {
25
- return await aironeApiClient . getJobs ( page ) ;
26
- } , [ page , refresh ] ) ;
34
+ return await aironeApiClient . getJobs ( page , targetId ) ;
35
+ } , [ page , targetId , refresh ] ) ;
27
36
28
37
return (
29
38
< Box className = "container-fluid" >
0 commit comments