Skip to content

Commit 4b16074

Browse files
Zeff01claude
andcommitted
refactor: Remove external survey option, keep only in-app surveys
Changes: - Remove "External Survey" toggle from survey form - Remove is_external and survey_url fields from schema - Simplify SurveyForm to only support in-app surveys - Remove external survey checks from surveys list page - Remove is_external validation from response page - Show "Build Questions" button for all surveys - Clean up unused imports (ExternalLink icon) All surveys are now built directly in the app with questions. Users can no longer link to external survey platforms. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dd1cf2a commit 4b16074

3 files changed

Lines changed: 21 additions & 108 deletions

File tree

‎apps/codebility/app/home/settings/surveys/_components/SurveyForm.tsx‎

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,13 @@ import SurveyImageUpload from "./SurveyImageUpload";
1717
const 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

4029
type 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

‎apps/codebility/app/home/settings/surveys/page.tsx‎

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useState, useEffect } from "react";
44
import { useRouter } from "next/navigation";
5-
import { Plus, Pencil, Trash2, Eye, EyeOff, ExternalLink, Settings } from "lucide-react";
5+
import { Plus, Pencil, Trash2, Eye, EyeOff, Settings } from "lucide-react";
66
import { Button } from "@codevs/ui/button";
77
import { H1 } from "@/components/shared/dashboard";
88
import PageContainer from "../../_components/PageContainer";
@@ -14,8 +14,6 @@ interface Survey {
1414
id: string;
1515
title: string;
1616
description: string;
17-
is_external: boolean;
18-
survey_url?: string;
1917
type: "general" | "feedback" | "satisfaction" | "research" | "onboarding";
2018
image_url?: string;
2119
target_audience: "all" | "codev" | "intern" | "hr" | "admin";
@@ -256,26 +254,6 @@ export default function SurveysPage() {
256254
<p className="text-gray-600 dark:text-gray-300 mb-3">
257255
{survey.description}
258256
</p>
259-
{survey.is_external && survey.survey_url && (
260-
<div className="flex items-center gap-2 mb-3">
261-
<a
262-
href={survey.survey_url}
263-
target="_blank"
264-
rel="noopener noreferrer"
265-
className="text-sm text-blue-600 dark:text-blue-400 hover:underline flex items-center gap-1"
266-
>
267-
<ExternalLink className="h-3 w-3" />
268-
View External Survey
269-
</a>
270-
</div>
271-
)}
272-
{!survey.is_external && (
273-
<div className="flex items-center gap-2 mb-3">
274-
<span className="text-sm text-gray-600 dark:text-gray-400 flex items-center gap-1">
275-
📋 In-App Survey
276-
</span>
277-
</div>
278-
)}
279257
<div className="text-xs text-gray-500 dark:text-gray-400 space-y-1">
280258
<div>Created: {formatDate(survey.start_date)}</div>
281259
{survey.end_date && (
@@ -286,17 +264,15 @@ export default function SurveysPage() {
286264
</div>
287265

288266
<div className="flex items-center gap-2 ml-4">
289-
{!survey.is_external && (
290-
<Button
291-
variant="ghost"
292-
size="sm"
293-
onClick={() => router.push(`/home/settings/surveys/${survey.id}`)}
294-
className="text-purple-600 hover:text-purple-700 hover:bg-purple-50 dark:hover:bg-purple-900/20"
295-
title="Build questions"
296-
>
297-
<Settings className="h-4 w-4" />
298-
</Button>
299-
)}
267+
<Button
268+
variant="ghost"
269+
size="sm"
270+
onClick={() => router.push(`/home/settings/surveys/${survey.id}`)}
271+
className="text-purple-600 hover:text-purple-700 hover:bg-purple-50 dark:hover:bg-purple-900/20"
272+
title="Build questions"
273+
>
274+
<Settings className="h-4 w-4" />
275+
</Button>
300276
<Button
301277
variant="ghost"
302278
size="sm"

‎apps/codebility/app/home/surveys/[surveyId]/page.tsx‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function SurveyResponsePage() {
5858
const supabase = createClientClientComponent();
5959
const { data: surveyData, error: surveyError } = await supabase
6060
.from("surveys")
61-
.select("id, title, description, is_active, is_external")
61+
.select("id, title, description, is_active")
6262
.eq("id", surveyId)
6363
.single();
6464

@@ -68,13 +68,6 @@ export default function SurveyResponsePage() {
6868
return;
6969
}
7070

71-
// Check if external survey
72-
if (surveyData.is_external) {
73-
toast.error("This is an external survey");
74-
router.push("/home");
75-
return;
76-
}
77-
7871
setSurvey(surveyData);
7972

8073
// Check if already responded

0 commit comments

Comments
 (0)