mirror of
https://github.com/R0m1k3/PleinR.git
synced 2026-10-11 17:27:54 +02:00
Backend: commune en menu deroulant (communes du Bassin de Pompey)
- Constante BASSIN_POMPEY_COMMUNES (13 communes) dans src/lib/communes.ts - Champ commune devenu un select dans : ajout adherent, edition fiche, espace adherent. communeOptions() conserve une valeur existante hors liste. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
7bdb234475
commit
b5a606e945
4 files changed
+51
-3
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { BASSIN_POMPEY_COMMUNES } from "@/lib/communes";
|
||||
import { addMember } from "../actions";
|
||||
|
||||
export function AddMemberPanel({
|
||||
@@ -56,7 +57,14 @@ export function AddMemberPanel({
|
||||
</div>
|
||||
<div>
|
||||
<label className="field-label">Commune</label>
|
||||
<input name="city" placeholder="ex : Pompey" className="field" />
|
||||
<select name="city" className="field" defaultValue="">
|
||||
<option value="">—</option>
|
||||
{BASSIN_POMPEY_COMMUNES.map((c) => (
|
||||
<option key={c} value={c}>
|
||||
{c}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="field-label">Statut</label>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { db } from "@/db";
|
||||
import { categories, members, users } from "@/db/schema";
|
||||
import { can } from "@/lib/rbac";
|
||||
import { ImageField } from "@/components/ImageField";
|
||||
import { communeOptions } from "@/lib/communes";
|
||||
import { deleteMember, resetMemberPassword, updateMember } from "../../actions";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -93,7 +94,14 @@ export default async function EditMemberPage({
|
||||
</div>
|
||||
<div>
|
||||
<label className="field-label">Commune</label>
|
||||
<input name="city" defaultValue={member.city ?? ""} className="field" />
|
||||
<select name="city" className="field" defaultValue={member.city ?? ""}>
|
||||
<option value="">—</option>
|
||||
{communeOptions(member.city).map((c) => (
|
||||
<option key={c} value={c}>
|
||||
{c}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="field-label">Adresse</label>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { auth } from "@/auth";
|
||||
import { db } from "@/db";
|
||||
import { categories, members, promotions, type Member } from "@/db/schema";
|
||||
import { ImageField } from "@/components/ImageField";
|
||||
import { communeOptions } from "@/lib/communes";
|
||||
import { updateOwnProfile } from "../actions";
|
||||
import { MemberSpaceForm } from "./MemberSpaceForm";
|
||||
|
||||
@@ -96,7 +97,14 @@ export default async function EspacePage() {
|
||||
</div>
|
||||
<div>
|
||||
<label className="field-label">Commune</label>
|
||||
<input name="city" defaultValue={profile.city ?? ""} className="field" />
|
||||
<select name="city" className="field" defaultValue={profile.city ?? ""}>
|
||||
<option value="">—</option>
|
||||
{communeOptions(profile.city).map((c) => (
|
||||
<option key={c} value={c}>
|
||||
{c}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="field-label">Adresse</label>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Communes de la Communauté de communes du Bassin de Pompey.
|
||||
export const BASSIN_POMPEY_COMMUNES = [
|
||||
"Bouxières-aux-Dames",
|
||||
"Champigneulles",
|
||||
"Custines",
|
||||
"Faulx",
|
||||
"Frouard",
|
||||
"Lay-Saint-Christophe",
|
||||
"Liverdun",
|
||||
"Malleloy",
|
||||
"Marbache",
|
||||
"Millery",
|
||||
"Montenoy",
|
||||
"Pompey",
|
||||
"Saizerais",
|
||||
] as const;
|
||||
|
||||
// Liste d'options incluant une valeur courante hors liste (pour ne pas la perdre).
|
||||
export function communeOptions(current?: string | null): string[] {
|
||||
const list = [...BASSIN_POMPEY_COMMUNES] as string[];
|
||||
const c = (current ?? "").trim();
|
||||
if (c && !list.includes(c)) list.unshift(c);
|
||||
return list;
|
||||
}
|
||||
Reference in new issue
Block a user