store/resources/js/components/owner-verification/OwnerVerificationRowActions.vue
Yoga Pangestu 9539ff7042 refactor: remove StockController and related stock verification logic
- Deleted `data-table-actions.vue` component as it is no longer needed.
- Removed `CuttingResultPriceItem` type and related properties from `cutting.ts`.
- Updated routes in `web.php` to eliminate stock verification routes and permissions.
- Removed `StockTest.php` file and its associated tests for stock verification and management.
- Adjusted `CuttingTest.php` to reflect changes in cutting results handling and removed references to product variants.
2026-07-19 17:29:19 +07:00

113 lines
3.4 KiB
Vue

<script setup lang="ts">
import { useForm } from '@inertiajs/vue3';
import { X } from '@lucide/vue';
import { computed, ref } from 'vue';
import { toast } from 'vue-sonner';
import { RowApproveAction, RowRejectAction } from '@/components/button';
import { Button } from '@/components/ui/button';
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/components/ui/dialog';
import {
Field,
FieldError,
FieldLabel,
} from '@/components/ui/field';
import { Textarea } from '@/components/ui/textarea';
import { useCan } from '@/composables/useCan';
import { approve_request, reject_request } from '@/routes/admin/manage/owner_verifications';
const props = defineProps<{
type: 'request';
id: number;
}>();
const { can } = useCan();
const rejectDialogOpen = ref(false);
const approveForm = useForm({});
const rejectForm = useForm({
reason: '',
});
const approveUrl = approve_request.url(props.id);
const rejectUrl = reject_request.url(props.id);
const canApprove = computed(() => can('owner_verifications.verify'));
const canReject = computed(() => can('owner_verifications.reject'));
function submitApprove() {
approveForm
.post(approveUrl, {
preserveScroll: true,
onError: (errors: Record<string, string>) => {
const firstError = Object.values(errors)[0];
if (firstError) {
toast.error(firstError);
}
},
});
}
function submitReject() {
rejectForm
.post(rejectUrl, {
preserveScroll: true,
onSuccess: () => {
rejectDialogOpen.value = false;
rejectForm.reset();
},
onError: (errors: Record<string, string>) => {
const firstError = Object.values(errors)[0];
if (firstError) {
toast.error(firstError);
}
},
});
}
</script>
<template>
<template v-if="canApprove">
<RowApproveAction size="sm" tooltip="Setujui" :disabled="approveForm.processing" @click="submitApprove" />
</template>
<template v-if="canReject">
<RowRejectAction size="sm" tooltip="Tolak" :disabled="rejectForm.processing" @click="rejectDialogOpen = true" />
</template>
<Dialog v-model:open="rejectDialogOpen">
<DialogContent class="sm:max-w-lg">
<DialogHeader>
<DialogTitle>Tolak Verifikasi</DialogTitle>
</DialogHeader>
<div class="space-y-4">
<Field>
<FieldLabel for="owner-verification-reject-reason" required>Alasan Penolakan</FieldLabel>
<Textarea id="owner-verification-reject-reason" v-model="rejectForm.reason"
placeholder="Jelaskan alasan penolakan..." rows="3" />
<FieldError :errors="rejectForm.errors.reason ? [rejectForm.errors.reason] : []" />
</Field>
</div>
<DialogFooter>
<Button type="button" variant="outline" @click="rejectDialogOpen = false">
Batal
</Button>
<Button type="button" variant="destructive" :disabled="rejectForm.processing" @click="submitReject">
<X class="size-4" />
Tolak
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</template>