initial commit: project completion with proper gitignore

This commit is contained in:
AyrisAI
2026-05-16 00:43:22 +03:00
commit e708ba2156
84 changed files with 11035 additions and 0 deletions

100
app/actions.ts Normal file
View File

@@ -0,0 +1,100 @@
'use server'
import sql from '@/lib/db';
export async function getSettings() {
try {
const settings = await sql`SELECT * FROM settings WHERE id = 1 LIMIT 1`;
return settings[0] || null;
} catch (error) {
console.error('Error fetching settings:', error);
return null;
}
}
export async function getFeaturedServices() {
try {
const services = await sql`SELECT * FROM services WHERE is_featured = true ORDER BY display_order ASC LIMIT 4`;
return services;
} catch (error) {
console.error('Error fetching services:', error);
return [];
}
}
export async function getFeaturedProjects() {
try {
const projects = await sql`SELECT * FROM projects WHERE is_featured = true ORDER BY created_at DESC LIMIT 6`;
return projects;
} catch (error) {
console.error('Error fetching projects:', error);
return [];
}
}
export async function submitLead(formData: {
firstName: string;
lastName: string;
email: string;
projectType: string;
message: string;
}) {
try {
const fullName = `${formData.firstName} ${formData.lastName}`;
await sql`
INSERT INTO leads (full_name, email, service_type, message, status)
VALUES (${fullName}, ${formData.email}, ${formData.projectType}, ${formData.message}, 'new')
`;
return { success: true };
} catch (error) {
console.error('Error submitting lead:', error);
return { error: 'Failed to submit' };
}
}
export async function getPartners() {
try {
return await sql`
SELECT p.*, (
SELECT slug FROM projects
WHERE LOWER(TRIM(p.name)) LIKE '%' || LOWER(TRIM(title)) || '%'
OR LOWER(TRIM(title)) LIKE '%' || LOWER(TRIM(p.name)) || '%'
LIMIT 1
) as project_slug
FROM partners p
ORDER BY p.display_order ASC
`;
} catch (error) {
console.error('Error fetching partners:', error);
return [];
}
}
export async function getProjectBySlug(slug: string) {
try {
const projects = await sql`SELECT * FROM projects WHERE slug = ${slug} LIMIT 1`;
if (projects.length === 0) return null;
const project = projects[0];
// Fetch next project for the bottom section
const nextProjects = await sql`
SELECT * FROM projects
WHERE created_at < ${project.created_at}
ORDER BY created_at DESC
LIMIT 1
`;
// If no older project, fetch the newest one
let nextProject: any = nextProjects[0] || null;
if (!nextProject) {
const newest = await sql`SELECT * FROM projects ORDER BY created_at DESC LIMIT 1`;
nextProject = newest[0] !== project ? newest[0] : null;
}
return { project, nextProject };
} catch (error) {
console.error('Error fetching project:', error);
return null;
}
}