erp-platform/ui/src/mocks/mockMaterialGroups.ts
2025-09-15 12:31:47 +03:00

68 lines
No EOL
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);