@@ -4,7 +4,11 @@ import Footer from './Footer';
44import Banner from './Banner/Banner' ;
55import GenericError , { SachKaur , BalpreetSingh } from './GenericError' ;
66import PropTypes from 'prop-types' ;
7- import { DEFAULT_PAGE_TITLE , LOCAL_STORAGE_KEY_FOR_SESSION_TOKEN , TEXTS } from '../constants' ;
7+ import {
8+ DEFAULT_PAGE_TITLE ,
9+ LOCAL_STORAGE_KEY_FOR_SESSION_TOKEN ,
10+ TEXTS ,
11+ } from '../constants' ;
812import { connect } from 'react-redux' ;
913import throttle from 'lodash.throttle' ;
1014import {
@@ -13,18 +17,29 @@ import {
1317 OFFLINE_COLOR ,
1418} from '../../../common/constants' ;
1519import { ACTIONS , errorEvent } from '../util/analytics' ;
16- import { setOnlineMode , closeSettingsPanel , toggleDarkMode } from '../features/actions' ;
20+ import {
21+ setOnlineMode ,
22+ closeSettingsPanel ,
23+ toggleDarkMode ,
24+ } from '../features/actions' ;
1725import { FloatingActions } from './FloatingActions' ;
1826import MultipleShabadsDisplay from './MultipleShabadsDisplay' ;
1927
20- import { addVisraamClass , isShowFullscreenRoute , isShowAutoScrollRoute , isShowSettingsRoute , getQueryParams , isFalsy } from '../util' ;
28+ import {
29+ addVisraamClass ,
30+ isShowFullscreenRoute ,
31+ isShowAutoScrollRoute ,
32+ isShowSettingsRoute ,
33+ getQueryParams ,
34+ isFalsy ,
35+ } from '../util' ;
2136import { AddFavouriteShabadModal } from './Modals' ;
2237import { SEARCH_TYPES } from '../constants' ;
2338
2439class Layout extends React . PureComponent {
2540 static defaultProps = {
2641 isHome : false ,
27- title : DEFAULT_PAGE_TITLE
42+ title : DEFAULT_PAGE_TITLE ,
2843 } ;
2944
3045 static propTypes = {
@@ -46,7 +61,7 @@ class Layout extends React.PureComponent {
4661 setOnlineMode : PropTypes . func . isRequired ,
4762 toggleDarkMode : PropTypes . func . isRequired ,
4863 closeSettingsPanel : PropTypes . func ,
49- history : PropTypes . object
64+ history : PropTypes . object ,
5065 } ;
5166
5267 state = {
@@ -99,7 +114,10 @@ class Layout extends React.PureComponent {
99114 } = this . props ;
100115
101116 const queryParams = getQueryParams ( this . props . location . search ) ;
102- const isShowAI = queryParams . type && parseInt ( queryParams . type , 10 ) === SEARCH_TYPES . ASK_A_QUESTION && pathname . includes ( '/shabad' ) ;
117+ const isShowAI =
118+ queryParams . type &&
119+ parseInt ( queryParams . type , 10 ) === SEARCH_TYPES . ASK_A_QUESTION &&
120+ pathname . includes ( '/shabad' ) ;
103121
104122 const isShowFullScreen = isShowFullscreenRoute ( pathname ) ;
105123 const isShowAutoScroll = isShowAutoScrollRoute ( pathname ) && autoScrollMode ;
@@ -116,21 +134,29 @@ class Layout extends React.PureComponent {
116134 }
117135 }
118136
119- const isAddFavoriteShabadModalOpen = props . modalOpened === 'addFavoriteShabad' ;
137+ const isAddFavoriteShabadModalOpen =
138+ props . modalOpened === 'addFavoriteShabad' ;
120139
121140 return online || pathname !== '/' ? (
122141 < div className = "layout" >
123142 < Banner
124143 banner = { {
125- message : 'Help Us Build the Future of SikhiToTheMax! Every donation doubled - dvnetwork.org/sikhitothemax' ,
126- link : "dvnetwork.org/sikhitothemax" ,
127- label : "Donate now" ,
128- type : "3" ,
144+ message :
145+ 'Help Us Build the Future of SikhiToTheMax! Every donation doubled - dvnetwork.org/sikhitothemax' ,
146+ link : 'dvnetwork.org/sikhitothemax' ,
147+ label : 'Donate now' ,
148+ type : '3' ,
129149 disabled : true ,
130150 } }
131151 />
132- { isAddFavoriteShabadModalOpen && < AddFavouriteShabadModal open = { isAddFavoriteShabadModalOpen } /> }
133- < div className = { `pusher ${ showMultiViewPanel ? 'enable' : '' } pin-settings ${ showPinSettings ? 'active' : '' } ` } >
152+ { isAddFavoriteShabadModalOpen && (
153+ < AddFavouriteShabadModal open = { isAddFavoriteShabadModalOpen } />
154+ ) }
155+ < div
156+ className = { `pusher ${
157+ showMultiViewPanel ? 'enable' : ''
158+ } pin-settings ${ showPinSettings ? 'active' : '' } `}
159+ >
134160 < Header
135161 defaultQuery = { this . props . defaultQuery }
136162 isHome = { isHome }
@@ -155,15 +181,16 @@ class Layout extends React.PureComponent {
155181 isShowSettings = { isShowSettings }
156182 isShowAI = { isShowAI }
157183 onAIClick = { this . handleAIClick }
158- isAIActive = { this . state . isAIActive } />
184+ isAIActive = { this . state . isAIActive }
185+ />
159186
160187 { /* AI Dialog */ }
161188 { this . state . isAIActive && (
162189 < div className = "floating-dialog-container" >
163190 < div className = "floating-dialog open" >
164191 < div className = "floating-dialog-header" >
165- < h4 > AI Response </ h4 >
166- < button
192+ < h4 > Gurbani Assistant </ h4 >
193+ < button
167194 className = "floating-dialog-toggle"
168195 onClick = { this . handleAIClick }
169196 >
@@ -172,8 +199,16 @@ class Layout extends React.PureComponent {
172199 </ div >
173200 { this . state . rephrasedTranslation && (
174201 < div className = "floating-dialog-content" >
175- < p className = "question" > { this . state . rephrasedTranslation . question } </ p >
176- < p className = "answer" > { this . state . rephrasedTranslation . answer } </ p >
202+ < p className = "question" >
203+ { this . state . rephrasedTranslation . question }
204+ </ p >
205+ < p className = "answer" >
206+ < p className = "gurmukhi gurbani-font" >
207+ { this . state . rephrasedTranslation . verse . gurmukhi }
208+ </ p >
209+ { this . state . rephrasedTranslation . answer }
210+ </ p >
211+ < p className = "footer" > Response generated by GurbaniBot AI.</ p >
177212 </ div >
178213 ) }
179214 </ div >
@@ -188,11 +223,12 @@ class Layout extends React.PureComponent {
188223 < GenericError
189224 title = { TEXTS . OFFLINE }
190225 description = { TEXTS . OFFLINE_DESCRIPTION }
191- image = { SachKaur } />
226+ image = { SachKaur }
227+ />
192228 </ div >
193229 < Footer showPinSettings = { showPinSettings } />
194230 </ >
195- )
231+ ) ;
196232 }
197233
198234 updateTheme ( ) {
@@ -202,25 +238,27 @@ class Layout extends React.PureComponent {
202238 }
203239
204240 processAuth ( ) {
205- const { location, history } = this . props
206- const {
207- token, logout
208- } = getQueryParams ( location . search ) ;
241+ const { location, history } = this . props ;
242+ const { token, logout } = getQueryParams ( location . search ) ;
209243 // @TODO : use redux to control state of session user
210244 if ( ! isFalsy ( token ) ) {
211- window . localStorage . setItem ( LOCAL_STORAGE_KEY_FOR_SESSION_TOKEN , token )
212- history . push ( '/' )
245+ window . localStorage . setItem ( LOCAL_STORAGE_KEY_FOR_SESSION_TOKEN , token ) ;
246+ history . push ( '/' ) ;
213247 }
214248 // @TODO : use redux to remove user sesssion
215249 if ( logout === 'success' ) {
216- window . localStorage . removeItem ( LOCAL_STORAGE_KEY_FOR_SESSION_TOKEN )
217- history . push ( '/' )
250+ window . localStorage . removeItem ( LOCAL_STORAGE_KEY_FOR_SESSION_TOKEN ) ;
251+ history . push ( '/' ) ;
218252 }
219253 return ;
220254 }
221255
222256 componentDidMount ( ) {
223- if ( location . pathname !== "/hukamnama" && location . pathname !== "/shabad" && location . pathname !== "/search" ) {
257+ if (
258+ location . pathname !== '/hukamnama' &&
259+ location . pathname !== '/shabad' &&
260+ location . pathname !== '/search'
261+ ) {
224262 this . props . closeSettingsPanel ( ) ;
225263 }
226264 this . processAuth ( ) ;
@@ -231,7 +269,7 @@ class Layout extends React.PureComponent {
231269 document . title = this . props . title ;
232270 this . updateTheme ( ) ;
233271 addVisraamClass ( ) ;
234-
272+
235273 // Expose setRephrasedTranslation globally for Shabad component
236274 window . setRephrasedTranslation = this . setRephrasedTranslation ;
237275 }
@@ -272,15 +310,12 @@ class Layout extends React.PureComponent {
272310 }
273311
274312 handleAIClick = ( ) => {
275- console . log ( 'handleAIClick' ) ;
276313 this . setState ( ( prevState ) => ( {
277314 isAIActive : ! prevState . isAIActive ,
278315 } ) ) ;
279316 } ;
280317
281318 setRephrasedTranslation = ( translation ) => {
282- console . log ( "setRephrasedTranslation" , translation ) ;
283- console . log ( "this.state.isAIActive" , this . state . isAIActive ) ;
284319 this . setState ( {
285320 rephrasedTranslation : translation ,
286321 isAIActive : true , // Auto-open when translation is set
@@ -289,7 +324,21 @@ class Layout extends React.PureComponent {
289324}
290325
291326export default connect (
292- ( { online, darkMode, autoScrollMode, showMultiViewPanel, showPinSettings, modalOpened } ) => ( { online, darkMode, autoScrollMode, showMultiViewPanel, showPinSettings, modalOpened } ) ,
327+ ( {
328+ online,
329+ darkMode,
330+ autoScrollMode,
331+ showMultiViewPanel,
332+ showPinSettings,
333+ modalOpened,
334+ } ) => ( {
335+ online,
336+ darkMode,
337+ autoScrollMode,
338+ showMultiViewPanel,
339+ showPinSettings,
340+ modalOpened,
341+ } ) ,
293342 {
294343 toggleDarkMode,
295344 setOnlineMode,
0 commit comments