refactor(actions): 组 A 模块迁移至 invalidateFor(users/school/textbooks/questions/course-plans/standards/scheduling/audit/onboarding/invitation-codes/proctoring/i18n)
This commit is contained in:
@@ -5,7 +5,7 @@ import { Permissions } from "@/shared/types/permissions"
|
||||
import { CreateQuestionSchema } from "./schema"
|
||||
import type { CreateQuestionInput } from "./schema"
|
||||
import type { ActionState } from "@/shared/types/action-state"
|
||||
import { revalidatePath } from "next/cache"
|
||||
import { invalidateFor } from "@/shared/lib/cache"
|
||||
import { z } from "zod"
|
||||
import {
|
||||
createQuestionWithRelations,
|
||||
@@ -68,8 +68,7 @@ export async function createQuestionAction(
|
||||
|
||||
trackQuestionCreated(questionId, input.type, input.difficulty)
|
||||
|
||||
revalidatePath("/teacher/questions")
|
||||
revalidatePath("/admin/questions")
|
||||
await invalidateFor("questions.create")
|
||||
|
||||
return {
|
||||
success: true,
|
||||
@@ -117,8 +116,7 @@ export async function updateQuestionAction(
|
||||
|
||||
trackQuestionUpdated(id, updateData.type, updateData.difficulty)
|
||||
|
||||
revalidatePath("/teacher/questions")
|
||||
revalidatePath("/admin/questions")
|
||||
await invalidateFor("questions.update")
|
||||
|
||||
return { success: true, message: "Question updated successfully", data: id }
|
||||
} catch (e) {
|
||||
@@ -143,8 +141,7 @@ export async function deleteQuestionAction(
|
||||
|
||||
trackQuestionDeleted(questionId)
|
||||
|
||||
revalidatePath("/teacher/questions")
|
||||
revalidatePath("/admin/questions")
|
||||
await invalidateFor("questions.delete")
|
||||
|
||||
return { success: true, message: "Question deleted successfully", data: questionId }
|
||||
} catch (e) {
|
||||
@@ -190,8 +187,7 @@ export async function deleteQuestionsBatchAction(
|
||||
trackQuestionDeleted(id)
|
||||
}
|
||||
|
||||
revalidatePath("/teacher/questions")
|
||||
revalidatePath("/admin/questions")
|
||||
await invalidateFor("questions.deleteBatch")
|
||||
|
||||
return { success: true, message: "Batch delete completed", data: { deleted: deletedCount } }
|
||||
} catch (e) {
|
||||
@@ -369,8 +365,7 @@ export async function importQuestionsAction(
|
||||
trackQuestionCreated(createdIds[i], item.type, item.difficulty)
|
||||
}
|
||||
|
||||
revalidatePath("/teacher/questions")
|
||||
revalidatePath("/admin/questions")
|
||||
await invalidateFor("questions.import")
|
||||
|
||||
return { success: true, message: "Import completed", data: { imported: createdIds.length } }
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user