Compare commits
2 Commits
cc112ef253
...
6539d7dd2d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6539d7dd2d | ||
|
|
fbca04bce6 |
@ -503,9 +503,7 @@ ### ZONK — Tidak Ada Logic di Controller
|
||||
{
|
||||
$this->service->store($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil ditambahkan']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil ditambahkan'])->back();
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,9 +516,7 @@ ### ZONK — Tidak Ada Logic di Controller
|
||||
{
|
||||
$this->service->resetPassword($user, $request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Password berhasil direset']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Password berhasil direset'])->back();
|
||||
}
|
||||
```
|
||||
|
||||
@ -565,9 +561,7 @@ ### Return ke Halaman yang Sama — Gunakan `back()`
|
||||
{
|
||||
$this->service->destroy($product);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil dihapus']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil dihapus'])->back();
|
||||
}
|
||||
|
||||
// ❌ JANGAN pakai ->with()
|
||||
@ -622,9 +616,7 @@ ### DB Transaction — Gunakan `handleAction()` untuk 2+ Query
|
||||
{
|
||||
$this->service->destroy($product);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil dihapus']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil dihapus'])->back();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -32,35 +32,27 @@ public function updateSystem(UpdateSystemRequest $request): RedirectResponse
|
||||
{
|
||||
$this->service->updateSystem($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan sistem berhasil diperbarui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan sistem berhasil diperbarui.'])->back();
|
||||
}
|
||||
|
||||
public function updateHomepage(UpdateHomepageRequest $request): RedirectResponse
|
||||
{
|
||||
$this->service->updateHomepage($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan homepage berhasil diperbarui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan homepage berhasil diperbarui.'])->back();
|
||||
}
|
||||
|
||||
public function updateSocialMedia(UpdateSocialMediaRequest $request): RedirectResponse
|
||||
{
|
||||
$this->service->updateSocialMedia($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan media sosial berhasil diperbarui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan media sosial berhasil diperbarui.'])->back();
|
||||
}
|
||||
|
||||
public function updateHR(UpdateHRRequest $request): RedirectResponse
|
||||
{
|
||||
$this->service->updateHR($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan HR berhasil diperbarui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Pengaturan HR berhasil diperbarui.'])->back();
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,9 +86,7 @@ public function toggleActive(User $user): RedirectResponse
|
||||
$employee = $this->service->toggleActive($user);
|
||||
$status = $employee->is_active ? 'diaktifkan' : 'dinonaktifkan';
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => "Pegawai berhasil {$status}."]);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => "Pegawai berhasil {$status}."])->back();
|
||||
}
|
||||
|
||||
public function resetPassword(User $user): RedirectResponse
|
||||
|
||||
@ -28,26 +28,20 @@ public function store(CategoryRequest $request): RedirectResponse
|
||||
{
|
||||
$this->service->store($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil ditambahkan.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil ditambahkan.'])->back();
|
||||
}
|
||||
|
||||
public function update(CategoryRequest $request, Category $category): RedirectResponse
|
||||
{
|
||||
$this->service->update($category, $request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil diperbarui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil diperbarui.'])->back();
|
||||
}
|
||||
|
||||
public function destroy(Category $category): RedirectResponse
|
||||
{
|
||||
$this->service->destroy($category);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil dihapus.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kategori berhasil dihapus.'])->back();
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,26 +28,20 @@ public function store(CustomerRequest $request): RedirectResponse
|
||||
{
|
||||
$this->service->store($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil ditambahkan.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil ditambahkan.'])->back();
|
||||
}
|
||||
|
||||
public function update(CustomerRequest $request, Customer $customer): RedirectResponse
|
||||
{
|
||||
$this->service->update($customer, $request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil diperbarui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil diperbarui.'])->back();
|
||||
}
|
||||
|
||||
public function destroy(Customer $customer): RedirectResponse
|
||||
{
|
||||
$this->service->destroy($customer);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil dihapus.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Customer berhasil dihapus.'])->back();
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,9 +84,7 @@ public function toggleStatus(Product $product): RedirectResponse
|
||||
$this->service->toggleStatus($product);
|
||||
$status = $product->fresh()->status;
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => "Status produk berhasil diubah menjadi {$status->label()}."]);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => "Status produk berhasil diubah menjadi {$status->label()}."])->back();
|
||||
}
|
||||
|
||||
public function toggleFeatured(Product $product): RedirectResponse
|
||||
@ -94,18 +92,14 @@ public function toggleFeatured(Product $product): RedirectResponse
|
||||
$this->service->toggleFeatured($product);
|
||||
$featured = $product->fresh()->is_featured;
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => $featured ? 'Produk berhasil ditampilkan di halaman depan.' : 'Produk berhasil disembunyikan dari halaman depan.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => $featured ? 'Produk berhasil ditampilkan di halaman depan.' : 'Produk berhasil disembunyikan dari halaman depan.'])->back();
|
||||
}
|
||||
|
||||
public function approve(Product $product): RedirectResponse
|
||||
{
|
||||
$this->service->approve($product);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil disetujui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil disetujui.'])->back();
|
||||
}
|
||||
|
||||
public function reject(Product $product): RedirectResponse
|
||||
@ -113,18 +107,14 @@ public function reject(Product $product): RedirectResponse
|
||||
$reason = request()->input('rejection_reason', '');
|
||||
$this->service->reject($product, $reason);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil ditolak.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil ditolak.'])->back();
|
||||
}
|
||||
|
||||
public function resubmit(Product $product): RedirectResponse
|
||||
{
|
||||
$this->service->resubmit($product);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil diajukan ulang.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Produk berhasil diajukan ulang.'])->back();
|
||||
}
|
||||
|
||||
public function variants(Product $product): JsonResponse
|
||||
|
||||
@ -81,9 +81,7 @@ public function toggleStatus(RawMaterial $rawMaterial): RedirectResponse
|
||||
$this->service->toggleStatus($rawMaterial);
|
||||
$status = $rawMaterial->fresh()->is_active ? 'Aktif' : 'Non Aktif';
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => "Status bahan baku berhasil diubah menjadi {$status}."]);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => "Status bahan baku berhasil diubah menjadi {$status}."])->back();
|
||||
}
|
||||
|
||||
public function variants(RawMaterial $rawMaterial): JsonResponse
|
||||
|
||||
@ -28,26 +28,20 @@ public function store(SupplierRequest $request): RedirectResponse
|
||||
{
|
||||
$this->service->store($request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil ditambahkan.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil ditambahkan.'])->back();
|
||||
}
|
||||
|
||||
public function update(SupplierRequest $request, Supplier $supplier): RedirectResponse
|
||||
{
|
||||
$this->service->update($supplier, $request->validated());
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil diperbarui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil diperbarui.'])->back();
|
||||
}
|
||||
|
||||
public function destroy(Supplier $supplier): RedirectResponse
|
||||
{
|
||||
$this->service->destroy($supplier);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil dihapus.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Supplier berhasil dihapus.'])->back();
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,8 +61,6 @@ public function destroy(Role $role): RedirectResponse
|
||||
{
|
||||
$this->service->destroy($role);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Role berhasil dihapus.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Role berhasil dihapus.'])->back();
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,8 +22,6 @@ public function update(PasswordUpdateRequest $request): RedirectResponse
|
||||
{
|
||||
$request->user()->update(['password' => $request->password]);
|
||||
|
||||
Inertia::flash('toast', ['type' => 'success', 'message' => 'Kata sandi berhasil diperbarui.']);
|
||||
|
||||
return back();
|
||||
return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kata sandi berhasil diperbarui.'])->back();
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,6 +101,7 @@ export default function CuttingCreate({ rawMaterials }: Props) {
|
||||
|
||||
const [cartOpen, setCartOpen] = useState(false);
|
||||
const [previewKey, setPreviewKey] = useState<string | null>(null);
|
||||
const [variantPreview, setVariantPreview] = useState<{ src: string; title?: string; description?: string } | null>(null);
|
||||
const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false);
|
||||
const [deleteMaterialIndex, setDeleteMaterialIndex] = useState<number | null>(null);
|
||||
|
||||
@ -456,7 +457,7 @@ export default function CuttingCreate({ rawMaterials }: Props) {
|
||||
<div key={price.id} className={`flex flex-wrap items-center justify-between gap-2 rounded-lg border p-3 ${isAdded ? 'border-primary' : ''}`}>
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 rounded-md object-cover" />
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 cursor-pointer rounded-md object-cover" onClick={() => setVariantPreview({ src: price.photo_url, title: price.variant, description: rm.name })} />
|
||||
) : (
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">N/A</div>
|
||||
)}
|
||||
@ -511,7 +512,7 @@ export default function CuttingCreate({ rawMaterials }: Props) {
|
||||
<div key={price.id} className={`flex flex-wrap items-center justify-between gap-2 rounded-lg border p-3 ${isAdded ? 'border-primary' : ''}`}>
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 rounded-md object-cover" />
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 cursor-pointer rounded-md object-cover" onClick={() => setVariantPreview({ src: price.photo_url, title: price.variant, description: selectedMaterial?.name })} />
|
||||
) : (
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">N/A</div>
|
||||
)}
|
||||
@ -767,6 +768,18 @@ export default function CuttingCreate({ rawMaterials }: Props) {
|
||||
sources={materials.filter((m) => m.photo_url).map((m) => m.photo_url!)}
|
||||
/>
|
||||
|
||||
<ImagePreviewModal
|
||||
open={variantPreview !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
setVariantPreview(null);
|
||||
}
|
||||
}}
|
||||
src={variantPreview?.src ?? null}
|
||||
title={variantPreview?.title}
|
||||
description={variantPreview?.description}
|
||||
/>
|
||||
|
||||
{comboDialogOpen && (
|
||||
<div className="fixed inset-0 z-50 bg-black/50" onClick={() => setComboDialogOpen(false)} />
|
||||
)}
|
||||
@ -815,7 +828,7 @@ export default function CuttingCreate({ rawMaterials }: Props) {
|
||||
<div key={item.priceId} className="flex items-center justify-between gap-2 rounded-md border border-primary bg-primary/5 px-3 py-2">
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{photoUrl ? (
|
||||
<img src={photoUrl} alt={variantName} className="h-8 w-8 shrink-0 rounded-md object-cover" />
|
||||
<img src={photoUrl} alt={variantName} className="h-8 w-8 shrink-0 cursor-pointer rounded-md object-cover" onClick={() => setVariantPreview({ src: price?.photo_url ?? null, title: variantName, description: item.materialName })} />
|
||||
) : (
|
||||
<div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">N/A</div>
|
||||
)}
|
||||
@ -853,8 +866,8 @@ export default function CuttingCreate({ rawMaterials }: Props) {
|
||||
return (
|
||||
<div key={price.id} className={`flex items-center justify-between gap-3 rounded-lg border p-3 ${isSelected ? 'border-primary' : ''}`}>
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 rounded-md object-cover" />
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 cursor-pointer rounded-md object-cover" onClick={() => setVariantPreview({ src: price.photo_url, title: price.variant, description: comboMaterial.name })} />
|
||||
) : (
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">N/A</div>
|
||||
)}
|
||||
|
||||
@ -104,6 +104,7 @@ export default function CuttingEdit({ cutting, rawMaterials }: Props) {
|
||||
|
||||
const [cartOpen, setCartOpen] = useState(false);
|
||||
const [previewKey, setPreviewKey] = useState<string | null>(null);
|
||||
const [variantPreview, setVariantPreview] = useState<{ src: string; title?: string; description?: string } | null>(null);
|
||||
const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false);
|
||||
const [deleteMaterialIndex, setDeleteMaterialIndex] = useState<number | null>(null);
|
||||
|
||||
@ -455,8 +456,8 @@ export default function CuttingEdit({ cutting, rawMaterials }: Props) {
|
||||
return (
|
||||
<div key={price.id} className={`flex flex-wrap items-center justify-between gap-2 rounded-lg border p-3 ${isAdded ? 'border-primary' : ''}`}>
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 rounded-md object-cover" />
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 cursor-pointer rounded-md object-cover" onClick={() => setVariantPreview({ src: price.photo_url, title: price.variant, description: rm.name })} />
|
||||
) : (
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">N/A</div>
|
||||
)}
|
||||
@ -502,7 +503,7 @@ export default function CuttingEdit({ cutting, rawMaterials }: Props) {
|
||||
Tidak ada varian ditemukan.
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<div className="space-y-2">
|
||||
{selectedMaterialVariants.map((price) => {
|
||||
const isAdded = materials.some((m) => m.raw_material_price_id === price.id);
|
||||
const addedCount = materials.filter((m) => m.raw_material_price_id === price.id).length;
|
||||
@ -510,8 +511,8 @@ export default function CuttingEdit({ cutting, rawMaterials }: Props) {
|
||||
return (
|
||||
<div key={price.id} className={`flex flex-wrap items-center justify-between gap-2 rounded-lg border p-3 ${isAdded ? 'border-primary' : ''}`}>
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 rounded-md object-cover" />
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 cursor-pointer rounded-md object-cover" onClick={() => setVariantPreview({ src: price.photo_url, title: price.variant, description: selectedMaterial?.name })} />
|
||||
) : (
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">N/A</div>
|
||||
)}
|
||||
@ -528,7 +529,7 @@ export default function CuttingEdit({ cutting, rawMaterials }: Props) {
|
||||
<Plus className="h-4 w-4" />
|
||||
Tambah
|
||||
</Button>
|
||||
<Button type="button" variant="outline" size="sm" onClick={() => openComboDialog(selectedMaterial, price.id)}>
|
||||
<Button type="button" variant="outline" size="sm" onClick={() => openComboDialog(selectedMaterial, price.id)}>
|
||||
<Layers className="h-4 w-4" />
|
||||
Kombinasi
|
||||
</Button>
|
||||
@ -767,6 +768,18 @@ export default function CuttingEdit({ cutting, rawMaterials }: Props) {
|
||||
sources={materials.filter((m) => m.photo_url).map((m) => m.photo_url!)}
|
||||
/>
|
||||
|
||||
<ImagePreviewModal
|
||||
open={variantPreview !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
setVariantPreview(null);
|
||||
}
|
||||
}}
|
||||
src={variantPreview?.src ?? null}
|
||||
title={variantPreview?.title}
|
||||
description={variantPreview?.description}
|
||||
/>
|
||||
|
||||
{comboDialogOpen && (
|
||||
<div className="fixed inset-0 z-50 bg-black/50" onClick={() => setComboDialogOpen(false)} />
|
||||
)}
|
||||
@ -815,7 +828,7 @@ export default function CuttingEdit({ cutting, rawMaterials }: Props) {
|
||||
<div key={item.priceId} className="flex items-center justify-between gap-2 rounded-md border border-primary bg-primary/5 px-3 py-2">
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{photoUrl ? (
|
||||
<img src={photoUrl} alt={variantName} className="h-8 w-8 shrink-0 rounded-md object-cover" />
|
||||
<img src={photoUrl} alt={variantName} className="h-8 w-8 shrink-0 cursor-pointer rounded-md object-cover" onClick={() => setVariantPreview({ src: price?.photo_url ?? null, title: variantName, description: item.materialName })} />
|
||||
) : (
|
||||
<div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">N/A</div>
|
||||
)}
|
||||
@ -844,8 +857,8 @@ export default function CuttingEdit({ cutting, rawMaterials }: Props) {
|
||||
return (
|
||||
<div key={price.id} className={`flex items-center justify-between gap-3 rounded-lg border p-3 ${isSelected ? 'border-primary' : ''}`}>
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 rounded-md object-cover" />
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img src={price.photo_conversion_url ?? price.photo_url} alt={price.variant} className="h-10 w-10 shrink-0 cursor-pointer rounded-md object-cover" onClick={() => setVariantPreview({ src: price.photo_url, title: price.variant, description: comboMaterial.name })} />
|
||||
) : (
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">N/A</div>
|
||||
)}
|
||||
|
||||
@ -141,6 +141,7 @@ export default function PurchaseCreate({ suppliers, rawMaterials }: Props) {
|
||||
);
|
||||
const [cartOpen, setCartOpen] = useState(false);
|
||||
const [previewKey, setPreviewKey] = useState<string | null>(null);
|
||||
const [variantPreview, setVariantPreview] = useState<{ src: string; title?: string; description?: string } | null>(null);
|
||||
const [cartRemoveKey, setCartRemoveKey] = useState<string | null>(null);
|
||||
|
||||
const draftData = useMemo(
|
||||
@ -915,18 +916,19 @@ export default function PurchaseCreate({ suppliers, rawMaterials }: Props) {
|
||||
: 'flex flex-wrap items-center justify-between gap-2 rounded-lg border p-3'
|
||||
}
|
||||
>
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img
|
||||
src={
|
||||
price.photo_conversion_url ?? price.photo_url
|
||||
}
|
||||
alt={
|
||||
price.variant
|
||||
}
|
||||
className="h-10 w-10 shrink-0 rounded-md object-cover"
|
||||
/>
|
||||
) : (
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
{price.photo_conversion_url ?? price.photo_url ? (
|
||||
<img
|
||||
src={
|
||||
price.photo_conversion_url ?? price.photo_url
|
||||
}
|
||||
alt={
|
||||
price.variant
|
||||
}
|
||||
className="h-10 w-10 shrink-0 cursor-pointer rounded-md object-cover"
|
||||
onClick={() => setVariantPreview({ src: price.photo_url, title: price.variant, description: selectedMaterial?.name })}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">
|
||||
N/A
|
||||
</div>
|
||||
@ -1334,6 +1336,18 @@ export default function PurchaseCreate({ suppliers, rawMaterials }: Props) {
|
||||
title={cartItems.find((i) => i.key === previewKey)?.title}
|
||||
/>
|
||||
|
||||
<ImagePreviewModal
|
||||
open={variantPreview !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
setVariantPreview(null);
|
||||
}
|
||||
}}
|
||||
src={variantPreview?.src ?? null}
|
||||
title={variantPreview?.title}
|
||||
description={variantPreview?.description}
|
||||
/>
|
||||
|
||||
<ConfirmDialog
|
||||
open={deleteConfirmOpen}
|
||||
onOpenChange={(open) => {
|
||||
|
||||
@ -95,6 +95,7 @@ export default function PurchaseEdit({
|
||||
);
|
||||
const [cartOpen, setCartOpen] = useState(false);
|
||||
const [previewKey, setPreviewKey] = useState<string | null>(null);
|
||||
const [variantPreview, setVariantPreview] = useState<{ src: string; title?: string; description?: string } | null>(null);
|
||||
const [cartRemoveKey, setCartRemoveKey] = useState<string | null>(null);
|
||||
|
||||
const [fetchedVariants, setFetchedVariants] = useState<Map<number, RawMaterialVariant[]>>(new Map());
|
||||
@ -314,7 +315,8 @@ export default function PurchaseEdit({
|
||||
<img
|
||||
src={price.photo_conversion_url ?? price.photo_url!}
|
||||
alt={price.variant}
|
||||
className="h-10 w-10 shrink-0 rounded-md object-cover"
|
||||
className="h-10 w-10 shrink-0 cursor-pointer rounded-md object-cover"
|
||||
onClick={() => setVariantPreview({ src: price.photo_url ?? null, title: price.variant, description: group.name })}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-xs text-muted-foreground">
|
||||
@ -679,6 +681,18 @@ export default function PurchaseEdit({
|
||||
title={cartItems.find((i) => i.key === previewKey)?.title}
|
||||
/>
|
||||
|
||||
<ImagePreviewModal
|
||||
open={variantPreview !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
setVariantPreview(null);
|
||||
}
|
||||
}}
|
||||
src={variantPreview?.src ?? null}
|
||||
title={variantPreview?.title}
|
||||
description={variantPreview?.description}
|
||||
/>
|
||||
|
||||
<ConfirmDialog
|
||||
open={cartRemoveKey !== null}
|
||||
onOpenChange={(open) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user