@@ -2,18 +2,23 @@ import * as React from 'react';
2
2
import { useEffect , useState } from 'react' ;
3
3
import { useAppDispatch , useAppSelector } from "../../redux/hooks" ;
4
4
import { selectListProjectsData } from "./slice" ;
5
- import { DeleteProjectRequest , ListProjectsRequest , ProjectDTO } from "./model" ;
5
+ import { DeleteProjectRequest , GetProjectRequest , ListProjectsRequest , ProjectDTO } from "./model" ;
6
6
import { getCurrentUser } from "../../utils/sessionstorageClient" ;
7
7
import { listProjectsAsync } from "./async-apis/listProjects" ;
8
8
import { Container , Paper , Stack , Table , TableBody , TableCell , TableContainer , TableHead , TableRow } from "@mui/material" ;
9
9
import Button from "@mui/material/Button" ;
10
10
import { deleteProjectAsync } from "./async-apis/deleteProject" ;
11
11
import Typography from "@mui/material/Typography" ;
12
12
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline" ;
13
+ import ChangeCircleIcon from '@mui/icons-material/ChangeCircle' ;
14
+
13
15
import { DeleteProject } from "./delete-project" ;
16
+ import { getProjectAsync } from "./async-apis/getProject" ;
17
+ import { useNavigate } from "react-router-dom" ;
14
18
15
19
export const Projects = ( ) => {
16
20
const dispatch = useAppDispatch ( ) ;
21
+ const navigate = useNavigate ( ) ;
17
22
const listProjectsData = useAppSelector ( selectListProjectsData ) ;
18
23
const [ payload , setPayload ] = useState ( {
19
24
isDeleteProjectDialogOpen : false ,
@@ -56,6 +61,15 @@ export const Projects = () => {
56
61
} ) ;
57
62
} ;
58
63
64
+ const handleSwitchProjectClick = ( projectDTO : ProjectDTO ) => {
65
+ const getProjectRequest : GetProjectRequest = {
66
+ id : projectDTO . id ,
67
+ email : getCurrentUser ( )
68
+ } ;
69
+ dispatch ( getProjectAsync ( getProjectRequest ) ) ;
70
+ navigate ( '/home' ) ;
71
+ } ;
72
+
59
73
const getActionButtons = ( projectDTO : ProjectDTO ) : React . ReactNode => {
60
74
return < Stack direction = "row" spacing = "3" >
61
75
< Button variant = "contained"
@@ -65,6 +79,14 @@ export const Projects = () => {
65
79
} } >
66
80
< DeleteOutlineIcon />
67
81
</ Button >
82
+
83
+ < Button variant = "contained"
84
+ color = "primary"
85
+ onClick = { ( ) => {
86
+ handleSwitchProjectClick ( projectDTO ) ;
87
+ } } >
88
+ < ChangeCircleIcon />
89
+ </ Button >
68
90
</ Stack > ;
69
91
} ;
70
92
0 commit comments