@@ -38,6 +38,7 @@ export default function AskPage() {
3838 const [ hasInitialLoaded , setHasInitialLoaded ] = useState ( false ) ;
3939 const [ followUpText , setFollowUpText ] = useState < { [ key : string ] : string } > ( { } ) ;
4040 const [ isFollowUpSubmitting , setIsFollowUpSubmitting ] = useState < { [ key : string ] : boolean } > ( { } ) ;
41+ const [ followUpSuccess , setFollowUpSuccess ] = useState < { [ key : string ] : boolean } > ( { } ) ;
4142
4243 useEffect ( ( ) => {
4344 if ( isLoaded && isSignedIn ) {
@@ -94,12 +95,11 @@ export default function AskPage() {
9495 setNewTicketSubject ( '' ) ;
9596 setNewTicketMessage ( '' ) ;
9697 fetchTickets ( ) ;
97- setNotification ( { message : "Guidance Request Submitted!" , type : 'success' } ) ;
9898 setIsSuccess ( true ) ;
9999 setTimeout ( ( ) => {
100100 setIsSuccess ( false ) ;
101101 setIsNewQuestionExpanded ( false ) ;
102- } , 3000 ) ;
102+ } , 4000 ) ;
103103 } else {
104104 setNotification ( { message : "Error: " + result . error , type : 'error' } ) ;
105105 }
@@ -119,8 +119,11 @@ export default function AskPage() {
119119 const result = await userReplyToTicket ( ticketId , text ) ;
120120 if ( result . success ) {
121121 setFollowUpText ( prev => ( { ...prev , [ ticketId ] : '' } ) ) ;
122+ setFollowUpSuccess ( prev => ( { ...prev , [ ticketId ] : true } ) ) ;
122123 fetchTickets ( ) ;
123- setNotification ( { message : "Follow-up sent!" , type : 'success' } ) ;
124+ setTimeout ( ( ) => {
125+ setFollowUpSuccess ( prev => ( { ...prev , [ ticketId ] : false } ) ) ;
126+ } , 4000 ) ;
124127 } else {
125128 setNotification ( { message : "Error: " + result . error , type : 'error' } ) ;
126129 }
@@ -233,7 +236,7 @@ export default function AskPage() {
233236 rows = { 5 }
234237 value = { newTicketMessage }
235238 onChange = { ( e ) => setNewTicketMessage ( e . target . value ) }
236- placeholder = "Describe your query or spiritual challenge in detail..."
239+ placeholder = "Please share your spiritual question or request for guidance in detail..."
237240 className = "w-full bg-gray-50 border border-gray-100 rounded-2xl p-4 focus:ring-4 focus:ring-ochre/10 focus:border-ochre outline-none transition-all text-sm leading-relaxed resize-none font-medium"
238241 />
239242 </ div >
@@ -282,33 +285,45 @@ export default function AskPage() {
282285
283286 { isNewQuestionExpanded && (
284287 < div className = "p-4 border-t border-gray-50 bg-gray-50/30 animate-in slide-in-from-top-2 duration-300" >
285- < form onSubmit = { handleSubmit } className = "space-y-4" >
286- < input
287- type = "text"
288- required
289- value = { newTicketSubject }
290- onChange = { ( e ) => setNewTicketSubject ( e . target . value ) }
291- placeholder = "Inquiry Topic..."
292- className = "w-full bg-white border border-gray-100 rounded-xl px-3 py-2 text-sm focus:ring-2 focus:ring-ochre/20 focus:border-ochre outline-none font-medium"
293- />
294- < textarea
295- required
296- rows = { 3 }
297- value = { newTicketMessage }
298- onChange = { ( e ) => setNewTicketMessage ( e . target . value ) }
299- placeholder = "Briefly describe your request..."
300- className = "w-full bg-white border border-gray-100 rounded-xl px-3 py-2 text-sm focus:ring-2 focus:ring-ochre/20 focus:border-ochre outline-none resize-none font-medium"
301- />
302- < div className = "flex justify-end" >
303- < button
304- type = "submit"
305- disabled = { isSubmitting }
306- className = "bg-ochre text-white px-5 py-2 rounded-xl text-xs font-black uppercase tracking-widest hover:bg-gold transition-all disabled:opacity-50 flex items-center shadow-lg shadow-ochre/20"
307- >
308- { isSubmitting ? < Loader2 className = "w-3 h-3 mr-2 animate-spin" /> : 'Submit Inquiry' }
309- </ button >
288+ { isSuccess ? (
289+ < div className = "flex items-center space-x-4 py-8 px-4 bg-white rounded-2xl shadow-sm border border-green-50 animate-in zoom-in duration-500" >
290+ < div className = "w-12 h-12 bg-green-50 rounded-full flex items-center justify-center text-green-600 flex-none" >
291+ < CheckCircle2 className = "w-6 h-6" />
292+ </ div >
293+ < div >
294+ < h3 className = "font-bold text-gray-900 leading-tight" > Request Received</ h3 >
295+ < p className = "text-xs text-gray-500 mt-0.5" > Krishnaji will respond to your query soon.</ p >
296+ </ div >
310297 </ div >
311- </ form >
298+ ) : (
299+ < form onSubmit = { handleSubmit } className = "space-y-4" >
300+ < input
301+ type = "text"
302+ required
303+ value = { newTicketSubject }
304+ onChange = { ( e ) => setNewTicketSubject ( e . target . value ) }
305+ placeholder = "Topic of Spiritual Inquiry..."
306+ className = "w-full bg-white border border-gray-100 rounded-xl px-3 py-2 text-sm focus:ring-2 focus:ring-ochre/20 focus:border-ochre outline-none font-medium"
307+ />
308+ < textarea
309+ required
310+ rows = { 3 }
311+ value = { newTicketMessage }
312+ onChange = { ( e ) => setNewTicketMessage ( e . target . value ) }
313+ placeholder = "Please share your spiritual question or request for guidance here..."
314+ className = "w-full bg-white border border-gray-100 rounded-xl px-3 py-2 text-sm focus:ring-2 focus:ring-ochre/20 focus:border-ochre outline-none resize-none font-medium"
315+ />
316+ < div className = "flex justify-end" >
317+ < button
318+ type = "submit"
319+ disabled = { isSubmitting }
320+ className = "bg-ochre text-white px-5 py-2 rounded-xl text-xs font-black uppercase tracking-widest hover:bg-gold transition-all disabled:opacity-50 flex items-center shadow-lg shadow-ochre/20 active:scale-95"
321+ >
322+ { isSubmitting ? < Loader2 className = "w-3 h-3 mr-2 animate-spin" /> : 'Submit Inquiry' }
323+ </ button >
324+ </ div >
325+ </ form >
326+ ) }
312327 </ div >
313328 ) }
314329 </ div >
@@ -405,35 +420,42 @@ export default function AskPage() {
405420
406421 { ticket . status !== 'CLOSED' && (
407422 < div className = "space-y-4 pt-4 border-t border-gray-100 mt-4" >
408- < div className = "space-y-2" >
409- < label className = "text-[9px] font-black uppercase tracking-widest text-gray-400 ml-1" > Send Follow-up</ label >
410- < textarea
411- value = { followUpText [ ticket . id ] || '' }
412- onChange = { ( e ) => setFollowUpText ( prev => ( { ...prev , [ ticket . id ] : e . target . value } ) ) }
413- placeholder = "Type your clarifying question here..."
414- rows = { 3 }
415- className = "w-full bg-white border border-gray-100 rounded-2xl p-3 text-sm focus:ring-4 focus:ring-ochre/10 focus:border-ochre outline-none transition-all resize-none font-medium"
416- />
417- < div className = "flex justify-between items-center" >
418- < button
419- onClick = { ( e ) => {
420- e . stopPropagation ( ) ;
421- setTicketToClose ( ticket . id ) ;
422- } }
423- className = "text-[10px] font-black text-gray-400 uppercase tracking-widest hover:text-red-500 transition-colors"
424- >
425- Close Inquiry
426- </ button >
427- < button
428- onClick = { ( ) => handleFollowUp ( ticket . id ) }
429- disabled = { isFollowUpSubmitting [ ticket . id ] || ! followUpText [ ticket . id ] ?. trim ( ) }
430- className = "bg-ochre text-white px-6 py-2 rounded-xl text-xs font-black uppercase tracking-widest hover:bg-gold transition-all disabled:opacity-30 shadow-lg shadow-ochre/20 flex items-center"
431- >
432- { isFollowUpSubmitting [ ticket . id ] ? < Loader2 className = "w-3 h-3 mr-2 animate-spin" /> : < Send className = "w-3 h-3 mr-2" /> }
433- Send
434- </ button >
423+ { followUpSuccess [ ticket . id ] ? (
424+ < div className = "flex items-center space-x-3 py-3 px-4 bg-green-50/50 rounded-xl border border-green-100 animate-in fade-in zoom-in duration-300" >
425+ < CheckCircle2 className = "w-5 h-5 text-green-600" />
426+ < p className = "text-xs font-bold text-green-700 uppercase tracking-widest" > Guidance shared with Krishnaji</ p >
435427 </ div >
436- </ div >
428+ ) : (
429+ < div className = "space-y-2" >
430+ < label className = "text-[9px] font-black uppercase tracking-widest text-gray-400 ml-1" > Send Follow-up</ label >
431+ < textarea
432+ value = { followUpText [ ticket . id ] || '' }
433+ onChange = { ( e ) => setFollowUpText ( prev => ( { ...prev , [ ticket . id ] : e . target . value } ) ) }
434+ placeholder = "Type your clarifying question here..."
435+ rows = { 3 }
436+ className = "w-full bg-white border border-gray-100 rounded-2xl p-3 text-sm focus:ring-4 focus:ring-ochre/10 focus:border-ochre outline-none transition-all resize-none font-medium"
437+ />
438+ < div className = "flex justify-between items-center" >
439+ < button
440+ onClick = { ( e ) => {
441+ e . stopPropagation ( ) ;
442+ setTicketToClose ( ticket . id ) ;
443+ } }
444+ className = "text-[10px] font-black text-gray-400 uppercase tracking-widest hover:text-red-500 transition-colors"
445+ >
446+ Close Inquiry
447+ </ button >
448+ < button
449+ onClick = { ( ) => handleFollowUp ( ticket . id ) }
450+ disabled = { isFollowUpSubmitting [ ticket . id ] || ! followUpText [ ticket . id ] ?. trim ( ) }
451+ className = "bg-ochre text-white px-6 py-2 rounded-xl text-xs font-black uppercase tracking-widest hover:bg-gold transition-all disabled:opacity-30 shadow-lg shadow-ochre/20 flex items-center active:scale-95"
452+ >
453+ { isFollowUpSubmitting [ ticket . id ] ? < Loader2 className = "w-3 h-3 mr-2 animate-spin" /> : < Send className = "w-3 h-3 mr-2" /> }
454+ Send
455+ </ button >
456+ </ div >
457+ </ div >
458+ ) }
437459 </ div >
438460 ) }
439461 </ div >
0 commit comments