diff --git a/src/app/purchase/detail/edit/page.tsx b/src/app/purchase/detail/edit/page.tsx
index 92f0980b..e265fb4b 100644
--- a/src/app/purchase/detail/edit/page.tsx
+++ b/src/app/purchase/detail/edit/page.tsx
@@ -6,7 +6,7 @@ import useSWR from 'swr';
import PurchaseRequestForm from '@/components/pages/purchase/form/request/PurchaseRequestForm';
import { PurchaseApi } from '@/services/api/purchase';
-import { isResponseError } from '@/lib/api-helper';
+import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { Purchase } from '@/types/api/purchase/purchase';
@@ -54,6 +54,190 @@ const DUMMY_PURCHASE_EDIT: Purchase = {
email: 'a@email.com',
name: 'Admin User',
},
+ purchase_items: [
+ {
+ id: 1,
+ product_warehouse: {
+ id: 1,
+ product_id: 1,
+ warehouse_id: 1,
+ quantity: 100,
+ product: {
+ id: 1,
+ name: 'Product A',
+ brand: 'Brand A',
+ sku: 'PROD-A-001',
+ product_price: 500000,
+ expiry_period: 0,
+ uom: {
+ id: 1,
+ name: 'pcs',
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ product_category: {
+ id: 1,
+ code: 'CAT-1',
+ name: 'Electronics',
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ suppliers: [
+ {
+ id: 1,
+ name: 'Supplier A',
+ alias: 'SupA',
+ pic: 'John Doe',
+ type: 'Local',
+ category: 'Electronics',
+ hatchery: 'N/A',
+ phone: '555-1234',
+ email: 'email@.com',
+ address: '123 Main St, Cityville',
+ npwp: '12.345.678.9-012.345',
+ account_number: 'ACC-12345',
+ due_date: 30,
+ balance: 1000000,
+ created_at: '2024-01-10T10:00:00Z',
+ updated_at: '2024-01-12T12:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ ],
+ flags: [],
+ created_at: '2024-01-05T09:00:00Z',
+ updated_at: '2024-01-07T11:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ warehouse: {
+ id: 1,
+ name: 'Main Warehouse',
+ type: 'AREA',
+ area: { id: 1, name: 'Area 1' },
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ created_at: '2024-01-05T09:00:00Z',
+ updated_at: '2024-01-07T11:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ product: {
+ id: 1,
+ name: 'Product A',
+ brand: 'Brand A',
+ sku: 'PROD-A-001',
+ product_price: 500000,
+ expiry_period: 0,
+ uom: {
+ id: 1,
+ name: 'pcs',
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ product_category: {
+ id: 1,
+ code: 'CAT-1',
+ name: 'Electronics',
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ suppliers: [
+ {
+ id: 1,
+ name: 'Supplier A',
+ alias: 'SupA',
+ pic: 'John Doe',
+ type: 'Local',
+ category: 'Electronics',
+ hatchery: 'N/A',
+ phone: '555-1234',
+ email: 'email@.com',
+ address: '123 Main St, Cityville',
+ npwp: '12.345.678.9-012.345',
+ account_number: 'ACC-12345',
+ due_date: 30,
+ balance: 1000000,
+ created_at: '2024-01-10T10:00:00Z',
+ updated_at: '2024-01-12T12:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ ],
+ flags: [],
+ created_at: '2024-01-05T09:00:00Z',
+ updated_at: '2024-01-07T11:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ warehouse: {
+ id: 1,
+ name: 'Main Warehouse',
+ type: 'AREA',
+ area: { id: 1, name: 'Area 1' },
+ created_at: '2024-01-01T00:00:00Z',
+ updated_at: '2024-01-01T00:00:00Z',
+ created_user: {
+ id: 2,
+ id_user: 2,
+ email: 'a@email.com',
+ name: 'Admin User',
+ },
+ },
+ sub_qty: 3,
+ },
+ ],
};
const PurchaseEdit = () => {
@@ -91,11 +275,8 @@ const PurchaseEdit = () => {
{isLoadingPurchase && (
)}
- {/* {!isLoadingPurchase && isResponseSuccess(purchase) && (
-
- )} */}
- {/* TODO: remove this dummy data and integrate to real API */}
+ {/* DEBUG TEMP: force dummy to verify form mapping/rendering */}
);
diff --git a/src/types/api/purchase/purchase.d.ts b/src/types/api/purchase/purchase.d.ts
index 669fd4b2..f26f739c 100644
--- a/src/types/api/purchase/purchase.d.ts
+++ b/src/types/api/purchase/purchase.d.ts
@@ -1,5 +1,16 @@
import { BaseMetadata } from '@/types/api/api-general';
import { Supplier } from '@/types/api/master-data/supplier';
+import { Warehouse } from '@/types/api/master-data/warehouse';
+import { Product } from '@/types/api/master-data/product';
+import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
+
+export type PurchaseItem = {
+ id: number;
+ warehouse: Warehouse;
+ product: Product;
+ product_warehouse: ProductWarehouse;
+ sub_qty: number;
+};
export type BasePurchase = {
id: number;
@@ -13,6 +24,7 @@ export type BasePurchase = {
notes?: string | null;
deleted_at?: string | null;
created_by: number;
+ purchase_items?: PurchaseItem[];
};
export type Purchase = BaseMetadata & BasePurchase;