import React, { useState } from "react"; import GlobalModel from "../../components/common/GlobalModel"; import Stepper from "./Stepper"; import SupplierInfoStep from "./SupplierInfoStep"; import BankStep from "./BankStep"; import AddressStep from "./AddressStep"; const AddProductModal = ({ isOpen, onClose }) => { const steps = [ { key: "supplierInfo", label: "Supplier Info" }, { key: "bank", label: "Bank" }, { key: "address", label: "Address" }, ]; const [activeStepIndex, setActiveStepIndex] = useState(0); const activeStepKey = steps[activeStepIndex].key; if (!isOpen) return null; const handleNext = () => { if (activeStepIndex < steps.length - 1) setActiveStepIndex(activeStepIndex + 1); else handleSubmit(); }; const handleBack = () => { if (activeStepIndex > 0) setActiveStepIndex(activeStepIndex - 1); }; const handleSubmit = () => { console.log("Form submitted"); onClose(); }; return (
Add New Supplier
e.preventDefault()}> {activeStepKey === "supplierInfo" && } {activeStepKey === "bank" && } {activeStepKey === "address" && }
{activeStepIndex < steps.length - 1 ? ( ) : ( )}
); }; export default AddProductModal;