@@ -36,12 +36,13 @@ const SubmitMeetingSummary: NextPage = () => {
3636 const [ isLoading , setIsLoading ] = useState ( false ) ;
3737 const [ names , setNames ] = useState < Names [ ] > ( [ ] )
3838 const [ tags , setTags ] = useState ( { } )
39+ const [ summaryStatus , setSummaryStatus ] = useState ( 'populatedSummary' ) ;
3940
4041 async function getWorkgroupList ( ) {
4142 setIsLoading ( true ) ;
4243 const workgroupList : any = await getWorkgroups ( ) ;
43- const names1 = await getNames ( ) ;
44- const tags1 = await getTags ( ) ;
44+ const names1 = await getNames ( ) ;
45+ const tags1 = await getTags ( ) ;
4546
4647 let newNames = names1 . map ( ( value ) => ( { value : value . name , label : value . name } ) ) ;
4748
@@ -60,11 +61,11 @@ const SubmitMeetingSummary: NextPage = () => {
6061 let referenceTags = tags1
6162 . filter ( tag => tag . type === 'references' )
6263 . map ( tag => ( { value : tag . tag , label : tag . tag } ) ) ;
63-
64+
6465 let gamesPlayedTags = tags1
6566 . filter ( tag => tag . type === 'gamesPlayed' )
6667 . map ( tag => ( { value : tag . tag , label : tag . tag } ) ) ;
67-
68+
6869 setWorkgroups ( workgroupList ) ;
6970 setNames ( newNames ) ;
7071 setTags ( { other : otherTags , emotions : emotionTags , topicsCovered : topicTags , references : referenceTags , gamesPlayed : gamesPlayedTags } ) ;
@@ -87,28 +88,28 @@ const SubmitMeetingSummary: NextPage = () => {
8788 "Deep Funding Town Hall" : [ "townHallSummary" ] ,
8889 "One-off Event" : [ "Narative" ]
8990 } ;
90-
91- useEffect ( ( ) => {
92- async function fetchInitialData ( workgroupId : string ) {
93- setIsLoading ( true ) ;
94- const summaries : any = await getSummaries ( workgroupId ) ;
95- setMeetings ( summaries )
96- if ( summaries && summaries [ 0 ] ?. type ) {
97- setActiveComponent ( 'two' ) ;
98- }
91+
92+ useEffect ( ( ) => {
93+ async function fetchInitialData ( workgroupId : string ) {
94+ setIsLoading ( true ) ;
95+ const summaries : any = await getSummaries ( workgroupId ) ;
96+ setMeetings ( summaries )
97+ if ( summaries && summaries [ 0 ] ?. type ) {
98+ setActiveComponent ( 'two' ) ;
99+ }
99100 setShowNewWorkgroupInput ( false ) ;
100- setSelectedWorkgroupId ( workgroupId ) ;
101+ setSelectedWorkgroupId ( workgroupId ) ;
101102 const selectedWorkgroup = workgroups . find ( workgroup => workgroup . workgroup_id === workgroupId ) ;
102103 if ( selectedWorkgroup ) {
103- setMyVariable ( { ...myVariable , workgroup : selectedWorkgroup , summaries, summary : summaries [ 0 ] , names, tags, agendaItemOrder : orderMapping } ) ;
104+ setMyVariable ( { ...myVariable , workgroup : selectedWorkgroup , summaries, summary : summaries [ 0 ] , names, tags, agendaItemOrder : orderMapping } ) ;
104105 }
105106 setIsLoading ( false ) ;
106- }
107+ }
107108
108- if ( router . query . workgroup && workgroups . length > 0 ) {
109- fetchInitialData ( router . query . workgroup as string ) ;
110- }
111- } , [ router . query , workgroups ] ) ;
109+ if ( router . query . workgroup && workgroups . length > 0 ) {
110+ fetchInitialData ( router . query . workgroup as string ) ;
111+ }
112+ } , [ router . query , workgroups ] ) ;
112113
113114 useEffect ( ( ) => {
114115 getWorkgroupList ( ) ;
@@ -127,7 +128,7 @@ useEffect(() => {
127128 setShowNewWorkgroupInput ( true ) ;
128129 } else {
129130 setShowNewWorkgroupInput ( false ) ;
130- setSelectedWorkgroupId ( selectedWorkgroupId ) ;
131+ setSelectedWorkgroupId ( selectedWorkgroupId ) ;
131132 const selectedWorkgroup = workgroups . find ( workgroup => workgroup . workgroup_id === selectedWorkgroupId ) ;
132133 if ( selectedWorkgroup ) {
133134 setMyVariable ( { ...myVariable , workgroup : selectedWorkgroup , summaries, summary : summaries [ 0 ] , names, tags } ) ;
@@ -137,14 +138,14 @@ useEffect(() => {
137138 router . push ( `/submit-meeting-summary?workgroup=${ selectedWorkgroupId } ` , undefined , { shallow : true } ) ;
138139 }
139140 //console.log("myVariable", myVariable );
140- }
141+ }
141142 async function handleSelectChange2 ( e : any ) {
142143 const newSelectedMeetingId = e . target . value ;
143144 setSelectedMeetingId ( newSelectedMeetingId ) ; // Correctly set the selectedMeetingId
144145
145146 // Find the selected summary using the new selectedMeetingId
146147 const selectedSummary = meetings . find ( ( meeting : any ) => meeting . meeting_id === newSelectedMeetingId ) ;
147-
148+
148149 // If there's a selected summary, update the myVariable state with that summary
149150 if ( selectedSummary ) {
150151 setMyVariable ( prevMyVariable => ( {
@@ -176,37 +177,37 @@ useEffect(() => {
176177 setShowNewWorkgroupInput ( false ) ;
177178 }
178179 setIsLoading ( false ) ;
179- } ;
180+ } ;
180181
181182 const getComponent = ( ) => {
182183 switch ( activeComponent ) {
183184 case 'two' : return < SummaryTemplate key = { selectedWorkgroupId } updateMeetings = { updateMeetings } /> ;
184185 case 'four' : return < ArchiveSummaries key = { selectedWorkgroupId } /> ;
185186 default : return < div > Select a component</ div > ;
186187 }
187- }
188+ }
188189
189190 function formatDate ( isoString : any ) {
190191 const months = [
191192 'January' , 'February' , 'March' , 'April' , 'May' , 'June' ,
192193 'July' , 'August' , 'September' , 'October' , 'November' , 'December'
193194 ] ;
194-
195+
195196 const date = new Date ( isoString ) ;
196197 const day = date . getDate ( ) ;
197198 const monthIndex = date . getMonth ( ) ;
198199 const year = date . getFullYear ( ) ;
199-
200+
200201 return `${ day } ${ months [ monthIndex ] } ${ year } ` ;
201202 }
202-
203+
203204 const updateMeetings = ( newMeetingSummary : any ) => {
204205 //console.log("Before update, meetings:", meetings, newMeetingSummary); // Log the current state before update
205-
206+
206207 setMeetings ( prevMeetings => {
207208 let updatedMeetings : any = [ ...prevMeetings ] ;
208209 const meetingIndex : any = updatedMeetings . findIndex ( ( meeting : any ) => meeting . meeting_id === newMeetingSummary . meeting_id ) ;
209-
210+
210211 if ( meetingIndex !== - 1 ) {
211212 // Replace existing summary
212213 updatedMeetings [ meetingIndex ] = newMeetingSummary ;
@@ -220,36 +221,64 @@ useEffect(() => {
220221 return updatedMeetings ;
221222 } ) ;
222223 } ;
223-
224+
224225 const resetSummary = ( ) => {
225226 setMyVariable ( prevMyVariable => ( {
226- ...prevMyVariable ,
227+ ...prevMyVariable ,
227228 summary : {
228- ...prevMyVariable . summary ,
229- meetingInfo : { } ,
229+ ...prevMyVariable . summary ,
230+ meetingInfo : { } ,
230231 agendaItems : [ ] ,
231- tags : { }
232+ tags : { }
232233 }
233234 } ) ) ;
234- } ;
235+ } ;
235236
236237 const noSummaryGiven = ( ) => {
237238 setMyVariable ( prevMyVariable => ( {
238- ...prevMyVariable ,
239+ ...prevMyVariable ,
239240 summary : {
240- ...prevMyVariable . summary ,
241- meetingInfo : { } ,
241+ ...prevMyVariable . summary ,
242+ meetingInfo : { } ,
242243 agendaItems : [ ] ,
243244 tags : { } ,
244- noSummaryGiven : true
245+ noSummaryGiven : true ,
246+ canceledSummary : false
245247 }
246248 } ) ) ;
247- } ;
249+ } ;
250+
251+ const handleSummaryStatusChange = ( e : any ) => {
252+ const newStatus = e . target . value ;
253+ setSummaryStatus ( newStatus ) ;
254+
255+ // Update myVariable state based on the selection
256+ if ( newStatus === 'noSummaryGiven' ) {
257+ noSummaryGiven ( ) ; // Your existing function to handle no summary
258+ } else if ( newStatus === 'canceledSummary' ) {
259+ // Implement logic for canceled summary
260+ setMyVariable ( prevMyVariable => ( {
261+ ...prevMyVariable ,
262+ summary : {
263+ ...prevMyVariable . summary ,
264+ meetingInfo : { } ,
265+ agendaItems : [ ] ,
266+ tags : { } ,
267+ noSummaryGiven : false ,
268+ canceledSummary : true
269+ }
270+ } ) ) ;
271+ } else {
272+ // Reset to populated summary (default state or any specific logic)
273+ console . log ( "Populated Summary" ) ;
274+ }
275+ } ;
276+
248277
249278 return (
250279 < div className = { styles . container } >
251280 < div className = { styles . navbar } >
252- { isLoading ? (
281+ { isLoading ? (
253282 < p > Loading...</ p >
254283 ) : (
255284 < >
@@ -258,8 +287,8 @@ useEffect(() => {
258287 < div className = { styles [ 'column-flex' ] } >
259288 < label className = { styles [ 'form-label' ] } htmlFor = "" > Select Workgroup</ label >
260289 < select
261- name = "" id = ""
262- className = { `${ styles . select } ${ selectedWorkgroupId === '' ? styles . selectGreen : '' } ` }
290+ name = "" id = ""
291+ className = { `${ styles . select } ${ selectedWorkgroupId === '' ? styles . selectGreen : '' } ` }
263292 value = { selectedWorkgroupId } onChange = { handleSelectChange }
264293 title = "Select a workgroup" >
265294 < option value = "" disabled > Please select Workgroup</ option >
@@ -273,23 +302,23 @@ useEffect(() => {
273302 ) }
274303 { workgroups . length > 0 && meetings ?. length > 0 && (
275304 < >
276- < div className = { styles [ 'column-flex' ] } >
277- < label className = { styles [ 'form-label' ] } htmlFor = "" > Select previous meeting data</ label >
278- < select
279- name = "" id = ""
280- className = { styles . select }
281- value = { selectedMeetingId } onChange = { handleSelectChange2 }
282- title = "Defaults to latest meeting, only change this when you want to use a previous meeting as template" >
283- { meetings . map ( ( meeting : any ) => (
284- < option
285- style = { { color : meeting . confirmed ? 'lightgreen' : 'white' } }
286- key = { `${ meeting . meeting_id } -${ meeting . updated_at } ` }
287- value = { meeting . meeting_id } >
305+ < div className = { styles [ 'column-flex' ] } >
306+ < label className = { styles [ 'form-label' ] } htmlFor = "" > Select previous meeting data</ label >
307+ < select
308+ name = "" id = ""
309+ className = { styles . select }
310+ value = { selectedMeetingId } onChange = { handleSelectChange2 }
311+ title = "Defaults to latest meeting, only change this when you want to use a previous meeting as template" >
312+ { meetings . map ( ( meeting : any ) => (
313+ < option
314+ style = { { color : meeting . confirmed ? 'lightgreen' : 'white' } }
315+ key = { `${ meeting . meeting_id } -${ meeting . updated_at } ` }
316+ value = { meeting . meeting_id } >
288317 { formatDate ( meeting . date ) } { meeting . username } { meeting . confirmed ? 'Archived' : '' }
289- </ option >
290- ) ) }
291- </ select >
292- </ div >
318+ </ option >
319+ ) ) }
320+ </ select >
321+ </ div >
293322 </ >
294323 ) }
295324 { showNewWorkgroupInput && (
@@ -300,24 +329,28 @@ useEffect(() => {
300329 ) }
301330 </ >
302331 ) }
303- { selectedWorkgroupId && ( < >
304- { myVariable . roles ?. isAdmin && ( < button className = { styles . navButton } onClick = { ( ) => setActiveComponent ( 'two' ) } > Summary</ button > ) }
305- { myVariable . roles ?. isAdmin && < button className = { styles . navButton } onClick = { ( ) => setActiveComponent ( 'four' ) } > Archive Summaries</ button > }
306- < button
307- className = { styles . resetButton }
308- onClick = { resetSummary }
309- title = "All values will be cleared, so please make sure to select all dropdowns and fill in all fields"
332+ { selectedWorkgroupId && ( < >
333+ { myVariable . roles ?. isAdmin && ( < button className = { styles . navButton } onClick = { ( ) => setActiveComponent ( 'two' ) } > Summary</ button > ) }
334+ { myVariable . roles ?. isAdmin && < button className = { styles . navButton } onClick = { ( ) => setActiveComponent ( 'four' ) } > Archive Summaries</ button > }
335+ < button
336+ className = { styles . resetButton }
337+ onClick = { resetSummary }
338+ title = "All values will be cleared, so please make sure to select all dropdowns and fill in all fields"
310339 > Clear Summary
311340 </ button >
312- { myVariable . roles ?. isAdmin && activeComponent == 'four' && ( < button
313- className = { styles . resetButton }
314- onClick = { noSummaryGiven }
315- title = "All values will be cleared, and markdown changed to 'No Sammary given'"
316- > No Summary Given
317- </ button > ) }
341+ { myVariable . roles ?. isAdmin && activeComponent == 'four' && (
342+ < select
343+ className = { styles . select }
344+ value = { summaryStatus }
345+ onChange = { handleSummaryStatusChange } >
346+ < option value = "populatedSummary" selected > Populated Summary</ option >
347+ < option value = "noSummaryGiven" > No Summary Given</ option >
348+ < option value = "canceledSummary" > Canceled Summary</ option >
349+ </ select >
350+ ) }
318351 </ > ) }
319352 </ div >
320- { myVariable . isLoggedIn && selectedWorkgroupId && ( < div className = { styles . mainContent } >
353+ { myVariable . isLoggedIn && selectedWorkgroupId && ( < div className = { styles . mainContent } >
321354 { getComponent ( ) }
322355 </ div > ) }
323356 { myVariable . isLoggedIn && ! selectedWorkgroupId && ! isLoading && ( < div className = { styles . nomainContent } >
0 commit comments