Compare commits
No commits in common. "452c1a4209a6d86bec289234cf6212291b3e8aae" and "c2360ef1ed0fe1798f9db85635bd84070da5b553" have entirely different histories.
452c1a4209
...
c2360ef1ed
@ -228,13 +228,6 @@ public function createVariantAndDraft(array $validated, User $user): array
|
||||
|
||||
$price->setAttribute('images', MediaPresenter::collection($price, 'images'));
|
||||
|
||||
$this->pushNotificationService->sendToRoles(
|
||||
'🆕 Varian Baru Ditambahkan',
|
||||
"{$user->name} menambahkan varian \"{$price->variant}\" ke bahan baku \"{$rawMaterial->name}\".",
|
||||
['owner', 'developer', 'direktur'],
|
||||
route('admin.master.raw_materials.index', ['search' => $rawMaterial->name]),
|
||||
);
|
||||
|
||||
return [
|
||||
'id' => $price->id,
|
||||
'variant' => $price->variant,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { router, usePage } from '@inertiajs/vue3';
|
||||
import { Home, LogOut, User } from '@lucide/vue';
|
||||
import { LogOut, User } from '@lucide/vue';
|
||||
import { computed } from 'vue';
|
||||
import NotificationBell from '@/components/NotificationBell.vue';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
@ -34,9 +34,6 @@ function logout() {
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="/" class="flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground" title="Halaman Depan">
|
||||
<Home class="size-4" />
|
||||
</a>
|
||||
<NotificationBell />
|
||||
<DropdownMenu v-if="user">
|
||||
<DropdownMenuTrigger as-child>
|
||||
|
||||
@ -21,16 +21,13 @@ const props = withDefaults(
|
||||
url: string | null;
|
||||
urls?: string[];
|
||||
title?: string;
|
||||
titles?: string[];
|
||||
}>(),
|
||||
{
|
||||
urls: () => [],
|
||||
title: 'Pratinjau Foto',
|
||||
titles: () => [],
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
const activeUrl = ref<string | null>(props.url);
|
||||
|
||||
watch(
|
||||
@ -66,14 +63,6 @@ const currentIndex = computed(() => {
|
||||
|
||||
const hasMultiple = computed(() => allUrls.value.length > 1);
|
||||
|
||||
const activeTitle = computed(() => {
|
||||
if (props.titles && props.titles.length > 0 && currentIndex.value >= 0) {
|
||||
return props.titles[currentIndex.value] ?? props.title ?? 'Pratinjau Foto';
|
||||
}
|
||||
|
||||
return props.title ?? 'Pratinjau Foto';
|
||||
});
|
||||
|
||||
function nextImage() {
|
||||
if (!hasMultiple.value) {
|
||||
return;
|
||||
@ -141,7 +130,7 @@ function handleTouchEnd(e: TouchEvent) {
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="sm:max-w-2xl p-4 overflow-hidden gap-4">
|
||||
<DialogHeader class="pb-2 border-b">
|
||||
<DialogTitle class="text-base font-semibold">{{ activeTitle }}</DialogTitle>
|
||||
<DialogTitle class="text-base font-semibold">{{ title ?? 'Pratinjau Gambar' }}</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div class="relative flex items-center justify-center min-h-[300px] select-none"
|
||||
|
||||
@ -14,7 +14,6 @@ const props = defineProps<{
|
||||
maxVisible?: number;
|
||||
title?: string;
|
||||
allUrls?: string[];
|
||||
allTitles?: string[];
|
||||
}>();
|
||||
|
||||
const previewOpen = ref(false);
|
||||
@ -121,5 +120,5 @@ function openGallery() {
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<MediaPreviewDialog v-model:open="previewOpen" v-model:url="previewUrl" :urls="allUrls ?? items.map(item => item.url)" :title="title" :titles="allTitles" @close="onPreviewClose" />
|
||||
<MediaPreviewDialog v-model:open="previewOpen" v-model:url="previewUrl" :urls="allUrls ?? items.map(item => item.url)" :title="title" @close="onPreviewClose" />
|
||||
</template>
|
||||
|
||||
@ -150,7 +150,7 @@ const placeholder = computed(() =>
|
||||
<FieldSet class="grid gap-4">
|
||||
<Field>
|
||||
<FieldLabel for="cash-amount" required>Jumlah</FieldLabel>
|
||||
<RupiahInput id="cash-amount" v-model="form.amount" />
|
||||
<RupiahInput id="cash-amount" v-model="form.amount" autofocus />
|
||||
<FieldError :errors="formErrors(form, 'amount')" />
|
||||
</Field>
|
||||
<Field>
|
||||
|
||||
@ -118,7 +118,7 @@ function submit() {
|
||||
<FieldSet class="grid gap-4">
|
||||
<Field>
|
||||
<FieldLabel for="employee-advance-amount" required>Jumlah</FieldLabel>
|
||||
<RupiahInput id="employee-advance-amount" v-model="form.amount" />
|
||||
<RupiahInput id="employee-advance-amount" v-model="form.amount" autofocus />
|
||||
<FieldError :errors="formErrors(form, 'amount')" />
|
||||
</Field>
|
||||
<Field>
|
||||
|
||||
@ -77,7 +77,7 @@ function submit() {
|
||||
<Field>
|
||||
<FieldLabel for="reject-reason" required>Alasan Penolakan</FieldLabel>
|
||||
<Textarea id="reject-reason" v-model="form.reason" placeholder="Tuliskan alasan penolakan"
|
||||
rows="3" :maxlength="FIELD_LIMITS.reason" />
|
||||
rows="3" autofocus :maxlength="FIELD_LIMITS.reason" />
|
||||
<FieldError :errors="formErrors(form, 'reason')" />
|
||||
</Field>
|
||||
</FieldSet>
|
||||
|
||||
@ -125,7 +125,7 @@ function submit() {
|
||||
<FieldSet class="grid gap-4">
|
||||
<Field>
|
||||
<FieldLabel for="expense-amount" required>Jumlah</FieldLabel>
|
||||
<RupiahInput id="expense-amount" v-model="form.amount" />
|
||||
<RupiahInput id="expense-amount" v-model="form.amount" autofocus />
|
||||
<FieldError :errors="formErrors(form, 'amount')" />
|
||||
</Field>
|
||||
<Field>
|
||||
|
||||
@ -98,7 +98,7 @@ function submit() {
|
||||
</p>
|
||||
<Field>
|
||||
<FieldLabel for="leave-start-date" required>Tanggal Mulai</FieldLabel>
|
||||
<DatePicker id="leave-start-date" v-model="form.start_date" />
|
||||
<DatePicker id="leave-start-date" v-model="form.start_date" autofocus />
|
||||
<FieldError :errors="formErrors(form, 'start_date')" />
|
||||
</Field>
|
||||
<Field>
|
||||
|
||||
@ -77,7 +77,7 @@ function submit() {
|
||||
<Field>
|
||||
<FieldLabel for="reject-reason" required>Alasan Penolakan</FieldLabel>
|
||||
<Textarea id="reject-reason" v-model="form.reason"
|
||||
placeholder="Masukkan alasan penolakan" rows="3"
|
||||
placeholder="Masukkan alasan penolakan" rows="3" autofocus
|
||||
:maxlength="FIELD_LIMITS.reason" />
|
||||
<FieldError :errors="formErrors(form, 'reason')" />
|
||||
</Field>
|
||||
|
||||
@ -68,7 +68,7 @@ function submitReject() {
|
||||
<Field>
|
||||
<FieldLabel for="cutting-reject-reason" required>Alasan Penolakan</FieldLabel>
|
||||
<Textarea id="cutting-reject-reason" v-model="rejectForm.reason"
|
||||
placeholder="Masukkan alasan penolakan" rows="3"
|
||||
placeholder="Masukkan alasan penolakan" rows="3" autofocus
|
||||
:maxlength="FIELD_LIMITS.reason" />
|
||||
<FieldError :errors="rejectForm.errors.reason
|
||||
? [rejectForm.errors.reason]
|
||||
|
||||
@ -101,7 +101,7 @@ async function submit() {
|
||||
v-model="form.name"
|
||||
type="text"
|
||||
placeholder="Masukkan nama pelanggan"
|
||||
|
||||
autofocus
|
||||
:maxlength="FIELD_LIMITS.name"
|
||||
/>
|
||||
<FieldError
|
||||
|
||||
@ -5,12 +5,6 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Empty,
|
||||
EmptyDescription,
|
||||
EmptyHeader,
|
||||
EmptyTitle,
|
||||
} from '@/components/ui/empty';
|
||||
import { formatRupiah } from '@/lib/rupiah';
|
||||
import type { OrderCartItem } from '@/types/order';
|
||||
|
||||
@ -21,40 +15,18 @@ defineProps<{
|
||||
totalAmount: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
remove: [index: number];
|
||||
'adjust-quantity': [index: number, delta: number];
|
||||
'set-quantity': [index: number, value: string];
|
||||
}>();
|
||||
|
||||
const open = defineModel<boolean>('open', { required: true });
|
||||
|
||||
function onQtyInput(index: number, event: Event) {
|
||||
emit('set-quantity', index, (event.target as HTMLInputElement).value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="sm:max-w-lg min-w-0 max-h-[90dvh] flex flex-col overflow-y-auto">
|
||||
<DialogContent class="sm:max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Detail Keranjang</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div v-if="cart.length === 0" class="rounded-lg border border-dashed text-center text-sm text-muted-foreground">
|
||||
<Empty>
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Keranjang masih kosong</EmptyTitle>
|
||||
<EmptyDescription>
|
||||
Pilih varian produk untuk menambahkan ke keranjang.
|
||||
</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
</div>
|
||||
|
||||
<div v-else class="scrollbar-thin max-h-96 space-y-3 overflow-y-auto overscroll-y-contain">
|
||||
<div class="scrollbar-thin max-h-96 space-y-3 overflow-y-auto overscroll-y-contain">
|
||||
<div
|
||||
v-for="(item, index) in cart"
|
||||
v-for="item in cart"
|
||||
:key="`detail-${item.product_variant_id}-${item.stock_quality}`"
|
||||
class="rounded-lg border p-3"
|
||||
>
|
||||
@ -66,50 +38,15 @@ function onQtyInput(index: number, event: Event) {
|
||||
· {{ item.stock_quality_label ?? stockQualityLabel(item.stock_quality) }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex size-7 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive"
|
||||
@click="emit('remove', index)"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>
|
||||
</button>
|
||||
<span class="shrink-0 text-xs font-medium tabular-nums">{{ item.quantity }} pcs</span>
|
||||
</div>
|
||||
|
||||
<label class="mt-2 block text-xs text-muted-foreground">
|
||||
Jumlah (pcs)
|
||||
</label>
|
||||
<div class="mt-1 flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="flex size-8 shrink-0 items-center justify-center rounded border text-sm transition-colors hover:bg-muted"
|
||||
@click="emit('adjust-quantity', index, -1)"
|
||||
>
|
||||
−
|
||||
</button>
|
||||
<input
|
||||
type="text"
|
||||
inputmode="decimal"
|
||||
:value="item.quantity"
|
||||
class="h-8 w-full rounded border bg-transparent px-2 text-center text-sm focus:outline-none focus:ring-1 focus:ring-ring"
|
||||
@change="onQtyInput(index, $event)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="flex size-8 shrink-0 items-center justify-center rounded border text-sm transition-colors hover:bg-muted"
|
||||
@click="emit('adjust-quantity', index, 1)"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-1.5 flex items-center justify-between gap-2 text-xs text-muted-foreground">
|
||||
<span>@ Rp {{ formatRupiah(item.unit_price) }}</span>
|
||||
<span class="font-medium text-foreground">Rp {{ formatRupiah(lineSubtotal(item)) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="cart.length > 0" class="border-t pt-3">
|
||||
<div class="border-t pt-3">
|
||||
<div class="flex items-center justify-between text-sm font-semibold">
|
||||
<span>Total</span>
|
||||
<span class="text-primary">Rp {{ formatRupiah(totalAmount) }}</span>
|
||||
|
||||
@ -115,7 +115,6 @@ const {
|
||||
removeFromCart,
|
||||
adjustQuantity,
|
||||
syncCartItemQuantity,
|
||||
setCartItemQuantity,
|
||||
decreaseVariantQty,
|
||||
} = useOrderPosCart({
|
||||
catalog: () => props.catalog,
|
||||
@ -228,7 +227,7 @@ function buildFormData(): FormData {
|
||||
formData.append('discount', parseRupiah(form.discount));
|
||||
formData.append('nego_price', parseRupiah(form.nego_price));
|
||||
formData.append('notes', form.notes);
|
||||
|
||||
|
||||
if (isCashierUser.value) {
|
||||
formData.append('status', OrderStatus.COMPLETED);
|
||||
} else {
|
||||
@ -363,20 +362,5 @@ function submit() {
|
||||
:stock-quality-label="stockQualityLabel"
|
||||
:line-subtotal="lineSubtotal"
|
||||
:total-amount="totalAmount"
|
||||
@remove="removeFromCart"
|
||||
@adjust-quantity="adjustQuantity"
|
||||
@set-quantity="setCartItemQuantity"
|
||||
/>
|
||||
|
||||
<button
|
||||
v-if="cart.length > 0"
|
||||
type="button"
|
||||
class="fixed top-50 right-6 z-50 flex size-14 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-lg transition-transform hover:scale-105 active:scale-95 xl:hidden"
|
||||
@click="cartDetailOpen = true"
|
||||
>
|
||||
<ShoppingCart class="size-6" />
|
||||
<span class="absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full bg-destructive text-[11px] font-bold text-destructive-foreground">
|
||||
{{ cart.length > 99 ? '99+' : cart.length }}
|
||||
</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@ -287,31 +287,6 @@ export function useOrderPosCart(options: {
|
||||
}
|
||||
}
|
||||
|
||||
async function setCartItemQuantity(index: number, value: string) {
|
||||
const item = cart.value[index];
|
||||
const nextQty = Number.parseFloat(value.replace(',', '.'));
|
||||
|
||||
if (Number.isNaN(nextQty) || nextQty < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nextQty < 1) {
|
||||
await removeFromCart(index);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
item.quantity = String(nextQty);
|
||||
|
||||
if (toValue(options.isCreateMode)) {
|
||||
try {
|
||||
await syncDraftItem(item.product_variant_id, nextQty, item.stock_quality);
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : 'Gagal memperbarui jumlah item.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
search,
|
||||
selectedStockQuality,
|
||||
@ -328,7 +303,6 @@ export function useOrderPosCart(options: {
|
||||
removeFromCart,
|
||||
adjustQuantity,
|
||||
syncCartItemQuantity,
|
||||
setCartItemQuantity,
|
||||
decreaseVariantQty,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,62 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Empty,
|
||||
EmptyDescription,
|
||||
EmptyHeader,
|
||||
EmptyTitle,
|
||||
} from '@/components/ui/empty';
|
||||
import { formatRupiah } from '@/lib/rupiah';
|
||||
import type { PurchaseCartItem } from '@/types/purchase';
|
||||
|
||||
const props = defineProps<{
|
||||
defineProps<{
|
||||
cart: PurchaseCartItem[];
|
||||
lineSubtotal: (item: PurchaseCartItem) => number;
|
||||
total: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
remove: [index: number];
|
||||
'adjust-quantity': [index: number, delta: number];
|
||||
'set-quantity': [index: number, value: string];
|
||||
}>();
|
||||
|
||||
const open = defineModel<boolean>('open', { required: true });
|
||||
|
||||
function onQtyInput(index: number, event: Event) {
|
||||
emit('set-quantity', index, (event.target as HTMLInputElement).value);
|
||||
}
|
||||
|
||||
const hasItems = computed(() => props.cart.length > 0);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="sm:max-w-lg min-w-0 max-h-[90dvh] flex flex-col overflow-y-auto">
|
||||
<DialogContent class="sm:max-w-lg min-w-0">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Detail Keranjang</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div v-if="!hasItems" class="rounded-lg border border-dashed text-center text-sm text-muted-foreground">
|
||||
<Empty>
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Keranjang masih kosong</EmptyTitle>
|
||||
<EmptyDescription>
|
||||
Pilih varian bahan baku untuk menambahkan ke keranjang.
|
||||
</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
</div>
|
||||
|
||||
<div v-else class="scrollbar-thin max-h-96 space-y-3 overflow-y-auto overscroll-y-contain">
|
||||
<div class="scrollbar-thin max-h-96 space-y-3 overflow-y-auto overscroll-y-contain">
|
||||
<div
|
||||
v-for="(item, index) in cart"
|
||||
v-for="item in cart"
|
||||
:key="`detail-${item.raw_material_price_id}`"
|
||||
class="rounded-lg border p-3"
|
||||
>
|
||||
@ -65,50 +34,17 @@ const hasItems = computed(() => props.cart.length > 0);
|
||||
<p class="truncate text-sm font-medium">{{ item.raw_material_name }}</p>
|
||||
<p class="truncate text-xs text-muted-foreground">{{ item.variant }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex size-7 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive"
|
||||
@click="emit('remove', index)"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>
|
||||
</button>
|
||||
<span class="shrink-0 text-xs font-medium tabular-nums">
|
||||
{{ item.quantity }} {{ item.unit_abbreviation }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<label class="mt-2 block text-xs text-muted-foreground">
|
||||
Jumlah ({{ item.unit_abbreviation }})
|
||||
</label>
|
||||
<div class="mt-1 flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="flex size-8 shrink-0 items-center justify-center rounded border text-sm transition-colors hover:bg-muted"
|
||||
@click="emit('adjust-quantity', index, -1)"
|
||||
>
|
||||
−
|
||||
</button>
|
||||
<input
|
||||
type="text"
|
||||
inputmode="decimal"
|
||||
:value="item.quantity"
|
||||
class="h-8 w-full rounded border bg-transparent px-2 text-center text-sm focus:outline-none focus:ring-1 focus:ring-ring"
|
||||
@change="onQtyInput(index, $event)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="flex size-8 shrink-0 items-center justify-center rounded border text-sm transition-colors hover:bg-muted"
|
||||
@click="emit('adjust-quantity', index, 1)"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-1.5 flex items-center justify-between gap-2 text-xs text-muted-foreground">
|
||||
<span>@ Rp {{ formatRupiah(item.unit_price) }}</span>
|
||||
<span class="font-medium text-foreground">Rp {{ formatRupiah(lineSubtotal(item)) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="hasItems" class="border-t pt-3">
|
||||
<div class="border-t pt-3">
|
||||
<div class="flex items-center justify-between text-sm font-semibold">
|
||||
<span>Total</span>
|
||||
<span class="text-primary">Rp {{ formatRupiah(total) }}</span>
|
||||
|
||||
@ -33,7 +33,7 @@ const emit = defineEmits<{
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Keranjang masih kosong</EmptyTitle>
|
||||
<EmptyDescription>
|
||||
Pilih varian bahan baku untuk menambahkan ke keranjang.
|
||||
Pilih varian bahan baku di sebelah kiri untuk menambahkan ke keranjang.
|
||||
</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
@ -64,7 +64,6 @@ const {
|
||||
removeFromCart,
|
||||
adjustQuantity,
|
||||
syncCartItemQuantity,
|
||||
setCartItemQuantity,
|
||||
decreasePriceQty,
|
||||
} = usePurchasePosCart({
|
||||
catalog: () => props.catalog,
|
||||
@ -224,20 +223,5 @@ function submit() {
|
||||
:cart="cart"
|
||||
:line-subtotal="lineSubtotal"
|
||||
:total="total"
|
||||
@remove="removeFromCart"
|
||||
@adjust-quantity="adjustQuantity"
|
||||
@set-quantity="setCartItemQuantity"
|
||||
/>
|
||||
|
||||
<button
|
||||
v-if="cart.length > 0"
|
||||
type="button"
|
||||
class="fixed top-50 right-6 z-50 flex size-14 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-lg transition-transform hover:scale-105 active:scale-95 xl:hidden"
|
||||
@click="cartDetailOpen = true"
|
||||
>
|
||||
<ShoppingCart class="size-6" />
|
||||
<span class="absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full bg-destructive text-[11px] font-bold text-destructive-foreground">
|
||||
{{ cart.length > 99 ? '99+' : cart.length }}
|
||||
</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@ -189,31 +189,6 @@ export function usePurchasePosCart(options: {
|
||||
}
|
||||
}
|
||||
|
||||
async function setCartItemQuantity(index: number, value: string) {
|
||||
const item = cart.value[index];
|
||||
const nextQty = Number.parseFloat(value.replace(',', '.'));
|
||||
|
||||
if (Number.isNaN(nextQty) || nextQty < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nextQty <= 0) {
|
||||
await removeFromCart(index);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
item.quantity = String(nextQty);
|
||||
|
||||
if (toValue(options.isCreateMode)) {
|
||||
try {
|
||||
await syncDraftItem(item.raw_material_price_id, nextQty);
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : 'Gagal memperbarui jumlah item.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
search,
|
||||
cart,
|
||||
@ -227,7 +202,6 @@ export function usePurchasePosCart(options: {
|
||||
removeFromCart,
|
||||
adjustQuantity,
|
||||
syncCartItemQuantity,
|
||||
setCartItemQuantity,
|
||||
decreasePriceQty,
|
||||
upsertCartItem,
|
||||
};
|
||||
|
||||
@ -95,7 +95,7 @@ function submit() {
|
||||
<Field>
|
||||
<FieldLabel for="category-name" required>Nama</FieldLabel>
|
||||
<Input id="category-name" v-model="form.name" type="text" placeholder="Masukkan nama kategori"
|
||||
:maxlength="FIELD_LIMITS.categoryName" />
|
||||
autofocus :maxlength="FIELD_LIMITS.categoryName" />
|
||||
<FieldError :errors="formErrors(form, 'name')" />
|
||||
</Field>
|
||||
</FieldSet>
|
||||
|
||||
@ -101,7 +101,7 @@ function submit() {
|
||||
<Field>
|
||||
<FieldLabel for="customer-name" required>Nama</FieldLabel>
|
||||
<Input id="customer-name" v-model="form.name" type="text" placeholder="Masukkan nama pelanggan"
|
||||
:maxlength="FIELD_LIMITS.name" />
|
||||
autofocus :maxlength="FIELD_LIMITS.name" />
|
||||
<FieldError :errors="formErrors(form, 'name')" />
|
||||
</Field>
|
||||
<Field>
|
||||
|
||||
@ -59,12 +59,6 @@ function allVariantImageUrls(product: ProductListItem): string[] {
|
||||
return product.variants.flatMap((variant) => (variant.images ?? []).map((img) => img.url));
|
||||
}
|
||||
|
||||
function allVariantImageTitles(product: ProductListItem): string[] {
|
||||
return product.variants.flatMap((variant) =>
|
||||
(variant.images ?? []).map(() => `${product.name} - ${variant.name}`)
|
||||
);
|
||||
}
|
||||
|
||||
const verificationModalOpen = ref(false);
|
||||
const selectedRequestId = ref<number | null>(null);
|
||||
|
||||
@ -158,7 +152,7 @@ function openVerificationDetail(requestId: number | undefined) {
|
||||
{{ variant.name }}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<MediaThumbnailCell :items="variant.images ?? []" :max-visible="1" :title="`${product.name} - ${variant.name}`" :all-urls="allVariantImageUrls(product)" :all-titles="allVariantImageTitles(product)" />
|
||||
<MediaThumbnailCell :items="variant.images ?? []" :max-visible="1" :title="`${product.name} - ${variant.name}`" :all-urls="allVariantImageUrls(product)" />
|
||||
</TableCell>
|
||||
<TableCell class="tabular-nums">
|
||||
{{ variant.stock_formatted }}
|
||||
|
||||
@ -53,12 +53,6 @@ function allVariantImageUrls(material: RawMaterialListItem): string[] {
|
||||
return material.prices.flatMap((price) => (price.images ?? []).map((img) => img.url));
|
||||
}
|
||||
|
||||
function allVariantImageTitles(material: RawMaterialListItem): string[] {
|
||||
return material.prices.flatMap((price) =>
|
||||
(price.images ?? []).map(() => `${material.name} - ${price.variant}`)
|
||||
);
|
||||
}
|
||||
|
||||
const verificationModalOpen = ref(false);
|
||||
const selectedRequestId = ref<number | null>(null);
|
||||
|
||||
@ -150,7 +144,7 @@ function openVerificationDetail(requestId: number | undefined) {
|
||||
{{ price.variant }}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<MediaThumbnailCell :items="price.images ?? []" :max-visible="1" :title="`${material.name} - ${price.variant}`" :all-urls="allVariantImageUrls(material)" :all-titles="allVariantImageTitles(material)" />
|
||||
<MediaThumbnailCell :items="price.images ?? []" :max-visible="1" :title="`${material.name} - ${price.variant}`" :all-urls="allVariantImageUrls(material)" />
|
||||
</TableCell>
|
||||
<TableCell class="tabular-nums">
|
||||
{{ price.stock_formatted }}
|
||||
|
||||
@ -101,7 +101,7 @@ function submit() {
|
||||
<Field>
|
||||
<FieldLabel for="supplier-name" required>Nama</FieldLabel>
|
||||
<Input id="supplier-name" v-model="form.name" type="text"
|
||||
placeholder="Masukkan nama supplier" :maxlength="FIELD_LIMITS.name" />
|
||||
placeholder="Masukkan nama supplier" autofocus :maxlength="FIELD_LIMITS.name" />
|
||||
<FieldError :errors="formErrors(form, 'name')" />
|
||||
</Field>
|
||||
<Field>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user