Grapevine_Disease_Detection/vineye-admin/app/api/mobile/guides/[slug]/route.ts
Yanis 720dd34fdd add MyPlantsScreen + ScanDetailScreen + enriched admin + API mobile + project summary
Mobile:
- Replace LibraryScreen with MyPlantsScreen (date-grouped scan list, swipe actions, search, pull-to-refresh)
- Add ScanDetailScreen (immersive hero, confidence bar, cepage card, share/delete)
- Add DiseaseDetailScreen + GuideDetailScreen (hero pattern, animated entry)
- Add useScanDetail, useHistory (useCallback fix), dateGrouping utility
- Connect diseases/guides to admin API with cache + offline fallback
- Add NetworkContext, ToastContext, Skeleton loading components
- Extend ScanRecord type (isFavorite, location)
- Full i18n FR/EN for all new screens

Admin (vineye-admin):
- Enrich Disease/Guide Prisma schema (timeline, conditions, actions, sections)
- Enriched disease-form (7 sections) + guide-form (structured sections editor)
- Add mobile public API endpoints (diseases, guides by slug)
- Add Prisma migration + enriched seed data
- UI polish: sidebar, login, layout updates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 03:19:39 +02:00

43 lines
1 KiB
TypeScript

import { NextRequest } from "next/server";
import { prisma } from "@/lib/prisma";
const CORS_HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
"X-API-Version": "1.0",
"Cache-Control": "public, max-age=3600",
};
export async function OPTIONS() {
return new Response(null, { status: 204, headers: CORS_HEADERS });
}
export async function GET(
_request: NextRequest,
{ params }: { params: Promise<{ slug: string }> }
) {
const { slug } = await params;
const guide = await prisma.guide.findUnique({
where: { slug },
include: {
sections: { orderBy: { order: "asc" } },
},
});
if (!guide || !guide.published) {
return Response.json(
{ success: false, error: "Guide introuvable" },
{ status: 404, headers: CORS_HEADERS },
);
}
const { published: _, updatedAt: __, ...data } = guide;
return Response.json(
{ success: true, data },
{ headers: CORS_HEADERS },
);
}