Modèle PirogueProvider (id, name, contacts, fleuves, tarif, description) + enum TransportMode (OWNER_PROVIDES, SELF_ARRANGE, PARTNER_PROVIDER) sur Carbet + relation Carbet → PirogueProvider (nullable, ondelete:SetNull) Composants : - PirogueTransportBlock (server, gated par plugin) sur fiche carbet : affiche le mode + provider partenaire avec contacts/tarif/description - Page publique /partenaires-pirogue : liste des partenaires actifs Seed onEnable : - 3 partenaires démo (Pirogues du Maroni, Approuague Aventures, Oyapock Frontière) avec tarifs estimatifs et fleuves desservis réels - Attribution aux 6 carbets démo : · Awara (Maroni), Maripa (Approuague), Paripou (Oyapock) → PARTNER_PROVIDER · Wapa (Comté), Mahury CE → OWNER_PROVIDES · Kourou Couleuvre → SELF_ARRANGE onDisable désactive les partenaires démo et détache les carbets démo.
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
/**
|
|
* 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<PirogueProvider[]> {
|
|
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<PirogueProvider[]> {
|
|
const all = await listActiveProviders();
|
|
return all.filter((p) => p.rivers.some((r) => r.toLowerCase() === river.toLowerCase()));
|
|
}
|
|
|
|
export const TRANSPORT_MODE_LABEL: Record<string, string> = {
|
|
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<string, string> = {
|
|
OWNER_PROVIDES: "👤",
|
|
SELF_ARRANGE: "🗺️",
|
|
PARTNER_PROVIDER: "🤝",
|
|
};
|