@@ -13,12 +13,15 @@ const JarvisScreen = () => {
13
13
const meetingIdRef = useRef < number | null > ( null ) ;
14
14
const [ repText , setRepText ] = useState < string > ( "" ) ;
15
15
const timerRef = useRef < NodeJS . Timeout | null > ( null ) ;
16
- const [ endMeetingResponseType , setEndMeetingResponseType ] =
17
- useState < string > ( ) ;
16
+ const [ endMeetingAction , setEndMeetingAction ] = useState < string > ( ) ;
18
17
const [ asanaTask , setAsanaTask ] = useState < string [ ] > ( ) ;
19
18
const [ slackSummary , setSummarySlack ] = useState < string > ( ) ;
20
- const [ apiCallingStart , setAPICallingStart ] = useState < boolean > ( false ) ;
21
- const [ selectedTasks , setSelectedTasks ] = useState < string [ ] > ( [ ] ) ;
19
+ const [ isEndMettingAPICall , setIsEndMeetingAPICall ] =
20
+ useState < boolean > ( false ) ;
21
+ const [ asanaCreateAPICalling , setAsanaCreateAPICalling ] =
22
+ useState < boolean > ( false ) ;
23
+ const [ slackTaskCreateAPICalling , setSlackTaskCreateAPICalling ] =
24
+ useState < boolean > ( false ) ;
22
25
const [ loading , setLoading ] = useState < boolean > ( false ) ;
23
26
24
27
useEffect ( ( ) => {
@@ -29,7 +32,9 @@ const JarvisScreen = () => {
29
32
case "REP_TRANSCRIPT" :
30
33
{
31
34
const { message_text } = request . message . data ;
32
- setRepText ( ( m ) => m + message_text ) ;
35
+ if ( ! isEndMettingAPICall || ! asanaCreateAPICalling ) {
36
+ setRepText ( ( m ) => m + message_text ) ;
37
+ }
33
38
const message : Message = {
34
39
speaker_type : SpeakerType . REP ,
35
40
message_text,
@@ -43,38 +48,38 @@ const JarvisScreen = () => {
43
48
} , [ ] ) ;
44
49
45
50
useEffect ( ( ) => {
46
- // Start or reset the timer when repText changes
47
51
if ( repText . length ) {
48
- if ( timerRef . current ) clearTimeout ( timerRef . current ) ; // Reset the timer if already set
52
+ if ( timerRef . current ) clearTimeout ( timerRef . current ) ;
49
53
timerRef . current = setTimeout ( ( ) => {
50
- // Call the API after 4 seconds if repText hasn't changed
51
- setAPICallingStart ( true ) ;
52
- console . log ( "API call after 4 seconds" ) ;
54
+ if ( ! endMeetingAction ) {
55
+ setIsEndMeetingAPICall ( true ) ;
56
+ } else if ( endMeetingAction === "create_asana_tasks" ) {
57
+ setAsanaCreateAPICalling ( true ) ;
58
+ } else if ( endMeetingAction === "send_summary_to_slack" ) {
59
+ setSlackTaskCreateAPICalling ( true ) ;
60
+ }
53
61
} , 4000 ) ;
54
62
}
55
63
} , [ repText ] ) ;
56
64
57
65
useEffect ( ( ) => {
58
- if ( apiCallingStart && ! endMeetingResponseType ) {
66
+ if ( isEndMettingAPICall && ! endMeetingAction ) {
59
67
handleRecordingStart ( ) . then ( ( ) => {
60
- sendTranscriptToBackend ( meetingIdRef . current ) ;
68
+ sendEndMeetingTranscript ( meetingIdRef . current ) ;
61
69
} ) ;
62
- } else if (
63
- apiCallingStart &&
64
- endMeetingResponseType === "create_asana_tasks"
65
- ) {
70
+ } else if ( isEndMettingAPICall && asanaCreateAPICalling ) {
66
71
handleCreateAsanaTask ( ) . then ( ( ) => {
67
72
console . log ( "asana task created successfully" ) ;
68
73
} ) ;
69
74
}
70
- } , [ apiCallingStart , endMeetingResponseType ] ) ;
75
+ } , [ isEndMettingAPICall , asanaCreateAPICalling ] ) ;
71
76
72
77
async function handleRecordingStart ( ) {
73
78
const { id } = await addAndGetMeetingInfo ( ) ;
74
79
meetingIdRef . current = id ;
75
80
}
76
81
77
- async function sendTranscriptToBackend ( meeting_id : number ) {
82
+ async function sendEndMeetingTranscript ( meeting_id : number ) {
78
83
try {
79
84
if ( ! meeting_id ) throw new Error ( "meetingId required" ) ;
80
85
@@ -99,10 +104,10 @@ const JarvisScreen = () => {
99
104
const { data, type } = response . data ;
100
105
101
106
if ( type === "create_asana_tasks" && data ) {
102
- setEndMeetingResponseType ( type ) ;
107
+ setEndMeetingAction ( type ) ;
103
108
setAsanaTask ( data ) ;
104
109
} else if ( type === "send_summary_to_slack" ) {
105
- setEndMeetingResponseType ( type ) ;
110
+ setEndMeetingAction ( type ) ;
106
111
setSummarySlack ( data ) ;
107
112
}
108
113
} catch ( error ) {
@@ -113,14 +118,6 @@ const JarvisScreen = () => {
113
118
}
114
119
}
115
120
116
- const handleCheckboxChange = ( task : string ) => {
117
- setSelectedTasks ( ( prevSelectedTasks ) =>
118
- prevSelectedTasks . includes ( task )
119
- ? prevSelectedTasks . filter ( ( t ) => t !== task )
120
- : [ ...prevSelectedTasks , task ]
121
- ) ;
122
- } ;
123
-
124
121
const handleCreateAsanaTask = async ( ) => {
125
122
try {
126
123
if ( ! meetingIdRef . current ) throw new Error ( "meetingId required" ) ;
@@ -153,7 +150,7 @@ const JarvisScreen = () => {
153
150
} catch ( error ) {
154
151
toast . error ( "Failed" ) ;
155
152
console . error ( "Error Failed Create Asana API" , error ) ;
156
- }
153
+ }
157
154
} ;
158
155
159
156
const handleSendSlackSummary = async ( ) => {
@@ -167,7 +164,6 @@ const JarvisScreen = () => {
167
164
}
168
165
const postData = {
169
166
meetingId : meetingIdRef . current ,
170
- transcription : selectedTasks ,
171
167
} ;
172
168
173
169
// Make the POST request using Axios
@@ -206,40 +202,24 @@ const JarvisScreen = () => {
206
202
</ h2 >
207
203
{ ! ! repText . length && < span className = "text-lg" > { repText } </ span > }
208
204
< div className = "flex flex-col gap-1 ml-2 mt-2" >
209
- { endMeetingResponseType === "create_asana_tasks" &&
205
+ { endMeetingAction === "create_asana_tasks" &&
210
206
asanaTask &&
211
207
asanaTask . map ( ( task , index ) => (
212
208
< div className = "flex gap-2 p-1" key = { index } >
213
- { /* <input
214
- type="checkbox"
215
- value={task}
216
- checked={selectedTasks.includes(task)}
217
- onChange={() => handleCheckboxChange(task)}
218
- className="text-black rounded"
219
- /> */ }
220
209
< span > { index + 1 } </ span >
221
210
< p className = "text-sm text-start font-medium text-gray-900" >
222
211
{ task }
223
212
</ p >
224
213
</ div >
225
214
) ) }
226
- { /* {endMeetingResponseType === "create_asana_tasks" && (
227
- <button
228
- onClick={handleCreateAsanaTask}
229
- className="m-2 px-2 py-2 flex justify-center bg-blue-600 text-white rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
230
- >
231
- {loading ? <Loader /> : "Create Asana Task"}
232
- </button>
233
- )} */ }
234
215
</ div >
235
216
< div className = "flex flex-col gap-1 ml-2 mt-2" >
236
- { endMeetingResponseType === "send_summary_to_slack" &&
237
- slackSummary && (
238
- < p className = "text-sm text-start font-medium text-gray-900" >
239
- { slackSummary }
240
- </ p >
241
- ) }
242
- { endMeetingResponseType === "send_summary_to_slack" && (
217
+ { endMeetingAction === "send_summary_to_slack" && slackSummary && (
218
+ < p className = "text-sm text-start font-medium text-gray-900" >
219
+ { slackSummary }
220
+ </ p >
221
+ ) }
222
+ { endMeetingAction === "send_summary_to_slack" && (
243
223
< button
244
224
onClick = { handleSendSlackSummary }
245
225
className = "m-2 px-2 py-2 flex justify-center bg-blue-600 text-white rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
0 commit comments