From 9875239d5437443192aa18aaa16546254d157162 Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Thu, 29 May 2025 16:37:25 +0530 Subject: [PATCH] Refactor aisle properties and types in builder store - Updated AisleProperties component to include new properties for dashed, dotted, and arrows aisles. - Added new handlers for dash length, gap length, dot radius, and aisle length changes. - Enhanced aisle type management in AisleCreator to handle new aisle types and their properties. - Introduced type-specific setters in useAisleStore for better aisle property management. - Updated builderTypes to define specific interfaces for each aisle type. - Improved rendering logic for advanced properties based on selected aisle type. --- .../properties/AisleProperties.tsx | 241 +++++++++++------- .../instance/aisleTypes/arrowsAisle.tsx | 8 +- .../instance/aisleTypes/dashedAisle.tsx | 6 +- .../instance/aisleTypes/dottedAisle.tsx | 6 +- .../instance/aisleTypes/solidAisle.tsx | 2 +- .../aisle/aisleCreator/aisleCreator.tsx | 123 ++++++++- .../aisle/aisleCreator/referenceAisle.tsx | 130 +++++++--- .../simulation/events/arrows/arrows.tsx | 2 +- app/src/store/builder/useAisleStore.ts | 102 +++++++- app/src/store/builder/useBuilderStore.ts | 81 ++++++ app/src/types/builderTypes.d.ts | 67 ++++- 11 files changed, 609 insertions(+), 159 deletions(-) diff --git a/app/src/components/layout/sidebarRight/properties/AisleProperties.tsx b/app/src/components/layout/sidebarRight/properties/AisleProperties.tsx index c277812..f354844 100644 --- a/app/src/components/layout/sidebarRight/properties/AisleProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/AisleProperties.tsx @@ -23,39 +23,20 @@ interface TextureItem { const AisleProperties: React.FC = () => { const [collapsePresets, setCollapsePresets] = useState(false); const [collapseTexture, setCollapseTexture] = useState(true); - const { aisleType, aisleWidth, aisleColor, setAisleType, setAisleColor, setAisleWidth } = useBuilderStore(); + + const { aisleType, aisleWidth, aisleColor, dashLength, gapLength, dotRadius, aisleLength, setAisleType, setAisleColor, setAisleWidth, setDashLength, setGapLength, setDotRadius, setAisleLength } = useBuilderStore(); const aisleTextureList: TextureItem[] = [ - { - color: "yellow", - id: "yellow1", - brief: "pedestrian walkways", - texture: "", - }, + { color: "yellow", id: "yellow1", brief: "pedestrian walkways", texture: "" }, { color: "gray", id: "gray", brief: "basic", texture: "" }, { color: "green", id: "green1", brief: "pedestrian walkways", texture: "" }, { color: "orange", id: "orange", brief: "material flow", texture: "" }, { color: "blue", id: "blue", brief: "vehicle paths", texture: "" }, { color: "purple", id: "purple", brief: "material flow", texture: "" }, { color: "red", id: "red", brief: "safety zone", texture: "" }, - { - color: "bright green", - id: "bright-green", - brief: "safety zone", - texture: "", - }, - { - color: "yellow-black", - id: "yellow-black", - brief: "utility aisles", - texture: "", - }, - { - color: "white-black", - id: "white-black", - brief: "utility aisles", - texture: "", - }, + { color: "bright green", id: "bright-green", brief: "safety zone", texture: "" }, + { color: "yellow-black", id: "yellow-black", brief: "utility aisles", texture: "" }, + { color: "white-black", id: "white-black", brief: "utility aisles", texture: "" }, ]; const aisleTypes: { @@ -64,77 +45,148 @@ const AisleProperties: React.FC = () => { id: string; thumbnail: string; }[] = [ - { - name: "Solid", - type: "solid-aisle", - id: "1", - thumbnail: Solid, - }, - { - name: "Dotted", - type: "dotted-aisle", - id: "2", - thumbnail: Dotted, - }, - { - name: "Dashed", - type: "dashed-aisle", - id: "3", - thumbnail: Dashed, - }, - { - name: "Arrow", - type: "arrow-aisle", - id: "4", - thumbnail: Arrow, - }, - { - name: "Contiuous Arrows", - type: "arrows-aisle", - id: "5", - thumbnail: Arrows, - }, - { - name: "Directional", - type: "junction-aisle", - id: "6", - thumbnail: Directional, - }, - { - name: "Arc", - type: "arc-aisle", - id: "7", - thumbnail: Arc, - }, - { - name: "Circle", - type: "circle-aisle", - id: "8", - thumbnail: Circle, - }, + { name: "Solid", type: "solid-aisle", id: "1", thumbnail: Solid }, + { name: "Dotted", type: "dotted-aisle", id: "2", thumbnail: Dotted }, + { name: "Dashed", type: "dashed-aisle", id: "3", thumbnail: Dashed }, + { name: "Arrow", type: "arrow-aisle", id: "4", thumbnail: Arrow }, + { name: "Continuous Arrows", type: "arrows-aisle", id: "5", thumbnail: Arrows }, + { name: "Directional", type: "junction-aisle", id: "6", thumbnail: Directional }, + { name: "Arc", type: "arc-aisle", id: "7", thumbnail: Arc }, + { name: "Circle", type: "circle-aisle", id: "8", thumbnail: Circle }, ]; const handleAisleWidthChange = (value: string) => { const width = parseFloat(value); - if (isNaN(width)) { - return; + if (!isNaN(width)) { + setAisleWidth(width); } - setAisleWidth(width); - } + }; + + const handleDashLengthChange = (value: string) => { + const length = parseFloat(value); + if (!isNaN(length)) { + setDashLength(length); + } + }; + + const handleGapLengthChange = (value: string) => { + const length = parseFloat(value); + if (!isNaN(length)) { + setGapLength(length); + } + }; + + const handleDotRadiusChange = (value: string) => { + const radius = parseFloat(value); + if (!isNaN(radius)) { + setDotRadius(radius); + } + }; + + const handleAisleLengthChange = (value: string) => { + const length = parseFloat(value); + if (!isNaN(length)) { + setAisleLength(length); + } + }; + + const renderAdvancedProperties = () => { + switch (aisleType) { + case 'dashed-aisle': + return ( + <> + {aisleType && + <> + + + + } + + ); + case 'dotted-aisle': + return ( + <> + {aisleType && + <> + + + } + + ); + case 'arrows-aisle': + return ( + <> + {aisleType && + <> + + + } + + ); + default: + return null; + } + }; return (
Properties
+ + {/* Basic Properties */}
- + {aisleType !== 'dotted-aisle' && + + } + {renderAdvancedProperties()}
{/* Presets */} @@ -154,12 +206,9 @@ const AisleProperties: React.FC = () => { {aisleTypes.map((val) => (
@@ -177,10 +226,7 @@ const AisleProperties: React.FC = () => { aria-expanded={!collapseTexture} >
Aisle Texture
-
+
@@ -191,8 +237,7 @@ const AisleProperties: React.FC = () => {