@@ -85,6 +85,14 @@ const Sidebar = (): JSX.Element => {
8585 const navigate = useNavigate ( )
8686 const location = useLocation ( )
8787 const [ name , setName ] = useState < string > ( '' )
88+ useEffect ( ( ) => {
89+ if ( appStateContext ?. state . isRequestInitiated == true ) {
90+ NavigationButtonStates . Disabled
91+ }
92+ else {
93+ NavigationButtonStates . Active
94+ }
95+ } )
8896
8997 useEffect ( ( ) => {
9098 if ( ! appStateContext ) {
@@ -113,7 +121,12 @@ const Sidebar = (): JSX.Element => {
113121 }
114122
115123 const currentView = determineView ( )
116- const isGenerating = appStateContext ?. state . isGenerating
124+ // inactive, disabled, active
125+ var draftButtonState = NavigationButtonStates . Disabled
126+ if ( appStateContext ?. state . draftedDocument ) {
127+ draftButtonState = currentView === 'draft' ? NavigationButtonStates . Active : NavigationButtonStates . Inactive
128+ }
129+ const isGenerating = appStateContext ?. state . isRequestInitiated
117130
118131 return (
119132 < Stack className = { styles . sidebarContainer } >
@@ -125,9 +138,9 @@ const Sidebar = (): JSX.Element => {
125138 text = { 'Browse' }
126139 buttonState = {
127140 currentView === 'chat'
128- ? NavigationButtonStates . Active
129- : appStateContext ?. state . isGenerating
130- ? NavigationButtonStates . Disabled
141+ ? NavigationButtonStates . Active
142+ : appStateContext ?. state . isRequestInitiated
143+ ? NavigationButtonStates . Disabled
131144 : NavigationButtonStates . Inactive
132145 }
133146 onClick = { ( ) => {
@@ -141,9 +154,10 @@ const Sidebar = (): JSX.Element => {
141154 buttonState = {
142155 currentView === 'generate'
143156 ? NavigationButtonStates . Active
144- : appStateContext ?. state . isGenerating
157+ : appStateContext ?. state . isRequestInitiated
145158 ? NavigationButtonStates . Disabled
146159 : NavigationButtonStates . Inactive
160+
147161 }
148162 onClick = { ( ) => {
149163 if ( ! isGenerating ) {
@@ -153,17 +167,10 @@ const Sidebar = (): JSX.Element => {
153167 />
154168 < NavigationButton
155169 text = { 'Draft' }
156- buttonState = {
157- currentView === 'draft'
158- ? NavigationButtonStates . Active
159- : appStateContext ?. state . isGenerating
160- ? NavigationButtonStates . Disabled
161- : NavigationButtonStates . Inactive
162- }
170+ buttonState = { draftButtonState }
171+
163172 onClick = { ( ) => {
164- if ( ! isGenerating ) {
165- navigate ( '/draft' )
166- }
173+ navigate ( '/draft' )
167174 } }
168175 />
169176 </ Stack >
0 commit comments