2025-05-30 09:03:55 +00:00
|
|
|
import { useEffect, useMemo } from 'react';
|
2025-05-27 12:41:26 +00:00
|
|
|
import { useAisleStore } from '../../../../store/builder/useAisleStore';
|
2025-05-30 09:03:55 +00:00
|
|
|
import { useToggleView } from '../../../../store/builder/store';
|
2025-05-27 12:41:26 +00:00
|
|
|
import AisleInstance from './instance/aisleInstance';
|
2025-05-30 09:03:55 +00:00
|
|
|
import Point from '../../point/point';
|
2025-05-27 12:41:26 +00:00
|
|
|
|
|
|
|
function AisleInstances() {
|
|
|
|
const { aisles } = useAisleStore();
|
2025-05-30 09:03:55 +00:00
|
|
|
const { toggleView } = useToggleView();
|
|
|
|
|
|
|
|
const allPoints = useMemo(() => {
|
|
|
|
const points: Point[] = [];
|
|
|
|
const seenUuids = new Set<string>();
|
|
|
|
|
|
|
|
aisles.forEach(aisle => {
|
|
|
|
aisle.points.forEach(point => {
|
|
|
|
if (!seenUuids.has(point.uuid)) {
|
|
|
|
seenUuids.add(point.uuid);
|
|
|
|
points.push(point);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return points;
|
|
|
|
}, [aisles]);
|
2025-05-27 12:41:26 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
2025-05-28 10:54:08 +00:00
|
|
|
// console.log('aisles: ', aisles);
|
2025-05-27 12:41:26 +00:00
|
|
|
}, [aisles]);
|
|
|
|
|
|
|
|
return (
|
2025-05-30 09:03:55 +00:00
|
|
|
<>
|
|
|
|
{toggleView &&
|
|
|
|
<group name='Aisle-Points-Group'>
|
|
|
|
{allPoints.map((point) => (
|
|
|
|
<Point key={point.uuid} point={point} />
|
|
|
|
))}
|
|
|
|
</group>
|
|
|
|
}
|
2025-05-27 12:41:26 +00:00
|
|
|
|
2025-05-30 09:03:55 +00:00
|
|
|
<group name='Aisles-Group'>
|
|
|
|
{aisles.map((aisle) =>
|
|
|
|
<AisleInstance aisle={aisle} key={aisle.uuid} />
|
|
|
|
)}
|
|
|
|
</group>
|
|
|
|
</>
|
2025-05-27 12:41:26 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AisleInstances
|