Fix all Server Actions imported from dynamic route paths

All admin and student Client Components were importing Server Actions
from paths with dynamic segments ([courseId], [moduleId], [lessonId], [slug]).
This caused "Cannot access toStringTag on the server" RSC crash.

Consolidated all Server Actions into static files under src/lib/actions/:
- course-actions.ts  (modules + enrollment)
- module-actions.ts  (lessons + reorder + move)
- user-actions.ts    (bulk grant / revoke)
- student-actions.ts (progress + homework + comments)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 14:05:26 +05:00
parent 9eb21e3ab4
commit 5dfa79d357
11 changed files with 410 additions and 7 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
import { useState, useTransition } from "react";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { grantAccess, revokeAccess } from "@/app/admin/courses/[courseId]/actions";
import { grantAccess, revokeAccess } from "@/lib/actions/course-actions";
interface Student {
id: string;
+1 -1
View File
@@ -25,7 +25,7 @@ import {
reorderLessons,
toggleLessonPublished,
moveLessonToModule,
} from "@/app/admin/courses/[courseId]/modules/[moduleId]/actions";
} from "@/lib/actions/module-actions";
interface Lesson {
id: string;
+1 -1
View File
@@ -17,7 +17,7 @@ import {
} from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import Link from "next/link";
import { createModule, deleteModule, updateModule, reorderModules } from "@/app/admin/courses/[courseId]/actions";
import { createModule, deleteModule, updateModule, reorderModules } from "@/lib/actions/course-actions";
interface Module {
id: string;
@@ -3,7 +3,7 @@
import { useState, useTransition } from "react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { bulkGrantAccess, revokeUserAccess } from "@/app/admin/users/[userId]/actions";
import { bulkGrantAccess, revokeUserAccess } from "@/lib/actions/user-actions";
interface Course {
id: string;
+1 -1
View File
@@ -1,7 +1,7 @@
"use client";
import { useState, useTransition } from "react";
import { submitHomework } from "@/app/(student)/courses/[slug]/lessons/[lessonId]/homework-actions";
import { submitHomework } from "@/lib/actions/student-actions";
import { AudioRecorder } from "@/components/curator/audio-recorder";
interface HWFile { name: string; url: string; size: number }
+1 -1
View File
@@ -1,7 +1,7 @@
"use client";
import { useState, useTransition } from "react";
import { addComment, deleteComment } from "@/app/(student)/courses/[slug]/lessons/[lessonId]/comment-actions";
import { addComment, deleteComment } from "@/lib/actions/student-actions";
type Comment = {
id: string;
@@ -2,7 +2,7 @@
import { useTransition } from "react";
import { Check } from "lucide-react";
import { toggleLessonProgress } from "@/app/(student)/courses/[slug]/lessons/[lessonId]/actions";
import { toggleLessonProgress } from "@/lib/actions/student-actions";
export function LessonCompleteButton({
lessonId,