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