@@ -95,11 +95,19 @@ export default function WidgetCard({
9595 const [ customPlatformsDisable , setCustomPlatformsDisable ] = useState ( false )
9696 const [ isLoading , setIsLoading ] = useState ( false )
9797 const [ isReturningUser , setIsReturningUser ] = useState ( false )
98-
98+ const [ isWidget , setIsWidget ] = useState < boolean > ( false )
99+
99100 const { app, setApp } = useAppStore ( ) // use for edit flow
100101 const searchParams = useSearchParams ( )
101102 const id = searchParams . get ( "id" )
102103
104+ useEffect ( ( ) => {
105+ const config = window ?. localStorage . getItem ( "widgetConfig" )
106+ if ( config ) {
107+ setIsWidget ( true )
108+ }
109+ } , [ ] )
110+
103111 const handleAddQuestion = ( type : QuestionType ) => {
104112 if ( questions . length == 3 ) return
105113 const id = Date . now ( )
@@ -307,7 +315,7 @@ export default function WidgetCard({
307315 tags : cat . tags . filter ( ( tag ) => tag . id !== tagId ) ,
308316 }
309317 : cat ,
310- ) ,
318+ ) ,
311319 }
312320 }
313321 return q
@@ -462,7 +470,6 @@ export default function WidgetCard({
462470 addUrl ( )
463471 }
464472
465- const savedConfig = localStorage . getItem ( "widgetConfig" )
466473
467474 useEffect ( ( ) => {
468475 const getUniversalProfiles = async ( ) => {
@@ -506,7 +513,7 @@ export default function WidgetCard({
506513 ]
507514
508515 setProfileTypes ( updatedProfilesWithCustom )
509-
516+ const savedConfig = window ?. localStorage . getItem ( "widgetConfig" )
510517 // Set the first profile as selected if it exists
511518 if ( updatedProfilesWithCustom . length > 0 && ! savedConfig ) {
512519 setSelectedProfileType ( updatedProfilesWithCustom [ 0 ] )
@@ -1105,12 +1112,12 @@ export default function WidgetCard({
11051112 savedAt : new Date ( ) . getTime ( ) , // Add timestamp
11061113 }
11071114
1108- localStorage . setItem ( "widgetConfig" , JSON . stringify ( configData ) )
1115+ window ?. localStorage . setItem ( "widgetConfig" , JSON . stringify ( configData ) )
11091116 alert ( "Configuration saved successfully! Your progress will be restored when you return." )
11101117 }
11111118
11121119 const resetConfig = ( ) => {
1113- localStorage . removeItem ( "widgetConfig" )
1120+ window ?. localStorage . removeItem ( "widgetConfig" )
11141121 // Reset to default values
11151122 setCustomizationData ( {
11161123 general : {
@@ -1139,7 +1146,7 @@ export default function WidgetCard({
11391146 useEffect ( ( ) => {
11401147 // Don't load saved config if we're in edit mode (id exists)
11411148 if ( ! id ) {
1142- const savedConfig = localStorage . getItem ( "widgetConfig" )
1149+ const savedConfig = window ?. localStorage . getItem ( "widgetConfig" )
11431150 if ( savedConfig ) {
11441151 const parsedConfig = JSON . parse ( savedConfig )
11451152
@@ -1165,7 +1172,6 @@ export default function WidgetCard({
11651172 }
11661173 } , [ id ] )
11671174
1168- const isWidget = localStorage . getItem ( "widgetConfig" )
11691175
11701176 // Add a new function to check if any data has been modified from default values
11711177 const hasUserEnteredData = ( ) => {
0 commit comments