@@ -17,24 +17,13 @@ import SurveyImageUpload from "./SurveyImageUpload";
1717const surveySchema = z . object ( {
1818 title : z . string ( ) . min ( 1 , "Title is required" ) . max ( 255 , "Title too long" ) ,
1919 description : z . string ( ) . min ( 1 , "Description is required" ) ,
20- is_external : z . boolean ( ) . default ( false ) ,
21- survey_url : z . string ( ) . optional ( ) ,
2220 type : z . enum ( [ "general" , "feedback" , "satisfaction" , "research" , "onboarding" ] ) ,
2321 image_url : z . string ( ) . optional ( ) ,
2422 target_audience : z . enum ( [ "all" , "codev" , "intern" , "hr" , "admin" ] ) ,
2523 priority : z . number ( ) . min ( 1 ) . max ( 100 ) ,
2624 is_active : z . boolean ( ) ,
2725 start_date : z . string ( ) ,
2826 end_date : z . string ( ) . optional ( ) ,
29- } ) . refine ( ( data ) => {
30- // If external survey, survey_url is required and must be valid
31- if ( data . is_external ) {
32- return data . survey_url && z . string ( ) . url ( ) . safeParse ( data . survey_url ) . success ;
33- }
34- return true ;
35- } , {
36- message : "Survey URL is required for external surveys" ,
37- path : [ "survey_url" ] ,
3827} ) ;
3928
4029type SurveyFormData = z . infer < typeof surveySchema > ;
@@ -43,8 +32,6 @@ interface Survey {
4332 id : string ;
4433 title : string ;
4534 description : string ;
46- is_external : boolean ;
47- survey_url ?: string ;
4835 type : "general" | "feedback" | "satisfaction" | "research" | "onboarding" ;
4936 image_url ?: string ;
5037 target_audience : "all" | "codev" | "intern" | "hr" | "admin" ;
@@ -75,8 +62,6 @@ export default function SurveyForm({ survey, onSuccess }: SurveyFormProps) {
7562 defaultValues : {
7663 title : survey ?. title || "" ,
7764 description : survey ?. description || "" ,
78- is_external : survey ?. is_external ?? false ,
79- survey_url : survey ?. survey_url || "" ,
8065 type : survey ?. type || "general" ,
8166 image_url : survey ?. image_url || "" ,
8267 target_audience : survey ?. target_audience || "all" ,
@@ -88,7 +73,6 @@ export default function SurveyForm({ survey, onSuccess }: SurveyFormProps) {
8873 } ) ;
8974
9075 const isActive = watch ( "is_active" ) ;
91- const isExternal = watch ( "is_external" ) ;
9276
9377 const onSubmit = async ( data : SurveyFormData ) => {
9478 setLoading ( true ) ;
@@ -98,8 +82,6 @@ export default function SurveyForm({ survey, onSuccess }: SurveyFormProps) {
9882 const surveyData = {
9983 title : data . title ,
10084 description : data . description ,
101- is_external : data . is_external ,
102- survey_url : data . is_external ? data . survey_url : null ,
10385 type : data . type ,
10486 image_url : data . image_url || null ,
10587 target_audience : data . target_audience ,
@@ -144,55 +126,17 @@ export default function SurveyForm({ survey, onSuccess }: SurveyFormProps) {
144126
145127 return (
146128 < form onSubmit = { handleSubmit ( onSubmit ) } className = "space-y-6" >
147- { /* Survey Type Toggle */ }
148- < div className = "flex items-center space-x-2 p-4 bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700" >
149- < Switch
150- id = "is_external"
151- checked = { isExternal }
152- onCheckedChange = { ( checked ) => setValue ( "is_external" , checked ) }
153- className = "data-[state=checked]:bg-customViolet-100 dark:[&>span]:bg-foreground [&>span]:bg-muted-foreground"
129+ < div className = "space-y-2" >
130+ < Label htmlFor = "title" className = "text-foreground dark:text-gray-300" > Title *</ Label >
131+ < Input
132+ id = "title"
133+ variant = "lightgray"
134+ { ...register ( "title" ) }
135+ placeholder = "Enter survey title"
136+ className = "rounded"
154137 />
155- < div className = "flex-1" >
156- < Label htmlFor = "is_external" className = "text-foreground dark:text-gray-300 font-medium" >
157- External Survey
158- </ Label >
159- < p className = "text-sm text-gray-500 dark:text-gray-400" >
160- { isExternal
161- ? "Link to external survey (Google Forms, Typeform, etc.)"
162- : "Build survey with questions directly in the app" }
163- </ p >
164- </ div >
165- </ div >
166-
167- < div className = "grid grid-cols-1 md:grid-cols-2 gap-6" >
168- < div className = "space-y-2" >
169- < Label htmlFor = "title" className = "text-foreground dark:text-gray-300" > Title *</ Label >
170- < Input
171- id = "title"
172- variant = "lightgray"
173- { ...register ( "title" ) }
174- placeholder = "Enter survey title"
175- className = "rounded"
176- />
177- { errors . title && (
178- < p className = "text-sm text-red-600 dark:text-red-400" > { errors . title . message } </ p >
179- ) }
180- </ div >
181-
182- { isExternal && (
183- < div className = "space-y-2" >
184- < Label htmlFor = "survey_url" className = "text-foreground dark:text-gray-300" > Survey URL *</ Label >
185- < Input
186- id = "survey_url"
187- variant = "lightgray"
188- { ...register ( "survey_url" ) }
189- placeholder = "https://forms.google.com/..."
190- className = "rounded"
191- />
192- { errors . survey_url && (
193- < p className = "text-sm text-red-600 dark:text-red-400" > { errors . survey_url . message } </ p >
194- ) }
195- </ div >
138+ { errors . title && (
139+ < p className = "text-sm text-red-600 dark:text-red-400" > { errors . title . message } </ p >
196140 ) }
197141 </ div >
198142
0 commit comments