mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-22 14:25:47 +00:00
refactor(FE-177-166-167): separate table repeater component and adjust data types with new API Payload
This commit is contained in:
+187
-162
@@ -4,12 +4,34 @@ import { Location } from '@/types/api/master-data/location';
|
||||
import { Kandang } from '@/types/api/master-data/kandang';
|
||||
import { Warehouse } from '@/types/api/master-data/warehouse';
|
||||
import { ProductWarehouse } from '@/types/api/inventory/product-warehouse';
|
||||
import { Marketing } from '@/types/api/marketing/marketing';
|
||||
import { CreatedUser } from '@/types/api/api-general';
|
||||
import {
|
||||
BaseMarketing,
|
||||
Marketing,
|
||||
BaseSalesOrder,
|
||||
BaseDeliveryOrder,
|
||||
BaseDelivery,
|
||||
} from '@/types/api/marketing/marketing';
|
||||
import {
|
||||
CreatedUser,
|
||||
BaseApproval,
|
||||
BaseMetadata,
|
||||
} from '@/types/api/api-general';
|
||||
import { Product } from '@/types/api/master-data/product';
|
||||
import { Customer } from '@/types/api/master-data/customer';
|
||||
import { Uom } from '@/types/api/master-data/uom';
|
||||
import { ProductCategory } from '@/types/api/master-data/product-category';
|
||||
import { Supplier } from '@/types/api/master-data/supplier';
|
||||
|
||||
// Waktu saat ini untuk created_at/updated_at
|
||||
const now = format(new Date(), 'yyyy-MM-dd HH:mm:ss');
|
||||
const today = format(new Date(), 'yyyy-MM-dd');
|
||||
const tomorrow = format(
|
||||
new Date().setDate(new Date().getDate() + 1),
|
||||
'yyyy-MM-dd'
|
||||
);
|
||||
|
||||
// ======================
|
||||
// 👤 Created User
|
||||
// 👤 Created User & Helper Data
|
||||
// ======================
|
||||
export const createdUser: CreatedUser = {
|
||||
id: 1,
|
||||
@@ -18,6 +40,24 @@ export const createdUser: CreatedUser = {
|
||||
name: 'Admin Utama',
|
||||
};
|
||||
|
||||
const dummyProductBase: Product = {
|
||||
id: 101,
|
||||
name: 'Pakan Ayam Premium',
|
||||
brand: 'Brand Hebat',
|
||||
sku: 'PAK-001',
|
||||
product_price: 15000,
|
||||
selling_price: 18000,
|
||||
tax: 0.1,
|
||||
expiry_period: 365,
|
||||
uom: { id: 1, name: 'Sak' } as Uom,
|
||||
product_category: { id: 1, name: 'Pakan' } as ProductCategory,
|
||||
suppliers: [{ id: 1, name: 'Supplier A' } as Supplier],
|
||||
flags: ['PAKAN'],
|
||||
created_user: createdUser,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
};
|
||||
|
||||
// ======================
|
||||
// 📍 Area Dummy
|
||||
// ======================
|
||||
@@ -26,15 +66,15 @@ export const dummyAreas: Area[] = [
|
||||
id: 1,
|
||||
name: 'Bandung Barat',
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Cimahi Utara',
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -48,8 +88,8 @@ export const dummyLocations: Location[] = [
|
||||
address: 'Jl. Sukajadi No. 12',
|
||||
area: dummyAreas[0],
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
@@ -57,8 +97,8 @@ export const dummyLocations: Location[] = [
|
||||
address: 'Jl. Setiabudi No. 45',
|
||||
area: dummyAreas[1],
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -74,8 +114,8 @@ export const dummyKandangs: Kandang[] = [
|
||||
location: dummyLocations[0],
|
||||
pic: createdUser,
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
@@ -85,8 +125,8 @@ export const dummyKandangs: Kandang[] = [
|
||||
location: dummyLocations[1],
|
||||
pic: createdUser,
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -100,9 +140,9 @@ export const dummyWarehouses: Warehouse[] = [
|
||||
name: 'Gudang Wilayah Bandung Barat',
|
||||
area: dummyAreas[0],
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Warehouse,
|
||||
{
|
||||
id: 2,
|
||||
type: 'LOKASI',
|
||||
@@ -110,9 +150,9 @@ export const dummyWarehouses: Warehouse[] = [
|
||||
area: dummyAreas[0],
|
||||
location: { ...dummyLocations[0], area: dummyAreas[0] },
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Warehouse,
|
||||
{
|
||||
id: 3,
|
||||
type: 'KANDANG',
|
||||
@@ -125,9 +165,9 @@ export const dummyWarehouses: Warehouse[] = [
|
||||
pic: createdUser,
|
||||
},
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Warehouse,
|
||||
];
|
||||
|
||||
// ======================
|
||||
@@ -139,16 +179,11 @@ export const dummyProductWarehouses: ProductWarehouse[] = [
|
||||
product_id: 101,
|
||||
warehouse_id: 1,
|
||||
quantity: 1000,
|
||||
product: {
|
||||
id: 101,
|
||||
name: 'Pakan Ayam Premium',
|
||||
sku: 'PAK-001',
|
||||
category: 'PAKAN',
|
||||
} as unknown as Product,
|
||||
product: dummyProductBase,
|
||||
warehouse: dummyWarehouses[0],
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
@@ -156,28 +191,92 @@ export const dummyProductWarehouses: ProductWarehouse[] = [
|
||||
warehouse_id: 2,
|
||||
quantity: 500,
|
||||
product: {
|
||||
...dummyProductBase,
|
||||
id: 102,
|
||||
name: 'Vitamin Ayam Super',
|
||||
sku: 'VIT-002',
|
||||
category: 'VITAMIN',
|
||||
} as unknown as Product,
|
||||
flags: ['VITAMIN'],
|
||||
selling_price: 25000,
|
||||
},
|
||||
warehouse: dummyWarehouses[1],
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
},
|
||||
];
|
||||
|
||||
// ======================
|
||||
// 💼 Marketing Dummy
|
||||
// ======================
|
||||
export const dummyMarketings: Marketing[] = [
|
||||
// Step 1: Pengajuan Order
|
||||
|
||||
// Helper untuk Sales Order (SO) Item
|
||||
const soItem1: BaseSalesOrder = {
|
||||
id: 101,
|
||||
marketing_id: 1,
|
||||
product_warehouse_id: 1,
|
||||
qty: 100,
|
||||
unit_price: 18000, // Harga jual
|
||||
avg_weight: 1.0,
|
||||
total_weight: 100 * 1.0,
|
||||
total_price: 100 * 18000,
|
||||
product_warehouse: dummyProductWarehouses[0] as ProductWarehouse,
|
||||
};
|
||||
const soItem2: BaseSalesOrder = {
|
||||
id: 102,
|
||||
marketing_id: 2,
|
||||
product_warehouse_id: 2,
|
||||
qty: 50,
|
||||
unit_price: 25000,
|
||||
avg_weight: 0.5,
|
||||
total_weight: 50 * 0.5,
|
||||
total_price: 50 * 25000,
|
||||
product_warehouse: dummyProductWarehouses[1] as ProductWarehouse,
|
||||
};
|
||||
|
||||
// Helper untuk Delivery Item (DO) Detail
|
||||
const doDelivery1: BaseDelivery[] = [
|
||||
{
|
||||
product_warehouse: dummyProductWarehouses[0] as ProductWarehouse,
|
||||
qty: soItem1.qty,
|
||||
unit_price: soItem1.unit_price,
|
||||
total_weight: soItem1.total_weight,
|
||||
avg_weight: soItem1.avg_weight,
|
||||
total_price: soItem1.total_price,
|
||||
vehicle_number: 'B 1234 ABC',
|
||||
},
|
||||
];
|
||||
|
||||
const doDelivery2: BaseDelivery[] = [
|
||||
{
|
||||
product_warehouse: dummyProductWarehouses[1] as ProductWarehouse,
|
||||
qty: soItem2.qty,
|
||||
unit_price: soItem2.unit_price,
|
||||
total_weight: soItem2.total_weight,
|
||||
avg_weight: soItem2.avg_weight,
|
||||
total_price: soItem2.total_price,
|
||||
vehicle_number: 'D 5678 EFG',
|
||||
},
|
||||
];
|
||||
|
||||
// Helper untuk Delivery Order (DO) Header
|
||||
const deliveryOrder1: BaseDeliveryOrder[] = [
|
||||
{
|
||||
id: 1,
|
||||
status: 'APPROVED',
|
||||
marketing_id: 3,
|
||||
do_number: 'DO-003-2025',
|
||||
delivery_date: tomorrow,
|
||||
warehouse: dummyWarehouses[0],
|
||||
deliveries: doDelivery1,
|
||||
},
|
||||
];
|
||||
|
||||
export const dummyMarketings: Marketing[] = [
|
||||
// 1. Pengajuan Order (Langkah Pertama/Awal)
|
||||
{
|
||||
id: 1,
|
||||
status: 'DRAFT',
|
||||
name: 'SO-001-2025',
|
||||
so_date: format(new Date(), 'yyyy-MM-dd'),
|
||||
so_date: today,
|
||||
customer: {
|
||||
id: 1,
|
||||
name: 'PT Maju Jaya',
|
||||
@@ -189,50 +288,31 @@ export const dummyMarketings: Marketing[] = [
|
||||
email: 'contact@majujaya.com',
|
||||
account_number: '1234567890',
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
sales_person_id: createdUser.id,
|
||||
notes: 'Pengiriman awal bulan.',
|
||||
approval: {
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Customer,
|
||||
sales_person: createdUser,
|
||||
notes: 'Pengajuan Order Awal, menunggu persetujuan harga.',
|
||||
latest_approval: {
|
||||
step_number: 1,
|
||||
step_name: 'Pengajuan Order',
|
||||
action: 'APPROVED',
|
||||
action: 'CREATED',
|
||||
action_by: createdUser,
|
||||
action_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
marketing_products: [
|
||||
{
|
||||
id: 1,
|
||||
qty: 100,
|
||||
unit_price: 75000,
|
||||
avg_weight: 2.5,
|
||||
total_weight: 250,
|
||||
total_price: 7500000,
|
||||
product_warehouse: dummyProductWarehouses[0],
|
||||
delivery_product: {
|
||||
id: 1,
|
||||
qty: 100,
|
||||
unit_price: 75000,
|
||||
avg_weight: 2.5,
|
||||
total_weight: 250,
|
||||
total_price: 7500000,
|
||||
delivery_date: format(new Date(), 'yyyy-MM-dd'),
|
||||
vehicle_number: 'B 1234 XY',
|
||||
},
|
||||
},
|
||||
],
|
||||
action_at: now,
|
||||
} as BaseApproval,
|
||||
sales_order: [soItem1],
|
||||
delivery_order: [],
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Marketing,
|
||||
|
||||
// Step 2: Sales Order
|
||||
// 2. Sales Order (Disetujui dan Siap DO)
|
||||
{
|
||||
id: 2,
|
||||
status: 'APPROVED',
|
||||
name: 'SO-002-2025',
|
||||
so_date: format(new Date(), 'yyyy-MM-dd'),
|
||||
so_date: today,
|
||||
customer: {
|
||||
id: 2,
|
||||
name: 'CV Sumber Sehat',
|
||||
@@ -244,50 +324,32 @@ export const dummyMarketings: Marketing[] = [
|
||||
email: 'info@sumbersehat.com',
|
||||
account_number: '9876543210',
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
sales_person_id: createdUser.id,
|
||||
notes: 'Pesanan kedua untuk stok akhir tahun.',
|
||||
approval: {
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Customer,
|
||||
sales_person: createdUser,
|
||||
notes: 'Sales Order telah disetujui oleh Supervisor.',
|
||||
latest_approval: {
|
||||
id: 2,
|
||||
step_number: 2,
|
||||
step_name: 'Sales Order',
|
||||
action: 'APPROVED',
|
||||
action_by: createdUser,
|
||||
action_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
marketing_products: [
|
||||
{
|
||||
id: 2,
|
||||
qty: 50,
|
||||
unit_price: 75000,
|
||||
avg_weight: 2.5,
|
||||
total_weight: 125,
|
||||
total_price: 3750000,
|
||||
product_warehouse: dummyProductWarehouses[1],
|
||||
delivery_product: {
|
||||
id: 2,
|
||||
qty: 50,
|
||||
unit_price: 75000,
|
||||
avg_weight: 2.5,
|
||||
total_weight: 125,
|
||||
total_price: 3750000,
|
||||
delivery_date: format(new Date(), 'yyyy-MM-dd'),
|
||||
vehicle_number: 'B 5678 YZ',
|
||||
},
|
||||
},
|
||||
],
|
||||
action_at: now,
|
||||
} as BaseApproval,
|
||||
sales_order: [soItem2],
|
||||
delivery_order: [], // Belum ada pengiriman (DO) yang dibuat
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Marketing,
|
||||
|
||||
// Step 3: Delivery Order
|
||||
// 3. Delivery Order (Proses Pengiriman telah dibuat)
|
||||
{
|
||||
id: 3,
|
||||
status: 'APPROVED',
|
||||
status: 'DELIVERED', // Asumsi status DELIVERED berarti DO sudah selesai/terbuat
|
||||
name: 'SO-003-2025',
|
||||
so_date: format(new Date(), 'yyyy-MM-dd'),
|
||||
so_date: today,
|
||||
customer: {
|
||||
id: 3,
|
||||
name: 'UD Ternak Sejahtera',
|
||||
@@ -299,60 +361,23 @@ export const dummyMarketings: Marketing[] = [
|
||||
email: 'halo@ternaksejahtera.com',
|
||||
account_number: '1122334455',
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
sales_person_id: createdUser.id,
|
||||
notes: 'Order untuk pengiriman ke luar kota.',
|
||||
approval: {
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Customer,
|
||||
sales_person: createdUser,
|
||||
notes: 'Pengiriman barang telah berhasil dilakukan.',
|
||||
latest_approval: {
|
||||
id: 3,
|
||||
step_number: 3,
|
||||
step_name: 'Delivery Order',
|
||||
action: 'APPROVED',
|
||||
action: 'COMPLETED',
|
||||
action_by: createdUser,
|
||||
action_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
marketing_products: [
|
||||
{
|
||||
id: 3,
|
||||
qty: 80,
|
||||
unit_price: 70000,
|
||||
avg_weight: 2.4,
|
||||
total_weight: 192,
|
||||
total_price: 5600000,
|
||||
product_warehouse: dummyProductWarehouses[0],
|
||||
delivery_product: {
|
||||
id: 3,
|
||||
qty: 80,
|
||||
unit_price: 70000,
|
||||
avg_weight: 2.4,
|
||||
total_weight: 192,
|
||||
total_price: 5600000,
|
||||
delivery_date: format(new Date(), 'yyyy-MM-dd'),
|
||||
vehicle_number: 'D 9090 ZZ',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
qty: 80,
|
||||
unit_price: 70000,
|
||||
avg_weight: 2.4,
|
||||
total_weight: 192,
|
||||
total_price: 5600000,
|
||||
product_warehouse: dummyProductWarehouses[0],
|
||||
delivery_product: {
|
||||
id: 3,
|
||||
qty: 80,
|
||||
unit_price: 70000,
|
||||
avg_weight: 2.4,
|
||||
total_weight: 192,
|
||||
total_price: 5600000,
|
||||
delivery_date: format(new Date(), 'yyyy-MM-dd'),
|
||||
vehicle_number: 'D 9090 ZZ',
|
||||
},
|
||||
},
|
||||
],
|
||||
action_at: now,
|
||||
} as BaseApproval,
|
||||
sales_order: [soItem1, soItem2],
|
||||
delivery_order: deliveryOrder1, // DO sudah terbuat
|
||||
created_user: createdUser,
|
||||
created_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
updated_at: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||
},
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
} as Marketing,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user