@@ -12,71 +12,69 @@ type Props = Readonly<
1212 actions : ReadonlySet < OrgSchemaAction > ;
1313 className ?: string | undefined ;
1414 isFeedbackFormSupported ?: boolean ;
15- onHandleFeedbackActionClick ?: ( action : OrgSchemaAction ) => void ;
15+ onActionClick ?: ( action : OrgSchemaAction ) => void ;
1616 selectedAction ?: OrgSchemaAction | undefined ;
1717 } >
1818> ;
1919
2020const DEBOUNCE_TIMEOUT = 500 ;
2121
22- const Feedback = memo (
23- ( { actions, className, isFeedbackFormSupported, onHandleFeedbackActionClick, selectedAction } : Props ) => {
24- const [ { clearTimeout, setTimeout } ] = usePonyfill ( ) ;
25- const postActivity = usePostActivity ( ) ;
26- const localize = useLocalizer ( ) ;
22+ const Feedback = memo ( ( { actions, className, isFeedbackFormSupported, onActionClick, selectedAction } : Props ) => {
23+ const [ { clearTimeout, setTimeout } ] = usePonyfill ( ) ;
24+ const postActivity = usePostActivity ( ) ;
25+ const localize = useLocalizer ( ) ;
2726
28- const postActivityRef = useRefFrom ( postActivity ) ;
27+ const postActivityRef = useRefFrom ( postActivity ) ;
2928
30- useEffect ( ( ) => {
31- if ( ! selectedAction || isFeedbackFormSupported ) {
32- return ;
33- }
29+ useEffect ( ( ) => {
30+ if ( ! selectedAction || isFeedbackFormSupported ) {
31+ return ;
32+ }
3433
35- const timeout = setTimeout (
36- ( ) =>
37- // TODO: We should update this to use W3C Hydra.1
38- postActivityRef . current ( {
39- entities : [ selectedAction ] ,
40- name : 'webchat:activity-status/feedback' ,
41- type : 'event'
42- } as any ) ,
43- DEBOUNCE_TIMEOUT
44- ) ;
45-
46- return ( ) => clearTimeout ( timeout ) ;
47- } , [ clearTimeout , isFeedbackFormSupported , postActivityRef , selectedAction , setTimeout ] ) ;
48-
49- const actionProps = useMemo (
34+ const timeout = setTimeout (
5035 ( ) =>
51- [ ... actions ] . some ( action => action . actionStatus === 'CompletedActionStatus' )
52- ? {
53- disabled : true ,
54- title : localize ( 'VOTE_COMPLETE_ALT' )
55- }
56- : undefined ,
57- [ actions , localize ]
36+ // TODO: We should update this to use W3C Hydra.1
37+ postActivityRef . current ( {
38+ entities : [ selectedAction ] ,
39+ name : 'webchat:activity-status/feedback' ,
40+ type : 'event'
41+ } as any ) ,
42+ DEBOUNCE_TIMEOUT
5843 ) ;
5944
60- return (
61- < Fragment >
62- { [ ...actions ] . map ( ( action , index ) => (
63- < FeedbackVoteButton
64- action = { action }
65- className = { className }
66- key = { action [ '@id' ] || index }
67- onClick = { onHandleFeedbackActionClick }
68- pressed = {
69- selectedAction === action ||
70- action . actionStatus === 'CompletedActionStatus' ||
71- action . actionStatus === 'ActiveActionStatus'
72- }
73- { ...actionProps }
74- />
75- ) ) }
76- </ Fragment >
77- ) ;
78- }
79- ) ;
45+ return ( ) => clearTimeout ( timeout ) ;
46+ } , [ clearTimeout , isFeedbackFormSupported , postActivityRef , selectedAction , setTimeout ] ) ;
47+
48+ const actionProps = useMemo (
49+ ( ) =>
50+ [ ...actions ] . some ( action => action . actionStatus === 'CompletedActionStatus' )
51+ ? {
52+ disabled : true ,
53+ title : localize ( 'VOTE_COMPLETE_ALT' )
54+ }
55+ : undefined ,
56+ [ actions , localize ]
57+ ) ;
58+
59+ return (
60+ < Fragment >
61+ { [ ...actions ] . map ( ( action , index ) => (
62+ < FeedbackVoteButton
63+ action = { action }
64+ className = { className }
65+ key = { action [ '@id' ] || index }
66+ onClick = { onActionClick }
67+ pressed = {
68+ selectedAction === action ||
69+ action . actionStatus === 'CompletedActionStatus' ||
70+ action . actionStatus === 'ActiveActionStatus'
71+ }
72+ { ...actionProps }
73+ />
74+ ) ) }
75+ </ Fragment >
76+ ) ;
77+ } ) ;
8078
8179Feedback . displayName = 'ActivityStatusFeedback' ;
8280
0 commit comments