@@ -5,6 +5,7 @@ import { Part, Review_Status, User } from 'shared';
55import { getReviewStatusDisplayName , getStatusColor } from '../../../utils/part.utils' ;
66import { useNotifyPartAssignee , useNotifyPartReviewer } from '../../../hooks/part-review.hooks' ;
77import { useState } from 'react' ;
8+ import { useToast } from '../../../hooks/toasts.hooks' ;
89
910const PartReviewStatusPill = ( status : Review_Status ) => {
1011 return (
@@ -46,8 +47,9 @@ interface PartPageOverviewProps {
4647}
4748
4849const PartOverview : React . FC < PartPageOverviewProps > = ( { part } : PartPageOverviewProps ) => {
49- const { mutate : notifyPartAssignee } = useNotifyPartAssignee ( ) ;
50- const { mutate : notifyPartReviewer } = useNotifyPartReviewer ( ) ;
50+ const { mutateAsync : notifyPartAssignee } = useNotifyPartAssignee ( ) ;
51+ const { mutateAsync : notifyPartReviewer } = useNotifyPartReviewer ( ) ;
52+ const toast = useToast ( ) ;
5153
5254 const [ notifiedUserIds , setNotifiedUserIds ] = useState < Set < string > > ( new Set ( ) ) ;
5355
@@ -60,13 +62,20 @@ const PartOverview: React.FC<PartPageOverviewProps> = ({ part }: PartPageOvervie
6062 { status !== Review_Status . APPROVED && (
6163 < IconButton
6264 size = "small"
63- onClick = { ( ) => {
64- if ( isReviewer ) {
65- notifyPartReviewer ( { partId, reviewerId : anyUser . userId } ) ;
66- } else {
67- notifyPartAssignee ( { partId, assigneeId : anyUser . userId } ) ;
65+ onClick = { async ( ) => {
66+ try {
67+ if ( isReviewer ) {
68+ await notifyPartReviewer ( { partId, reviewerId : anyUser . userId } ) ;
69+ } else {
70+ await notifyPartAssignee ( { partId, assigneeId : anyUser . userId } ) ;
71+ }
72+ setNotifiedUserIds ( ( ids ) => ids . add ( anyUser . userId ) ) ;
73+ toast . success ( '' + ( isReviewer ? 'Reviewer' : 'Assignee' ) + ' notified' ) ;
74+ } catch ( error ) {
75+ if ( error instanceof Error ) {
76+ toast . error ( error . message ) ;
77+ }
6878 }
69- setNotifiedUserIds ( ( ids ) => ids . add ( anyUser . userId ) ) ;
7079 } }
7180 sx = { {
7281 backgroundColor : '#444444' ,
0 commit comments