feat: implement Moving Motivators feature with session management, real-time event handling, and UI components for enhanced user experience

This commit is contained in:
Julien Froidefond
2025-11-28 08:40:39 +01:00
parent a5c17e23f6
commit 448cf61e66
26 changed files with 3191 additions and 183 deletions

View File

@@ -0,0 +1,67 @@
-- CreateTable
CREATE TABLE "MovingMotivatorsSession" (
"id" TEXT NOT NULL PRIMARY KEY,
"title" TEXT NOT NULL,
"participant" TEXT NOT NULL,
"date" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "MovingMotivatorsSession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "MotivatorCard" (
"id" TEXT NOT NULL PRIMARY KEY,
"type" TEXT NOT NULL,
"orderIndex" INTEGER NOT NULL,
"influence" INTEGER NOT NULL DEFAULT 0,
"sessionId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "MotivatorCard_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "MovingMotivatorsSession" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "MMSessionShare" (
"id" TEXT NOT NULL PRIMARY KEY,
"sessionId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"role" TEXT NOT NULL DEFAULT 'EDITOR',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MMSessionShare_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "MovingMotivatorsSession" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "MMSessionShare_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "MMSessionEvent" (
"id" TEXT NOT NULL PRIMARY KEY,
"sessionId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"type" TEXT NOT NULL,
"payload" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MMSessionEvent_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "MovingMotivatorsSession" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "MMSessionEvent_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateIndex
CREATE INDEX "MovingMotivatorsSession_userId_idx" ON "MovingMotivatorsSession"("userId");
-- CreateIndex
CREATE INDEX "MotivatorCard_sessionId_idx" ON "MotivatorCard"("sessionId");
-- CreateIndex
CREATE UNIQUE INDEX "MotivatorCard_sessionId_type_key" ON "MotivatorCard"("sessionId", "type");
-- CreateIndex
CREATE INDEX "MMSessionShare_sessionId_idx" ON "MMSessionShare"("sessionId");
-- CreateIndex
CREATE INDEX "MMSessionShare_userId_idx" ON "MMSessionShare"("userId");
-- CreateIndex
CREATE UNIQUE INDEX "MMSessionShare_sessionId_userId_key" ON "MMSessionShare"("sessionId", "userId");
-- CreateIndex
CREATE INDEX "MMSessionEvent_sessionId_createdAt_idx" ON "MMSessionEvent"("sessionId", "createdAt");

View File

@@ -17,6 +17,10 @@ model User {
sessions Session[]
sharedSessions SessionShare[]
sessionEvents SessionEvent[]
// Moving Motivators relations
motivatorSessions MovingMotivatorsSession[]
sharedMotivatorSessions MMSessionShare[]
motivatorSessionEvents MMSessionEvent[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
@@ -122,3 +126,77 @@ model SessionEvent {
@@index([sessionId, createdAt])
}
// ============================================
// Moving Motivators Workshop
// ============================================
enum MotivatorType {
STATUS // Statut
POWER // Pouvoir
ORDER // Ordre
ACCEPTANCE // Acceptation
HONOR // Honneur
MASTERY // Maîtrise
SOCIAL // Relations sociales
FREEDOM // Liberté
CURIOSITY // Curiosité
PURPOSE // But
}
model MovingMotivatorsSession {
id String @id @default(cuid())
title String
participant String // Nom du participant
date DateTime @default(now())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
cards MotivatorCard[]
shares MMSessionShare[]
events MMSessionEvent[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
}
model MotivatorCard {
id String @id @default(cuid())
type MotivatorType
orderIndex Int // Position horizontale (1-10, importance)
influence Int @default(0) // Position verticale (-3 à +3)
sessionId String
session MovingMotivatorsSession @relation(fields: [sessionId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([sessionId, type]) // Une seule carte par type par session
@@index([sessionId])
}
model MMSessionShare {
id String @id @default(cuid())
sessionId String
session MovingMotivatorsSession @relation(fields: [sessionId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
role ShareRole @default(EDITOR)
createdAt DateTime @default(now())
@@unique([sessionId, userId])
@@index([sessionId])
@@index([userId])
}
model MMSessionEvent {
id String @id @default(cuid())
sessionId String
session MovingMotivatorsSession @relation(fields: [sessionId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
type String // CARD_MOVED, CARD_INFLUENCE_CHANGED, etc.
payload String // JSON payload
createdAt DateTime @default(now())
@@index([sessionId, createdAt])
}