feat: add certificate gallery and certifications section components
- Implemented CertificateGallery component to display certification images in a gallery format. - Created CertificationsSection component to showcase certifications with titles and descriptions. - Enhanced Gallery component to support animations and keyboard navigation. - Introduced Select component for dropdown selection with images. - Added utility functions for API responses and pagination handling. - Implemented localization functions for text and content. - Created a custom hook for detecting clicks outside of a component.
This commit is contained in:
@@ -1,28 +1,29 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { cookies } from 'next/headers';
|
||||
import { projects } from '../data';
|
||||
import { getLocaleFromCookies } from '@/lib/locale';
|
||||
import { localizeContent, localizeText } from '@/lib/domain';
|
||||
import { notFound, ok } from '@/lib/api-response';
|
||||
|
||||
export async function GET(request: Request, context: any) {
|
||||
const params = await context.params;
|
||||
const projectId = params.id;
|
||||
type RouteContext = {
|
||||
params: {
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
|
||||
const cookieStore = await cookies();
|
||||
const lang = cookieStore.get('locale')?.value || 'en';
|
||||
export async function GET(request: Request, context: RouteContext) {
|
||||
const projectId = context.params.id;
|
||||
|
||||
const locale = await getLocaleFromCookies();
|
||||
|
||||
let project = projects.find((project) => project.id === projectId);
|
||||
if (!project) {
|
||||
return NextResponse.json({ error: 'Not found' }, { status: 404 });
|
||||
return notFound();
|
||||
}
|
||||
|
||||
if (lang === 'fa') {
|
||||
project = {
|
||||
...project,
|
||||
title: project.fa_title || project.title,
|
||||
content: project.fa_content || project.content,
|
||||
};
|
||||
}
|
||||
project = {
|
||||
...project,
|
||||
title: localizeText(locale, project.title, project.fa_title),
|
||||
content: localizeContent(locale, project.content, project.fa_content),
|
||||
};
|
||||
|
||||
return NextResponse.json({
|
||||
data: project,
|
||||
});
|
||||
return ok(project);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user