toggle screen for product configurations
This commit is contained in:
@@ -49,6 +49,16 @@ export const categoriesApi = {
|
||||
if (!name) return Promise.reject(new Error("Category name is required."))
|
||||
const category = mockCategories.find((c) => c.categoryId === categoryId)
|
||||
if (!category) return Promise.reject(new Error("Category not found."))
|
||||
if (request.parentId !== undefined) {
|
||||
const parentId = request.parentId
|
||||
if (parentId === categoryId) {
|
||||
return Promise.reject(new Error("A category cannot be its own parent."))
|
||||
}
|
||||
if (parentId !== null && !mockCategories.some((c) => c.categoryId === parentId)) {
|
||||
return Promise.reject(new Error("Selected parent category does not exist."))
|
||||
}
|
||||
category.parentId = parentId
|
||||
}
|
||||
category.name = name
|
||||
return mockDelay(category)
|
||||
},
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { Bin, Brand, Category, Item, Uom, Vendor, VariantCategory, Warehouse } from "@/types/master-data"
|
||||
import { PurchaseOrder, Quotation, Requisition, Rfq, PurchaseReturn } from "@/types/procurement"
|
||||
import { Grn } from "@/types/grn"
|
||||
import { ProductConfig } from "@/types/settings"
|
||||
import {
|
||||
AdjustmentStatus,
|
||||
CountStatus,
|
||||
@@ -14,6 +15,26 @@ import {
|
||||
TransferStatus,
|
||||
} from "@/types/stock"
|
||||
|
||||
// Company-level Product Configuration (Settings → Product Configuration). Off by
|
||||
// default except the tracking-related toggles, matching the shipped design.
|
||||
export const mockProductConfig: ProductConfig = {
|
||||
subcategories: false,
|
||||
brands: false,
|
||||
productImages: false,
|
||||
serialNumbers: true,
|
||||
batchLotTracking: true,
|
||||
expiryMfgDates: true,
|
||||
warranty: true,
|
||||
serviceItems: true,
|
||||
adHocSaleLines: true,
|
||||
minPriceFloor: false,
|
||||
maxPriceCeiling: false,
|
||||
freePricingProducts: false,
|
||||
fractionalQuantities: false,
|
||||
packConversion: true,
|
||||
allowNegativeStock: false,
|
||||
}
|
||||
|
||||
export const mockWarehouses: Warehouse[] = [
|
||||
{ warehouseId: 1, code: "WH-MAIN", name: "Main Warehouse - Negombo" },
|
||||
{ warehouseId: 2, code: "WH-COLOMBO", name: "Colombo Distribution Center" },
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Product Configuration client, mirroring lib/api/brands.ts. A single company-level
|
||||
// settings object rather than a list — in-memory sample data (lib/api/mock-data.ts),
|
||||
// no backend API calls.
|
||||
import { ProductConfig, UpdateProductConfigRequest } from "@/types/settings"
|
||||
import { mockDelay, mockProductConfig } from "@/lib/api/mock-data"
|
||||
|
||||
export const productConfigApi = {
|
||||
get(): Promise<ProductConfig> {
|
||||
return mockDelay({ ...mockProductConfig })
|
||||
},
|
||||
|
||||
update(request: UpdateProductConfigRequest): Promise<ProductConfig> {
|
||||
Object.assign(mockProductConfig, request)
|
||||
return mockDelay({ ...mockProductConfig })
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user