Skip to content

Commit 1c47af1

Browse files
committed
feat: enhance project view modal and backend to support new project features
- Updated ProjectViewModal component to display new fields: tagline, key features, and gallery. - Added parsing for key features and gallery in create and update project actions. - Extended Project interface to include new fields: tagline, key_features, team_lead, team_members, gallery, and secondary_image. - Created SQL scripts to check existing columns and migrate the database schema to add new fields with appropriate comments.
1 parent ea267e9 commit 1c47af1

9 files changed

Lines changed: 1239 additions & 304 deletions

File tree

‎apps/codebility/app/(marketing)/services/_components/layout/ServiceDetailView.tsx‎

Lines changed: 400 additions & 51 deletions
Large diffs are not rendered by default.

‎apps/codebility/app/(marketing)/services/page.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ interface ProjectData {
2525
id: string;
2626
name: string;
2727
description?: string;
28+
tagline?: string;
29+
key_features?: string[];
30+
gallery?: string[];
2831
status?: string;
2932
start_date?: string;
3033
end_date?: string;
@@ -55,6 +58,9 @@ const ServicesPage = async () => {
5558
id: item.id,
5659
name: item.name,
5760
description: item.description || "",
61+
tagline: item.tagline || "",
62+
key_features: item.key_features || [],
63+
gallery: item.gallery || [],
5864
main_image: item.main_image || "",
5965
website_url: item.website_url || "",
6066
github_link: item.github_link || "",

‎apps/codebility/app/home/projects/_components/ProjectAddModal.tsx‎

Lines changed: 265 additions & 83 deletions
Large diffs are not rendered by default.

‎apps/codebility/app/home/projects/_components/ProjectEditModal.tsx‎

Lines changed: 296 additions & 109 deletions
Large diffs are not rendered by default.

‎apps/codebility/app/home/projects/_components/ProjectViewModal.tsx‎

Lines changed: 180 additions & 57 deletions
Large diffs are not rendered by default.

‎apps/codebility/app/home/projects/actions.ts‎

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,36 @@ export async function createProject(
180180
}
181181
}
182182

183+
// Parse key_features and gallery if provided
184+
const keyFeaturesData = formData.get("key_features");
185+
let keyFeatures: string[] | null = null;
186+
if (keyFeaturesData) {
187+
try {
188+
keyFeatures = JSON.parse(keyFeaturesData as string) as string[];
189+
} catch (error) {
190+
console.warn("Invalid key_features data:", error);
191+
}
192+
}
193+
194+
const galleryData = formData.get("gallery");
195+
let gallery: string[] | null = null;
196+
if (galleryData) {
197+
try {
198+
gallery = JSON.parse(galleryData as string) as string[];
199+
} catch (error) {
200+
console.warn("Invalid gallery data:", error);
201+
}
202+
}
203+
183204
// Create project (removed project_category_id as it no longer exists)
184205
const { data: project, error: projectError } = await supabase
185206
.from("projects")
186207
.insert({
187208
name: formData.get("name"),
188209
description: formData.get("description"),
210+
tagline: formData.get("tagline"),
211+
key_features: keyFeatures,
212+
gallery: gallery,
189213
github_link: formData.get("github_link"),
190214
website_url: formData.get("website_url"),
191215
figma_link: formData.get("figma_link"),
@@ -379,10 +403,31 @@ export async function updateProject(projectId: string, formData: FormData) {
379403
}
380404
}
381405

406+
// Parse key_features and gallery if provided
407+
const keyFeaturesData = formData.get("key_features");
408+
let keyFeatures: string[] | null = null;
409+
if (keyFeaturesData) {
410+
try {
411+
keyFeatures = JSON.parse(keyFeaturesData as string) as string[];
412+
} catch (error) {
413+
console.warn("Invalid key_features data:", error);
414+
}
415+
}
416+
417+
const galleryData = formData.get("gallery");
418+
let gallery: string[] | null = null;
419+
if (galleryData) {
420+
try {
421+
gallery = JSON.parse(galleryData as string) as string[];
422+
} catch (error) {
423+
console.warn("Invalid gallery data:", error);
424+
}
425+
}
426+
382427
// Update project details
383428
const updateData: any = {};
384429
for (const [key, value] of formData.entries()) {
385-
if (key !== "project_members" && key !== "tech_stack" && key !== "category_ids") {
430+
if (key !== "project_members" && key !== "tech_stack" && key !== "category_ids" && key !== "key_features" && key !== "gallery") {
386431
// Log the key-value pairs to debug
387432
console.log(`Processing form field: ${key} = ${value}`);
388433
updateData[key] = value;
@@ -394,6 +439,16 @@ export async function updateProject(projectId: string, formData: FormData) {
394439
updateData.tech_stack = techStack;
395440
}
396441

442+
// Add key_features if provided
443+
if (keyFeatures) {
444+
updateData.key_features = keyFeatures;
445+
}
446+
447+
// Add gallery if provided
448+
if (gallery) {
449+
updateData.gallery = gallery;
450+
}
451+
397452
// Log the final update data before sending to Supabase
398453
console.log("Final update data:", JSON.stringify(updateData, null, 2));
399454

‎apps/codebility/types/home/codev.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export interface Codev {
113113
date_applied?: string;
114114
promote_declined?: boolean;
115115
date_passed?: string;
116-
date_joined?: string;
116+
date_joined?: string;
117117
}
118118

119119
export type ApplicantStatus =
@@ -129,7 +129,7 @@ export type InternalStatus =
129129
| "INACTIVE"
130130
| "MENTOR"
131131
| "ADMIN"
132-
| "DEPLOYED"
132+
| "DEPLOYED";
133133

134134
export interface ProjectMember {
135135
id: string;
@@ -182,6 +182,13 @@ export interface Project {
182182
project_members?: ProjectMember[];
183183
kanban_display: boolean;
184184
public_display: boolean;
185+
// new fields
186+
tagline?: string;
187+
key_features?: string[];
188+
team_lead?: string;
189+
team_members?: string[];
190+
gallery?: string[];
191+
secondary_image?: string;
185192
}
186193
export interface Education {
187194
id: string;
@@ -217,7 +224,7 @@ export interface Level {
217224
max_points?: number; // Optional
218225
}
219226

220-
export type ActiveStatus = 'active' | 'inactive';
227+
export type ActiveStatus = "active" | "inactive";
221228

222229
export interface CodevFilter {
223230
positions?: string[];

‎check_existing_columns.sql‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Check existing columns in projects table
2+
SELECT
3+
column_name,
4+
data_type,
5+
is_nullable,
6+
column_default
7+
FROM information_schema.columns
8+
WHERE table_name = 'projects'
9+
AND table_schema = 'public'
10+
ORDER BY ordinal_position;

‎database_migration.sql‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Add new fields to projects table
2+
ALTER TABLE projects
3+
ADD COLUMN IF NOT EXISTS tagline TEXT,
4+
ADD COLUMN IF NOT EXISTS key_features JSONB,
5+
ADD COLUMN IF NOT EXISTS gallery JSONB,
6+
ADD COLUMN IF NOT EXISTS team_lead TEXT,
7+
ADD COLUMN IF NOT EXISTS team_members JSONB,
8+
ADD COLUMN IF NOT EXISTS secondary_image TEXT;
9+
10+
-- Add comments for documentation
11+
COMMENT ON COLUMN projects.tagline IS 'Short catchy tagline for the project';
12+
COMMENT ON COLUMN projects.key_features IS 'Array of key features as JSON';
13+
COMMENT ON COLUMN projects.gallery IS 'Array of gallery image URLs as JSON';
14+
COMMENT ON COLUMN projects.team_lead IS 'ID of the team leader';
15+
COMMENT ON COLUMN projects.team_members IS 'Array of team member IDs as JSON';
16+
COMMENT ON COLUMN projects.secondary_image IS 'URL of secondary project image';

0 commit comments

Comments
 (0)