Plans: wznawianie planu tylko dla wlasciciela (usuniete akcje trenera)
This commit is contained in:
@@ -429,12 +429,13 @@ export async function completePlan(prisma: PrismaClient, planId: string, userId:
|
||||
* pomyłek (np. błędnie oznaczony plan) — dni SKIPPED nie są wskrzeszane, a plan
|
||||
* bez dni zaplanowanych zostanie ponownie ukończony przez scheduler, gdy tylko
|
||||
* wszystkie dni pozostaną domknięte.
|
||||
* Wznowić może wyłącznie właściciel planu (trener nie ma takiej akcji).
|
||||
*/
|
||||
export async function reopenPlan(prisma: PrismaClient, planId: string, userId: string) {
|
||||
const plan = await assertPlanAccess(prisma, planId, userId);
|
||||
const plan = await assertPlanOwner(prisma, planId, userId);
|
||||
if (plan.status !== 'COMPLETED' && plan.status !== 'ABANDONED')
|
||||
throw badRequest('Only a completed or abandoned plan can be reopened');
|
||||
// Jeden aktywny plan dotyczy właściciela (inicjatorem może być trener).
|
||||
// Jeden aktywny plan dotyczy właściciela.
|
||||
// Pre-check + częściowy indeks unikalny (TrainingPlan_userId_active_key)
|
||||
// rozstrzyga równoległe wznowienia/aktywacje.
|
||||
const otherActive = await prisma.trainingPlan.findFirst({
|
||||
|
||||
Reference in New Issue
Block a user