From d221fb5c79d6ac2779b17e1e1249b07f1db3535c Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Wed, 1 Oct 2025 18:23:12 +0200 Subject: [PATCH] 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 --- web/src/app/actions/submissions.ts | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 web/src/app/actions/submissions.ts diff --git a/web/src/app/actions/submissions.ts b/web/src/app/actions/submissions.ts new file mode 100644 index 00000000..29fbc9f1 --- /dev/null +++ b/web/src/app/actions/submissions.ts @@ -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" } + } +} +