Let admins unfinalise a cash up from history
Adds POST /api/cashup/:id/unfinalise (admin-only) to revert a finalised cash up back to draft so it can be corrected, plus an Unfinalise button in the history table for admin users.
This commit is contained in:
parent
cbabda81d5
commit
2e9b4a2ca3
2 changed files with 23 additions and 0 deletions
|
|
@ -56,6 +56,13 @@ export function History({ user }: { user: User }) {
|
|||
load()
|
||||
}
|
||||
|
||||
async function unfinalise(id: number) {
|
||||
if (!confirm('Revert this cash up to draft so it can be edited?')) return
|
||||
await api.post(`/cashup/${id}/unfinalise`, {})
|
||||
flash('Reverted to draft.')
|
||||
load()
|
||||
}
|
||||
|
||||
async function bulkFinalize() {
|
||||
if (!selected.size) return
|
||||
if (!confirm(`Finalise ${selected.size} draft(s)?`)) return
|
||||
|
|
@ -155,6 +162,9 @@ export function History({ user }: { user: User }) {
|
|||
{canFinalise && row.status === 'draft' && (
|
||||
<Btn small variant="danger" onClick={() => deleteDraft(row.id)}>Delete</Btn>
|
||||
)}
|
||||
{user.is_admin && row.status === 'final' && (
|
||||
<Btn small variant="ghost" onClick={() => unfinalise(row.id)}>Unfinalise</Btn>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue