erp-platform/ui/src/mocks/mockMaterialGroups.ts

68 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-09-15 09:31:47 +00:00
import { MmMaterialGroup } from "../types/mm";
// Define your mock data
export const mockMaterialGroups: MmMaterialGroup[] = [
{
id: "1",
code: "METAL",
name: "Metal Malzemeler",
description: "Çelik, alüminyum gibi metal ürün grupları.",
isActive: true,
},
{
id: "2",
code: "MOTOR",
name: "Elektrik Motorları",
description: "AC, DC ve servo motor grupları.",
isActive: true,
},
{
id: "3",
code: "PLASTIK",
name: "Plastik Malzemeler",
isActive: true,
},
{
id: "4",
code: "KIMYA",
name: "Kimyasal Maddeler",
description: "Yağlar, solventler ve diğer kimyasallar.",
isActive: true,
},
{
id: "5",
code: "YARI-MAMUL",
name: "Yarı Mamuller",
parentGroupId: "1",
isActive: false,
},
{
id: "6",
code: "MAMUL",
name: "Mamuller",
parentGroupId: "1",
isActive: false,
},
];
// Function to populate the parentGroup field
export function populateParentGroups(groups: MmMaterialGroup[]): MmMaterialGroup[] {
const groupMap = new Map<string, MmMaterialGroup>();
// First, map each group by their id for quick lookup
groups.forEach((group) => {
groupMap.set(group.id, group);
});
// Then, for each group, set the parentGroup if it has a parentGroupId
groups.forEach((group) => {
if (group.parentGroupId) {
group.parentGroup = groupMap.get(group.parentGroupId);
}
});
return groups;
}
// Now you can use the function to populate parentGroup
populateParentGroups(mockMaterialGroups);