Skip to content

Commit 499b8da

Browse files
committed
fix: borrow cache action revalidations
1 parent 3db65e7 commit 499b8da

File tree

6 files changed

+30
-2
lines changed

6 files changed

+30
-2
lines changed

lib/actions/lost-borrow.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export async function lostBorrowAction(
2727
}
2828
return { error: 'failed to mark as lost' }
2929
} finally {
30-
revalidatePath('/admin/borrows')
30+
revalidatePath(`/admin/borrows/${data.id}`)
31+
revalidatePath(`/admin/borrows`)
32+
revalidatePath(`/borrows/${data.id}`)
33+
revalidatePath('/borrows')
34+
revalidatePath('/admin/books')
35+
revalidatePath('/books')
3136
}
3237
}

lib/actions/return-borrow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,10 @@ export async function returnBorrowAction({
3737
return { error: 'failed to return borrow' }
3838
} finally {
3939
revalidatePath(`/admin/borrows/${id}`)
40+
revalidatePath(`/admin/borrows`)
41+
revalidatePath(`/borrows/${id}`)
42+
revalidatePath('/borrows')
43+
revalidatePath('/admin/books')
44+
revalidatePath('/books')
4045
}
4146
}

lib/actions/undo-lost.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,10 @@ export async function undoLostAction(id: string) {
2929
return { error: 'failed to undo lost' }
3030
} finally {
3131
revalidatePath(`/admin/borrows/${id}`)
32+
revalidatePath(`/admin/borrows`)
33+
revalidatePath(`/borrows/${id}`)
34+
revalidatePath('/borrows')
35+
revalidatePath('/admin/books')
36+
revalidatePath('/books')
3237
}
3338
}

lib/actions/undo-return.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ export async function undoReturnAction(id: string) {
2525
}
2626
return { error: 'failed to undo return' }
2727
} finally {
28+
revalidatePath(`/admin/borrows/${id}`)
29+
revalidatePath(`/admin/borrows`)
30+
revalidatePath(`/borrows/${id}`)
2831
revalidatePath('/borrows')
32+
revalidatePath('/admin/books')
33+
revalidatePath('/books')
2934
}
3035
}

lib/actions/update-borrow.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ export async function updateBorrowAction(
2323
return { error: 'failed to update borrow' }
2424
} finally {
2525
revalidatePath(`/admin/borrows/${data.id}`)
26+
revalidatePath(`/admin/borrows`)
27+
revalidatePath(`/borrows/${data.id}`)
28+
revalidatePath('/borrows')
2629
}
2730
}

lib/api/book.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ export const getBook = async (query: GetBookQuery): GetBookResponse => {
4848
url.searchParams.append(key, String(value))
4949
}
5050
})
51-
const response = await fetch(url.toString())
51+
const response = await fetch(url.toString(), {
52+
cache: 'force-cache',
53+
next: {
54+
revalidate: 30,
55+
},
56+
})
5257
return response.json()
5358
}
5459

0 commit comments

Comments
 (0)