Checkpoint: - Bouton crayon dans MesEtablissements ouvre un Dialog modal (sans mode édition préalable)
- Page Solutions Logicielles : bouton Ajouter, crayon Modifier, poubelle Supprimer (gestionnaires uniquement) - Lien espace adhérent FEHAP mis à jour vers l'URL exacte - Serveur redémarré, cache esbuild purgé, 0 erreur TypeScript
This commit is contained in:
14
server/db.ts
14
server/db.ts
@@ -752,3 +752,17 @@ export async function getToutesLesSolutionsGroupees() {
|
||||
|
||||
return Array.from(map.values());
|
||||
}
|
||||
|
||||
export async function updateSolution(id: number, nom: string, editeurId: number, blocFonctionnelId: number | null) {
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("DB unavailable");
|
||||
await db.update(solutions).set({ nom, editeurId, blocFonctionnelId }).where(eq(solutions.id, id));
|
||||
return { id };
|
||||
}
|
||||
|
||||
export async function deleteSolution(id: number) {
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("DB unavailable");
|
||||
await db.delete(solutions).where(eq(solutions.id, id));
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
createEditeur,
|
||||
createLocalUser,
|
||||
createSolution,
|
||||
updateSolution,
|
||||
deleteSolution,
|
||||
deleteLogicielEtablissement,
|
||||
deleteUser,
|
||||
getAllDemandes,
|
||||
@@ -150,6 +152,23 @@ export const appRouter = router({
|
||||
const isGestionnaire = ctx.user.sonumRole === "gestionnaire" || ctx.user.role === "admin";
|
||||
return createSolution(input.nom, input.editeurId, input.blocFonctionnelId, isGestionnaire);
|
||||
}),
|
||||
updateSolution: protectedProcedure
|
||||
.input(z.object({
|
||||
id: z.number().int(),
|
||||
nom: z.string().min(1),
|
||||
editeurId: z.number().int(),
|
||||
blocFonctionnelId: z.number().int().optional().nullable(),
|
||||
}))
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
if (ctx.user.sonumRole !== "gestionnaire" && ctx.user.role !== "admin") throw new TRPCError({ code: "FORBIDDEN" });
|
||||
return updateSolution(input.id, input.nom, input.editeurId, input.blocFonctionnelId ?? null);
|
||||
}),
|
||||
deleteSolution: protectedProcedure
|
||||
.input(z.object({ id: z.number().int() }))
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
if (ctx.user.sonumRole !== "gestionnaire" && ctx.user.role !== "admin") throw new TRPCError({ code: "FORBIDDEN" });
|
||||
return deleteSolution(input.id);
|
||||
}),
|
||||
}),
|
||||
|
||||
// ─── Établissements ────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user