@@ -7,8 +7,10 @@ import { Container, Box, Grid, Typography } from "@material-ui/core";
77import ProjectSelect from "../components/ProjectSelect" ;
88import Filters from "../components/Filters" ;
99import { TestVariationMergeForm } from "../components/TestVariationMergeForm" ;
10+ import { useSnackbar } from "notistack" ;
1011
1112const TestVariationListPage : React . FunctionComponent = ( ) => {
13+ const { enqueueSnackbar } = useSnackbar ( ) ;
1214 const { projectId = "" } = useParams ( ) ;
1315 const [ testVariations , setTestVariations ] = React . useState < TestVariation [ ] > (
1416 [ ]
@@ -25,11 +27,18 @@ const TestVariationListPage: React.FunctionComponent = () => {
2527
2628 React . useEffect ( ( ) => {
2729 if ( projectId ) {
28- testVariationService . getList ( projectId ) . then ( ( testVariations ) => {
29- setTestVariations ( testVariations ) ;
30- } ) ;
30+ testVariationService
31+ . getList ( projectId )
32+ . then ( ( testVariations ) => {
33+ setTestVariations ( testVariations ) ;
34+ } )
35+ . catch ( ( err ) =>
36+ enqueueSnackbar ( err , {
37+ variant : "error" ,
38+ } )
39+ ) ;
3140 }
32- } , [ projectId ] ) ;
41+ } , [ projectId , enqueueSnackbar ] ) ;
3342
3443 React . useEffect ( ( ) => {
3544 setFilteredItems (
@@ -46,9 +55,19 @@ const TestVariationListPage: React.FunctionComponent = () => {
4655 } , [ query , branchName , os , device , browser , viewport , testVariations ] ) ;
4756
4857 const handleDelete = ( id : string ) => {
49- testVariationService . remove ( id ) . then ( ( item ) => {
50- setTestVariations ( testVariations . filter ( ( i ) => i . id !== item . id ) ) ;
51- } ) ;
58+ testVariationService
59+ . remove ( id )
60+ . then ( ( item ) => {
61+ setTestVariations ( testVariations . filter ( ( i ) => i . id !== item . id ) ) ;
62+ enqueueSnackbar ( "Deleted" , {
63+ variant : "success" ,
64+ } ) ;
65+ } )
66+ . catch ( ( err ) =>
67+ enqueueSnackbar ( err , {
68+ variant : "error" ,
69+ } )
70+ ) ;
5271 } ;
5372
5473 return (
0 commit comments