diff --git a/app/Models/ProductVariant.php b/app/Models/ProductVariant.php index 9540816..2d68022 100644 --- a/app/Models/ProductVariant.php +++ b/app/Models/ProductVariant.php @@ -17,7 +17,7 @@ use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\MediaCollections\Models\Media; -#[Appends(['formatted_name', 'formatted_stock'])] +#[Appends(['formatted_name', 'formatted_stock', 'formatted_reject_stock', 'formatted_retail_stock'])] #[Guarded(['id'])] #[ScopedBy([ProductVariantScope::class])] class ProductVariant extends Model implements HasMedia @@ -47,6 +47,20 @@ protected function formattedStock(): Attribute ); } + protected function formattedRejectStock(): Attribute + { + return Attribute::make( + get: fn () => number_format($this->reject_stock, 0, ',', '.'), + ); + } + + protected function formattedRetailStock(): Attribute + { + return Attribute::make( + get: fn () => number_format($this->retail_stock, 0, ',', '.'), + ); + } + public function orderItems(): HasMany { return $this->hasMany(OrderItem::class); diff --git a/app/Models/RawMaterialPrice.php b/app/Models/RawMaterialPrice.php index 971fd4d..e573ded 100644 --- a/app/Models/RawMaterialPrice.php +++ b/app/Models/RawMaterialPrice.php @@ -18,7 +18,7 @@ use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\MediaCollections\Models\Media; -#[Appends(['formatted_price'])] +#[Appends(['formatted_price', 'formatted_stock'])] #[Guarded(['id'])] #[ScopedBy([RawMaterialPriceScope::class])] class RawMaterialPrice extends Model implements HasMedia @@ -40,6 +40,13 @@ protected function formattedPrice(): Attribute ); } + protected function formattedStock(): Attribute + { + return Attribute::make( + get: fn () => number_format($this->stock, 0, ',', '.'), + ); + } + public function cuttingMaterials(): HasMany { return $this->hasMany(CuttingMaterial::class); diff --git a/resources/js/components/dialogs/image-preview-button.tsx b/resources/js/components/dialogs/image-preview-button.tsx index 73ccd57..17d5587 100644 --- a/resources/js/components/dialogs/image-preview-button.tsx +++ b/resources/js/components/dialogs/image-preview-button.tsx @@ -6,6 +6,7 @@ type ImagePreviewButtonProps = { modalSrc?: string; modalSrcs?: string[]; title?: string; + description?: string; alt?: string; className?: string; }; @@ -15,6 +16,7 @@ export function ImagePreviewButton({ modalSrc, modalSrcs, title, + description, alt, className = 'h-10 w-10', }: ImagePreviewButtonProps) { @@ -46,6 +48,7 @@ export function ImagePreviewButton({ src={modalSources?.[0] ?? srcs[0]} sources={modalSources ?? srcs} title={title} + description={description} /> ); diff --git a/resources/js/components/dialogs/image-preview-modal.tsx b/resources/js/components/dialogs/image-preview-modal.tsx index 47f1587..cb85748 100644 --- a/resources/js/components/dialogs/image-preview-modal.tsx +++ b/resources/js/components/dialogs/image-preview-modal.tsx @@ -4,6 +4,7 @@ import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, + DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; @@ -13,6 +14,7 @@ type ImagePreviewModalProps = { onOpenChange: (open: boolean) => void; src: string | null; title?: string; + description?: string; alt?: string; sources?: string[]; }; @@ -22,6 +24,7 @@ export function ImagePreviewModal({ onOpenChange, src, title, + description, alt = 'Preview', sources, }: ImagePreviewModalProps) { @@ -55,9 +58,10 @@ setCurrentIndex(0); }} > - {title && ( + {(title || description) && ( - {title} + {title && {title}} + {description && {description}} )} {currentSrc && ( diff --git a/resources/js/pages/admin/manage/cutting/cutting-card.tsx b/resources/js/pages/admin/manage/cutting/cutting-card.tsx index a5c4030..f7c4219 100644 --- a/resources/js/pages/admin/manage/cutting/cutting-card.tsx +++ b/resources/js/pages/admin/manage/cutting/cutting-card.tsx @@ -133,7 +133,8 @@ export function CuttingCardRow({ diff --git a/resources/js/pages/admin/manage/purchase/purchase-card.tsx b/resources/js/pages/admin/manage/purchase/purchase-card.tsx index 86d6094..ec817e5 100644 --- a/resources/js/pages/admin/manage/purchase/purchase-card.tsx +++ b/resources/js/pages/admin/manage/purchase/purchase-card.tsx @@ -120,7 +120,8 @@ export function PurchaseCardRow({ diff --git a/resources/js/pages/admin/manage/transaction/transaction-card.tsx b/resources/js/pages/admin/manage/transaction/transaction-card.tsx index 5060aed..1612b18 100644 --- a/resources/js/pages/admin/manage/transaction/transaction-card.tsx +++ b/resources/js/pages/admin/manage/transaction/transaction-card.tsx @@ -203,7 +203,8 @@ export function TransactionCardRow({ diff --git a/resources/js/pages/admin/master/product/columns.tsx b/resources/js/pages/admin/master/product/columns.tsx index a795597..7392e72 100644 --- a/resources/js/pages/admin/master/product/columns.tsx +++ b/resources/js/pages/admin/master/product/columns.tsx @@ -11,9 +11,11 @@ export type ProductVariant = { id: number; name: string; stock: number; - formatted_stock: string + formatted_stock: string; reject_stock: number; + formatted_reject_stock: string; retail_stock: number; + formatted_retail_stock: string; photo_urls: string[]; photo_conversion_urls: string[]; product_prices: { diff --git a/resources/js/pages/admin/master/product/variant/sub-row.tsx b/resources/js/pages/admin/master/product/variant/sub-row.tsx index 285242d..f59fb48 100644 --- a/resources/js/pages/admin/master/product/variant/sub-row.tsx +++ b/resources/js/pages/admin/master/product/variant/sub-row.tsx @@ -93,6 +93,7 @@ export function VariantSubRow({ srcs={variant.photo_conversion_urls?.length > 0 ? variant.photo_conversion_urls : variant.photo_urls} modalSrcs={variant.photo_urls} title={variant.name} + description={`Stok Bagus: ${variant.formatted_stock} | Stok Reject: ${variant.formatted_reject_stock} | Stok Ecer: ${variant.formatted_retail_stock}`} /> ) : (
diff --git a/resources/js/pages/admin/master/raw-material/columns.tsx b/resources/js/pages/admin/master/raw-material/columns.tsx index eb74ab3..d9c4873 100644 --- a/resources/js/pages/admin/master/raw-material/columns.tsx +++ b/resources/js/pages/admin/master/raw-material/columns.tsx @@ -3,6 +3,7 @@ export type RawMaterialVariant = { variant: string; price: number; stock: number; + formatted_stock: string; photo_url: string | null; photo_conversion_url: string | null; }; diff --git a/resources/js/pages/admin/master/raw-material/variant/sub-row.tsx b/resources/js/pages/admin/master/raw-material/variant/sub-row.tsx index ee3f8c0..8381127 100644 --- a/resources/js/pages/admin/master/raw-material/variant/sub-row.tsx +++ b/resources/js/pages/admin/master/raw-material/variant/sub-row.tsx @@ -90,6 +90,7 @@ export function RawMaterialVariantSubRow({ srcs={[variant.photo_conversion_url ?? variant.photo_url]} modalSrc={variant.photo_url} title={variant.variant} + description={`Stok: ${variant.formatted_stock}`} /> ) : (