CE-3438: Add error and loading states IOCDelete
3 unresolved threads
3 unresolved threads
Had to update common component
Merge request reports
Activity
requested review from @johannaszepanski and @skybrewer
assigned to @maxfrederiksen
25 25 setOpen(false); 26 26 }, [setOpen]); 27 27 28 useEffect(() => { 29 if (deletedIoc) { 30 showSnackBar(`IOC ${ioc.namingName} deleted`, "success"); 31 navigate("/iocs", { replace: true }); 32 } 33 }, [deletedIoc, ioc.namingName, navigate, showSnackBar]); changed this line in version 2 of the diff
31 .unwrap() 32 .then(() => { 33 showSnackBar(`IOC ${ioc.namingName} deleted`, "success"); 34 navigate("/iocs", { replace: true }); 35 }) 36 .catch((error) => { 37 setError(error); 38 setButtonDisabled(false); 39 }); 40 }, [ioc, deleteIOC, setButtonDisabled, navigate, showSnackBar]); 37 try { 38 await deleteIOC({ iocId: ioc.id }).unwrap(); 39 showSnackBar(`IOC ${ioc.namingName} deleted`, "success"); 40 navigate("/iocs", { replace: true }); 41 } catch (err) { 42 showSnackBar(getErrorMessage(err), "error"); I'm a bit confused over this snackbar. If there is an error deleting an IOC then the error message should be visible in the dialog and the dialog should still be open.
Although the try catch is working I personally think it is cleaner here to chain the promise as they do in the rtk documentation for unwrap.
changed this line in version 3 of the diff
added 5 commits
-
49c9098f...dacf2566 - 2 commits from branch
develop
- 07182943 - CE-3438: Add error and loading states IOCDelete
- 2576d352 - Add unwrap logic and extra reset() call
- 870b5761 - Remove async/await
Toggle commit list-
49c9098f...dacf2566 - 2 commits from branch
reset approvals from @johannaszepanski by pushing to the branch
mentioned in commit d1380680
Please register or sign in to reply