@@ -12,6 +12,7 @@ import statementsCategories from '../../../data/statementsCategories.json';
1212import { formatCategoryName } from '../../../lib/utils' ;
1313import { updateEntry } from '../../api/entriesApi' ;
1414import { EditStatementModal } from '../statementWizard/EditStatementModal' ;
15+ import { BellOff , ChevronUp , ChevronDown } from 'lucide-react' ;
1516
1617const groupQuestionsByCategory = ( questions : SetQuestion [ ] ) => {
1718 return questions . reduce < Record < string , SetQuestion [ ] > > ( ( acc , question ) => {
@@ -36,9 +37,11 @@ const StatementList: React.FC<{ username: string }> = ({ username }) => {
3637 const { entries } = data ;
3738
3839 const [ usedPresetQuestions , setUsedPresetQuestions ] = useState < string [ ] > ( [ ] ) ;
39- const { questions } = useQuestions ( ) ;
40+ const { questions, setQuestions } = useQuestions ( ) ;
41+
42+ // Get available preset questions (not used and not in snoozed section)
4043 const presetQuestions = questions . filter (
41- ( q ) => ! usedPresetQuestions . includes ( q . id )
44+ ( q ) => ! usedPresetQuestions . includes ( q . id ) && ! q . isSnoozed
4245 ) ;
4346
4447 const questionsByCategory = groupQuestionsByCategory ( presetQuestions ) ;
@@ -66,13 +69,48 @@ const StatementList: React.FC<{ username: string }> = ({ username }) => {
6669 // Keep a backup of the original entries when entering edit mode
6770 const [ originalEntries , setOriginalEntries ] = useState < { [ id : string ] : Entry } > ( { } ) ;
6871
72+ // Handle toggling the resolved state (archive/unarchive)
6973 const handleToggleResolved = ( statementId : string ) => {
7074 const stmt = entries . find ( ( s ) => s . id === statementId ) ;
7175 if ( ! stmt ) return ;
7276 const updated = { ...stmt , isResolved : ! stmt . isResolved } ;
7377 setData ( { type : 'UPDATE_ENTRY' , payload : updated } ) ;
7478 updateEntry ( updated ) ;
7579 } ;
80+
81+
82+ // Handle toggling the snoozed state for questions
83+ const handleToggleQuestionSnooze = ( questionId : string ) => {
84+ // Find the question in the questions array
85+ const questionToToggle = questions . find ( q => q . id === questionId ) ;
86+ if ( ! questionToToggle ) return ;
87+
88+ // Create a new array with the updated question
89+ const updatedQuestions = questions . map ( q => {
90+ if ( q . id === questionId ) {
91+ if ( q . isSnoozed ) {
92+ // Unsnooze - restore to original category if available
93+ return {
94+ ...q ,
95+ isSnoozed : false ,
96+ category : q . originalCategory || q . category
97+ } ;
98+ } else {
99+ // Snooze - store original category and move to snoozed
100+ return {
101+ ...q ,
102+ isSnoozed : true ,
103+ originalCategory : q . category ,
104+ category : 'snoozed'
105+ } ;
106+ }
107+ }
108+ return q ;
109+ } ) ;
110+
111+ // Update the questions in context
112+ setQuestions ( updatedQuestions ) ;
113+ } ;
76114
77115 const handleToggleActionResolved = (
78116 statementId : string ,
@@ -254,10 +292,17 @@ const StatementList: React.FC<{ username: string }> = ({ username }) => {
254292 updateEntry ( updatedStatement ) ;
255293 } ;
256294
295+ // State for managing the visibility of the snoozed section
296+ const [ isSnoozedQuestionsSectionExpanded , setIsSnoozedQuestionsSectionExpanded ] = useState ( false ) ;
297+
257298 const renderCategorySection = ( catId : string , catLabel : string ) => {
299+ // Don't render the snoozed category in the normal flow
300+ if ( catId === 'snoozed' ) return null ;
301+
258302 const presetForCat = questionsByCategory [ catId ] || [ ] ;
259303 const statementsForCat = statementsByCategory [ catId ] || [ ] ;
260304 if ( presetForCat . length === 0 && statementsForCat . length === 0 ) return null ;
305+
261306 return (
262307 < div key = { catId } className = 'mb-8' >
263308 < h3 className = 'text-lg font-semibold mb-2' >
@@ -270,6 +315,7 @@ const StatementList: React.FC<{ username: string }> = ({ username }) => {
270315 < QuestionCard
271316 presetQuestion = { presetQuestion }
272317 onSelect = { handlePresetQuestionSelect }
318+ onToggleSnooze = { handleToggleQuestionSnooze }
273319 />
274320 </ li >
275321 ) ) }
@@ -327,6 +373,49 @@ const StatementList: React.FC<{ username: string }> = ({ username }) => {
327373 </ div >
328374 ) ;
329375 } ;
376+
377+
378+ // Special renderer for the snoozed questions section
379+ const renderSnoozedQuestionsSection = ( ) => {
380+ // Filter questions to get snoozed ones
381+ const snoozedQuestions = questions . filter ( q => q . isSnoozed ) ;
382+ if ( snoozedQuestions . length === 0 ) return null ;
383+
384+ return (
385+ < div className = 'mb-8 mt-4 border-t pt-4' >
386+ < div
387+ className = 'flex items-center justify-between cursor-pointer py-2 px-3 bg-blue-50 rounded-md mb-2'
388+ onClick = { ( ) => setIsSnoozedQuestionsSectionExpanded ( ! isSnoozedQuestionsSectionExpanded ) }
389+ >
390+ < h3 className = 'text-lg font-semibold flex items-center text-blue-700' >
391+ < BellOff className = 'h-5 w-5 mr-2' />
392+ Snoozed Questions ({ snoozedQuestions . length } )
393+ </ h3 >
394+ < div className = 'text-blue-600' >
395+ { isSnoozedQuestionsSectionExpanded ? (
396+ < ChevronUp className = 'h-5 w-5' />
397+ ) : (
398+ < ChevronDown className = 'h-5 w-5' />
399+ ) }
400+ </ div >
401+ </ div >
402+
403+ { isSnoozedQuestionsSectionExpanded && (
404+ < ul className = 'space-y-2 mt-4 pl-4 border-l-2 border-blue-100' >
405+ { snoozedQuestions . map ( ( question ) => (
406+ < li key = { `snoozed-${ question . id } ` } >
407+ < QuestionCard
408+ presetQuestion = { question }
409+ onSelect = { ( ) => { /* Disabled for snoozed questions */ } }
410+ onToggleSnooze = { handleToggleQuestionSnooze }
411+ />
412+ </ li >
413+ ) ) }
414+ </ ul >
415+ ) }
416+ </ div >
417+ ) ;
418+ } ;
330419
331420 const definedCategories = categoriesList ;
332421 const definedCategoryIds = definedCategories . map ( ( c ) => c . id ) ;
@@ -340,10 +429,15 @@ const StatementList: React.FC<{ username: string }> = ({ username }) => {
340429 return (
341430 < >
342431 < div className = 'mt-8 bg-white rounded-xl shadow-lg p-6 w-full' >
432+ { /* Regular categories */ }
343433 { definedCategories . map ( ( cat ) =>
344434 renderCategorySection ( cat . id , cat . name )
345435 ) }
346436 { extraCategoryIds . map ( ( catId ) => renderCategorySection ( catId , catId ) ) }
437+
438+ { /* Snoozed sections */ }
439+ { renderSnoozedQuestionsSection ( ) }
440+
347441 < ConfirmationDialog
348442 isOpen = { deleteConfirmation . isOpen }
349443 onClose = { handleDeleteCancel }
0 commit comments