feat(web): add submission server actions for cache management

Add server actions that can be called from client components to trigger cache revalidation after submission status changes. Provides revalidateCommunitySubmissions for community page updates and revalidateAllSubmissions for dashboard and community pages
This commit is contained in:
Thomas Camlong
2025-10-01 18:23:12 +02:00
parent c0851a73c7
commit d221fb5c79

View File

@@ -0,0 +1,37 @@
"use server"
import { revalidateCommunityPage, revalidateSubmissions } from "@/lib/revalidate"
/**
* Server actions for submission management
* These can be called from client components to trigger cache revalidation
*/
/**
* Revalidate the community page after a submission status change
* Call this after approving, rejecting, or adding a submission to the collection
*/
export async function revalidateCommunitySubmissions() {
try {
await revalidateCommunityPage()
return { success: true }
} catch (error) {
console.error("Error revalidating community page:", error)
return { success: false, error: "Failed to revalidate" }
}
}
/**
* Revalidate all submission-related pages
* Use this for actions that affect both the dashboard and community pages
*/
export async function revalidateAllSubmissions() {
try {
await revalidateSubmissions()
return { success: true }
} catch (error) {
console.error("Error revalidating submissions:", error)
return { success: false, error: "Failed to revalidate" }
}
}