Skip to content

Commit

Permalink
Merge pull request #237 from ahsanzizan/main
Browse files Browse the repository at this point in the history
fix: Revalidate organisasi page on update
  • Loading branch information
ahsanzizan authored Jul 10, 2024
2 parents 8a3317f + ef63c1c commit 0d424d0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/actions/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export async function postCreate(

revalidatePath("/berita");
revalidatePath("/admin/posts");
revalidatePath("/organisasi/[period]/[slug]");
revalidatePath("/");

return { message: "Success", result: { id: newPost.id } };
Expand Down Expand Up @@ -144,12 +145,14 @@ export async function postUpdate(
);
if (!update) return { error: true, message: "Gagal update post!" };
revalidatePath("/berita");
revalidatePath("/");
revalidatePath("/admin/posts");
revalidatePath("/organisasi/[period]/[slug]");
revalidatePath(`/admin/posts/[id]`);
return { message: "Success" };
} catch (e) {
console.log(e);
return { error: true, message: "Gagal menambahkan berita!" };
return { error: true, message: "Gagal update berita!" };
}
}

Expand All @@ -165,7 +168,9 @@ export async function updatePostStatus(current_state: boolean, id: string) {
);
revalidatePath("/berita");
revalidatePath("/admin/posts");
revalidatePath("/organisasi/[period]/[slug]");
revalidatePath(`/admin/posts/[id]`, "page");
revalidatePath("/");
return { message: "Berhasil megupdate post!" };
} catch (e) {
console.log(e);
Expand All @@ -179,6 +184,8 @@ export async function postDelete(id: string) {
revalidatePath("/berita");
revalidatePath("/admin/posts");
revalidatePath(`/admin/posts/[id]`);
revalidatePath("/organisasi/[period]/[slug]");
revalidatePath("/");
return { message: "Berhasil menghapus post!" };
} catch (e) {
console.log(e);
Expand Down

0 comments on commit 0d424d0

Please sign in to comment.