import React from "react";
import InputWithDropDown from "../../../../../ui/inputs/InputWithDropDown";
import LabledDropdown from "../../../../../ui/inputs/LabledDropdown";

interface StorageActionProps {
    type: "store" | "spawn" | "default";
    value: string;
    min: number;
    max?: number;
    defaultValue: string;
    currentMaterialType: string;
    handleCapacityChange: (value: string) => void;
    handleMaterialTypeChange: (value: string) => void;
}

const StorageAction: React.FC<StorageActionProps> = ({ type, value, min, max, defaultValue, currentMaterialType, handleCapacityChange, handleMaterialTypeChange }) => {
    return (
        <>
            {type === 'store' &&
                <InputWithDropDown
                    label="Storage Capacity"
                    value={value}
                    min={min}
                    step={1}
                    max={max}
                    defaultValue={defaultValue}
                    activeOption="unit"
                    onClick={() => { }}
                    onChange={handleCapacityChange}
                />
            }
            {type === 'spawn' &&
                <>
                    <InputWithDropDown
                        label="Spawn Capacity"
                        value={value}
                        min={min}
                        step={1}
                        max={max}
                        defaultValue={defaultValue}
                        activeOption="unit"
                        onClick={() => { }}
                        onChange={handleCapacityChange}
                    />
                    <LabledDropdown
                        label={"Material Type"}
                        defaultOption={currentMaterialType}
                        options={["Default material", "Material 1", "Material 2", "Material 3"]}
                        onSelect={handleMaterialTypeChange}
                    />
                </>
            }
        </>
    );
};

export default StorageAction;
