mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2025-10-27 21:49:04 +08:00
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:
37
web/src/app/actions/submissions.ts
Normal file
37
web/src/app/actions/submissions.ts
Normal 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" }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user