@@ -129,30 +129,30 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
129129
130130 // Extract top widget configuration
131131 if ( existingConfig . topWidget ?. config ) {
132- const topWidgetType = existingConfig . topWidget . type ;
132+ const existingTopWidgetType = existingConfig . topWidget . type ;
133133 const topConfig = existingConfig . topWidget . config ;
134134
135- if ( topWidgetType ) {
136- formContext . setValue ( 'topWidgetType' , topWidgetType ) ;
135+ if ( existingTopWidgetType ) {
136+ formContext . setValue ( 'topWidgetType' , existingTopWidgetType ) ;
137137
138138 // Map configuration based on widget type
139- if ( topWidgetType === ITEM_TYPE . WEATHER_WIDGET ) {
139+ if ( existingTopWidgetType === ITEM_TYPE . WEATHER_WIDGET ) {
140140 topWidgetFields = {
141141 temperatureUnit : topConfig . temperatureUnit || 'fahrenheit' ,
142142 location : topConfig . location || null
143143 } ;
144144 formContext . setValue ( 'top_temperatureUnit' , topConfig . temperatureUnit || 'fahrenheit' ) ;
145145 formContext . setValue ( 'top_location' , topConfig . location || null ) ;
146146 }
147- else if ( topWidgetType === ITEM_TYPE . DATE_TIME_WIDGET ) {
147+ else if ( existingTopWidgetType === ITEM_TYPE . DATE_TIME_WIDGET ) {
148148 topWidgetFields = {
149149 location : topConfig . location || null ,
150150 timezone : topConfig . timezone || ''
151151 } ;
152152 formContext . setValue ( 'top_location' , topConfig . location || null ) ;
153153 formContext . setValue ( 'top_timezone' , topConfig . timezone || '' ) ;
154154 }
155- else if ( topWidgetType === ITEM_TYPE . SYSTEM_MONITOR_WIDGET ) {
155+ else if ( existingTopWidgetType === ITEM_TYPE . SYSTEM_MONITOR_WIDGET ) {
156156 const gauges = topConfig . gauges || [ 'cpu' , 'temp' , 'ram' ] ;
157157 topWidgetFields = {
158158 temperatureUnit : topConfig . temperatureUnit || 'fahrenheit' ,
@@ -173,7 +173,7 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
173173 formContext . setValue ( 'top_showSystemInfo' , topConfig . showSystemInfo !== false ) ;
174174 formContext . setValue ( 'top_showInternetStatus' , topConfig . showInternetStatus !== false ) ;
175175 }
176- else if ( topWidgetType === ITEM_TYPE . DISK_MONITOR_WIDGET ) {
176+ else if ( existingTopWidgetType === ITEM_TYPE . DISK_MONITOR_WIDGET ) {
177177 topWidgetFields = {
178178 selectedDisks : topConfig . selectedDisks || [ ] ,
179179 showIcons : topConfig . showIcons !== false ,
@@ -185,7 +185,7 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
185185 formContext . setValue ( 'top_showName' , topConfig . showName !== false ) ;
186186 formContext . setValue ( 'top_layout' , '2x2' ) ;
187187 }
188- else if ( topWidgetType === ITEM_TYPE . PIHOLE_WIDGET ) {
188+ else if ( existingTopWidgetType === ITEM_TYPE . PIHOLE_WIDGET ) {
189189 // Use masked values for sensitive fields if they exist
190190 const maskedApiToken = topConfig . _hasApiToken ? '**********' : '' ;
191191 const maskedPassword = topConfig . _hasPassword ? '**********' : '' ;
@@ -207,7 +207,7 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
207207 formContext . setValue ( 'top_piholeName' , topConfig . displayName || '' ) ;
208208 formContext . setValue ( 'top_showLabel' , topConfig . showLabel !== undefined ? topConfig . showLabel : true ) ;
209209 }
210- else if ( topWidgetType === ITEM_TYPE . ADGUARD_WIDGET ) {
210+ else if ( existingTopWidgetType === ITEM_TYPE . ADGUARD_WIDGET ) {
211211 // Use masked values for sensitive fields if they exist
212212 const maskedUsername = topConfig . _hasUsername ? '**********' : '' ;
213213 const maskedPassword = topConfig . _hasPassword ? '**********' : '' ;
@@ -234,15 +234,15 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
234234
235235 // Extract bottom widget configuration
236236 if ( existingConfig . bottomWidget ?. config ) {
237- const bottomWidgetType = existingConfig . bottomWidget . type ;
237+ const existingBottomWidgetType = existingConfig . bottomWidget . type ;
238238 const bottomConfig = existingConfig . bottomWidget . config ;
239239
240- if ( bottomWidgetType ) {
240+ if ( existingBottomWidgetType ) {
241241 // Set the bottomWidgetType directly
242- formContext . setValue ( 'bottomWidgetType' , bottomWidgetType ) ;
242+ formContext . setValue ( 'bottomWidgetType' , existingBottomWidgetType ) ;
243243
244244 // Map configuration based on widget type
245- if ( bottomWidgetType === ITEM_TYPE . WEATHER_WIDGET ) {
245+ if ( existingBottomWidgetType === ITEM_TYPE . WEATHER_WIDGET ) {
246246 const temperatureUnit = bottomConfig . temperatureUnit || 'fahrenheit' ;
247247 const location = bottomConfig . location || null ;
248248
@@ -260,7 +260,7 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
260260 formContext . setValue ( 'bottom_location' , null ) ;
261261 }
262262 }
263- else if ( bottomWidgetType === ITEM_TYPE . DATE_TIME_WIDGET ) {
263+ else if ( existingBottomWidgetType === ITEM_TYPE . DATE_TIME_WIDGET ) {
264264 const location = bottomConfig . location || null ;
265265 const timezone = bottomConfig . timezone || '' ;
266266
@@ -278,7 +278,7 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
278278
279279 formContext . setValue ( 'bottom_timezone' , timezone ) ;
280280 }
281- else if ( bottomWidgetType === ITEM_TYPE . SYSTEM_MONITOR_WIDGET ) {
281+ else if ( existingBottomWidgetType === ITEM_TYPE . SYSTEM_MONITOR_WIDGET ) {
282282 const gauges = bottomConfig . gauges || [ 'cpu' , 'temp' , 'ram' ] ;
283283 bottomWidgetFields = {
284284 temperatureUnit : bottomConfig . temperatureUnit || 'fahrenheit' ,
@@ -299,7 +299,7 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
299299 formContext . setValue ( 'bottom_showSystemInfo' , bottomConfig . showSystemInfo !== false ) ;
300300 formContext . setValue ( 'bottom_showInternetStatus' , bottomConfig . showInternetStatus !== false ) ;
301301 }
302- else if ( bottomWidgetType === ITEM_TYPE . DISK_MONITOR_WIDGET ) {
302+ else if ( existingBottomWidgetType === ITEM_TYPE . DISK_MONITOR_WIDGET ) {
303303 bottomWidgetFields = {
304304 selectedDisks : bottomConfig . selectedDisks || [ ] ,
305305 showIcons : bottomConfig . showIcons !== false ,
@@ -311,7 +311,7 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
311311 formContext . setValue ( 'bottom_showName' , bottomConfig . showName !== false ) ;
312312 formContext . setValue ( 'bottom_layout' , '2x2' ) ;
313313 }
314- else if ( bottomWidgetType === ITEM_TYPE . PIHOLE_WIDGET ) {
314+ else if ( existingBottomWidgetType === ITEM_TYPE . PIHOLE_WIDGET ) {
315315 // Use masked values for sensitive fields if they exist
316316 const maskedApiToken = bottomConfig . _hasApiToken ? '**********' : '' ;
317317 const maskedPassword = bottomConfig . _hasPassword ? '**********' : '' ;
@@ -333,7 +333,7 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
333333 formContext . setValue ( 'bottom_piholeName' , bottomConfig . displayName || '' ) ;
334334 formContext . setValue ( 'bottom_showLabel' , bottomConfig . showLabel !== undefined ? bottomConfig . showLabel : true ) ;
335335 }
336- else if ( bottomWidgetType === ITEM_TYPE . ADGUARD_WIDGET ) {
336+ else if ( existingBottomWidgetType === ITEM_TYPE . ADGUARD_WIDGET ) {
337337 // Use masked values for sensitive fields if they exist
338338 const maskedUsername = bottomConfig . _hasUsername ? '**********' : '' ;
339339 const maskedPassword = bottomConfig . _hasPassword ? '**********' : '' ;
@@ -820,8 +820,8 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
820820 useEffect ( ( ) => {
821821 const handleFormSubmit = async ( ) => {
822822 // Capture widget types immediately before they can be lost
823- const topWidgetType = formContext . getValues ( 'topWidgetType' ) ;
824- const bottomWidgetType = formContext . getValues ( 'bottomWidgetType' ) ;
823+ const currentTopWidgetType = formContext . getValues ( 'topWidgetType' ) ;
824+ const currentBottomWidgetType = formContext . getValues ( 'bottomWidgetType' ) ;
825825
826826 // Grab the current page's state first
827827 const currentPosition = currentPage === 0 ? 'top' : 'bottom' ;
@@ -832,8 +832,8 @@ export const DualWidgetConfig = ({ formContext, existingItem }: DualWidgetConfig
832832 captureFormValuesToState ( 'bottom' ) ;
833833
834834 // Build individual widget configs using captured types
835- const topWidget = topWidgetType ? await buildWidgetConfigWithType ( 'top' , topWidgetType ) : undefined ;
836- const bottomWidget = bottomWidgetType ? await buildWidgetConfigWithType ( 'bottom' , bottomWidgetType ) : undefined ;
835+ const topWidget = currentTopWidgetType ? await buildWidgetConfigWithType ( 'top' , currentTopWidgetType ) : undefined ;
836+ const bottomWidget = currentBottomWidgetType ? await buildWidgetConfigWithType ( 'bottom' , currentBottomWidgetType ) : undefined ;
837837
838838 // Create the final dual widget config
839839 const dualWidgetConfig = {
0 commit comments