@@ -17,7 +17,9 @@ const FormBuilderComponent = dynamic(() => import('@/components/FormBuilder'), {
17
17
const STORAGE_KEY = 'surveyjs-form-definitions' ;
18
18
19
19
export default function Home ( ) {
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
21
const [ surveyJson , setSurveyJson ] = useState < any > ( null ) ;
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
23
const [ savedSurveys , setSavedSurveys ] = useState < any [ ] > ( [ ] ) ;
22
24
const [ currentSurveyName , setCurrentSurveyName ] = useState < string > ( '' ) ;
23
25
const [ isLoading , setIsLoading ] = useState ( true ) ;
@@ -28,15 +30,19 @@ export default function Home() {
28
30
const savedList = saved ? JSON . parse ( saved ) : [ ] ;
29
31
30
32
const preloaded = [ courseEvaluationForm , healthAndWellnessAssessment , marketResearchForm , volunteerSignUpForm , websiteUsabilityForm ] ;
31
- const merged = [ ...preloaded , ...savedList . filter ( s => ! preloaded . some ( p => p . id === s . id ) ) ] ;
33
+ const merged = [
34
+ ...preloaded ,
35
+ ...savedList . filter ( ( s : { id : string } ) => ! preloaded . some ( p => p . id === s . id ) )
36
+ ] ;
37
+
32
38
33
39
setSavedSurveys ( merged ) ;
34
40
setIsLoading ( false ) ;
35
41
}
36
42
37
43
loadInitialSurveys ( ) ;
38
44
} , [ ] ) ;
39
-
45
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
46
const handleSurveyChange = useCallback ( ( json : any ) => {
41
47
setSurveyJson ( json ) ;
42
48
} , [ ] ) ;
@@ -60,7 +66,7 @@ export default function Home() {
60
66
setCurrentSurveyName ( '' ) ;
61
67
alert ( 'Survey saved successfully!' ) ;
62
68
} , [ surveyJson , currentSurveyName , savedSurveys ] ) ;
63
-
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
70
const loadSurvey = useCallback ( ( survey : any ) => {
65
71
setSurveyJson ( survey . json ) ;
66
72
setCurrentSurveyName ( survey . name ) ;
@@ -87,86 +93,75 @@ export default function Home() {
87
93
88
94
return (
89
95
< div className = "min-h-screen bg-gray-50" >
90
- { /* Header */ }
91
- < header className = "bg-white shadow-sm border-b border-gray-200 py-6" >
92
- < div className = "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8" >
93
- < div className = "flex flex-col sm:flex-row sm:justify-between sm:items-center space-y-4 sm:space-y-0" >
94
- < h1 className = "text-2xl font-bold text-gray-900" > SurveyJS Form Builder</ h1 >
95
- < div className = "flex items-center gap-x-6" >
96
- < input
97
- type = "text"
98
- placeholder = "Enter survey name..."
99
- value = { currentSurveyName }
100
- onChange = { ( e ) => setCurrentSurveyName ( e . target . value ) }
101
- className = "px-5 py-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 w-64"
102
- />
96
+ < div className = "flex h-[calc(100vh-6rem)]" >
97
+ < aside className = "hidden lg:block xl:w-96 bg-white shadow-sm border-r border-gray-200 overflow-y-auto p-4" >
98
+ < div className = "flex justify-between items-center mb-4" >
99
+ < h2 className = "font-medium text-gray-800 tracking-wide uppercase text-[17px]" >
100
+ Saved Surveys
101
+ </ h2 >
102
+ { savedSurveys . length > 0 && (
103
103
< button
104
- onClick = { saveSurvey }
105
- className = "px-10 py-5 bg-blue- 600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition "
104
+ onClick = { clearAllSurveys }
105
+ className = "cursor-pointer text-red- 600 hover:text-red-800 transition text-[17px] "
106
106
>
107
- Save Survey
107
+ Clear All
108
108
</ button >
109
- </ div >
109
+ ) }
110
110
</ div >
111
- </ div >
112
- </ header >
113
111
114
- < div className = "flex h-[calc(100vh-6rem)] " >
115
- { /* Sidebar */ }
116
- < aside className = "w-80 bg-white shadow-sm border-r border-gray-200 overflow-y-auto" >
117
- < div className = "p-6" >
118
- < div className = "flex justify-between items-center mb-12 px-2" >
119
- < h2 className = "text-lg font-semibold text-gray-900" > Saved Surveys </ h2 >
120
- { savedSurveys . length > 0 && (
121
- < button
122
- onClick = { clearAllSurveys }
123
- className = "text-sm text-red-600 hover:text-red-800 transition"
124
- >
125
- Clear All
126
- </ button >
127
- ) }
128
- </ div >
112
+ < div className = "flex flex-col gap-4 mb-8 " >
113
+ < input
114
+ type = "text"
115
+ placeholder = "Enter survey name"
116
+ value = { currentSurveyName }
117
+ onChange = { ( e ) => setCurrentSurveyName ( e . target . value ) }
118
+ className = "px-2 py-3 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-base"
119
+ />
120
+ < button
121
+ onClick = { saveSurvey }
122
+ className = "cursor-pointer py-3 px-2 bg-blue-600 text-white text-base font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition"
123
+ >
124
+ Save Survey
125
+ </ button >
126
+ </ div >
129
127
130
- { savedSurveys . length === 0 ? (
131
- < p className = "text-gray-500 text-sm" > No saved surveys yet.</ p >
132
- ) : (
133
- < div className = "space-y-6" >
134
- { savedSurveys . map ( ( survey ) => (
135
- < div
136
- key = { survey . id }
137
- className = "p-5 bg-gray-50 rounded-lg hover:bg-gray-100 transition"
138
- >
139
- < div className = "flex justify-between items-start gap-6" >
140
- < div className = "flex-1" >
141
- < h3 className = "font-medium text-gray-900 mb-2" > { survey . name } </ h3 >
142
- < p className = "text-sm text-gray-500" >
143
- Created: { new Date ( survey . createdAt ) . toLocaleDateString ( ) }
144
- </ p >
145
- </ div >
146
- < div className = "flex gap-4 ml-2" >
147
- < button
148
- onClick = { ( ) => loadSurvey ( survey ) }
149
- className = "text-blue-600 hover:text-blue-800 text-sm transition"
150
- >
151
- Load
152
- </ button >
153
- < button
154
- onClick = { ( ) => deleteSurvey ( survey . id ) }
155
- className = "text-red-600 hover:text-red-800 text-sm transition"
156
- >
157
- Delete
158
- </ button >
159
- </ div >
128
+ { savedSurveys . length === 0 ? (
129
+ < p className = "text-gray-500" > No saved surveys yet.</ p >
130
+ ) : (
131
+ < div >
132
+ { savedSurveys . map ( ( survey ) => (
133
+ < div key = { survey . id } className = "mb-6" >
134
+ < div className = "flex justify-between items-start" >
135
+ < div className = "flex-1 pr-8" >
136
+ < h3 className = "font-medium text-gray-900 mb-1 text-base" >
137
+ { survey . name }
138
+ </ h3 >
139
+ < p className = "text-gray-500" >
140
+ Created: { new Date ( survey . createdAt ) . toLocaleDateString ( ) }
141
+ </ p >
142
+ </ div >
143
+ < div className = "flex flex-row items-center gap-3 min-w-[70px]" >
144
+ < button
145
+ onClick = { ( ) => loadSurvey ( survey ) }
146
+ className = "cursor-pointer text-blue-600 hover:text-blue-800 transition py-1"
147
+ >
148
+ Load
149
+ </ button >
150
+ < button
151
+ onClick = { ( ) => deleteSurvey ( survey . id ) }
152
+ className = "cursor-pointer text-red-600 hover:text-red-800 transition py-1"
153
+ >
154
+ Delete
155
+ </ button >
160
156
</ div >
161
157
</ div >
162
- ) ) }
163
- </ div >
164
- ) }
165
- </ div >
158
+ </ div >
159
+ ) ) }
160
+ </ div >
161
+ ) }
166
162
</ aside >
167
163
168
- { /* Main Content */ }
169
- < main className = "flex-1 p-8" >
164
+ < main className = "flex-1 overflow-y-auto" >
170
165
< FormBuilderComponent
171
166
onSaveSurvey = { handleSurveyChange }
172
167
json = { surveyJson }
@@ -175,4 +170,4 @@ export default function Home() {
175
170
</ div >
176
171
</ div >
177
172
) ;
178
- }
173
+ }
0 commit comments