feat: Show confirm/decline buttons for Chef/Disponent
- Management can now accept/decline on behalf of employees - Buttons always visible for management roles - Visual feedback for already confirmed/declined status
This commit is contained in:
@@ -105,14 +105,14 @@ async function updateStatus(status: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function confirmAssignment(confirm: boolean) {
|
async function confirmAssignment(userId: string, confirm: boolean) {
|
||||||
try {
|
try {
|
||||||
await api.put(`/orders/${route.params.id}/assignment`, {
|
await api.put(`/orders/${route.params.id}/assignment/${userId}`, {
|
||||||
status: confirm ? 'confirmed' : 'declined'
|
status: confirm ? 'confirmed' : 'declined'
|
||||||
})
|
})
|
||||||
const myAssignment = assignments.value.find(a => a.user_id === authStore.user?.id)
|
const assignment = assignments.value.find(a => a.user_id === userId)
|
||||||
if (myAssignment) {
|
if (assignment) {
|
||||||
myAssignment.status = confirm ? 'confirmed' : 'declined'
|
assignment.status = confirm ? 'confirmed' : 'declined'
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert(e instanceof Error ? e.message : t('messages.error'))
|
alert(e instanceof Error ? e.message : t('messages.error'))
|
||||||
@@ -258,10 +258,20 @@ const spotsRemaining = computed(() => {
|
|||||||
{{ getStatusLabel(assignment.status) }}
|
{{ getStatusLabel(assignment.status) }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<!-- Confirm/Decline buttons for assigned user -->
|
<!-- Confirm/Decline buttons - for assigned user OR management -->
|
||||||
<template v-if="assignment.user_id === authStore.user?.id && assignment.status === 'pending'">
|
<template v-if="assignment.status === 'pending' || authStore.canManageOrders">
|
||||||
<button class="btn btn-success text-sm" @click="confirmAssignment(true)">✓</button>
|
<button
|
||||||
<button class="btn btn-danger text-sm" @click="confirmAssignment(false)">✗</button>
|
class="btn btn-success text-sm"
|
||||||
|
:class="{ 'opacity-50': assignment.status === 'confirmed' }"
|
||||||
|
@click="confirmAssignment(assignment.user_id, true)"
|
||||||
|
:title="assignment.status === 'confirmed' ? 'Bereits bestätigt' : 'Bestätigen'"
|
||||||
|
>✓</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-danger text-sm"
|
||||||
|
:class="{ 'opacity-50': assignment.status === 'declined' }"
|
||||||
|
@click="confirmAssignment(assignment.user_id, false)"
|
||||||
|
:title="assignment.status === 'declined' ? 'Bereits abgelehnt' : 'Ablehnen'"
|
||||||
|
>✗</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Remove button for management -->
|
<!-- Remove button for management -->
|
||||||
|
|||||||
Reference in New Issue
Block a user