/** * Helpers Plugin pirogue-providers. */ import { prisma } from "@/lib/prisma"; export type PirogueProvider = { id: string; name: string; contactEmail: string | null; contactPhone: string | null; rivers: string[]; pricingNote: string | null; description: string | null; active: boolean; }; export async function listActiveProviders(): Promise { const rows = await prisma.pirogueProvider.findMany({ where: { active: true }, orderBy: { name: "asc" }, }); return rows.map((r) => ({ id: r.id, name: r.name, contactEmail: r.contactEmail, contactPhone: r.contactPhone, rivers: r.rivers, pricingNote: r.pricingNote, description: r.description, active: r.active, })); } export async function listProvidersForRiver(river: string): Promise { const all = await listActiveProviders(); return all.filter((p) => p.rivers.some((r) => r.toLowerCase() === river.toLowerCase())); } export const TRANSPORT_MODE_LABEL: Record = { OWNER_PROVIDES: "Le loueur fournit le passeur", SELF_ARRANGE: "À organiser par le voyageur", PARTNER_PROVIDER: "Partenaire référencé", }; export const TRANSPORT_MODE_EMOJI: Record = { OWNER_PROVIDES: "👤", SELF_ARRANGE: "🗺️", PARTNER_PROVIDER: "🤝", };