import React, { useState, useEffect } from "react"; import { Button } from "@mui/material"; import axios from "axios"; // import { API } from "src/API"; // import { isAutheticated } from "../../components/auth/authhelper"; import { Link, useNavigate } from "react-router-dom"; import { CCard, CCardBody, CCardGroup, CCol, CContainer, CRow, } from "@coreui/react"; import ProductDetails from "./Productcomponents/ProductDetails.js"; import ProductVarients from "./Productcomponents/ProductVarients.js"; import ProductsImages from "./Productcomponents/ProductImages.js"; import { isAutheticated } from "src/auth.js"; // import ReleventProduct from "./Productcomponents/ReleventProduct"; // import ProductFabric from "./Productcomponents/ProductFabric.js"; const AddProduct = () => { const token = isAutheticated(); const [productId, setProductId] = useState(""); const [viewState, setViewState] = useState(1); const [images, setImages] = useState([]); const [categories, setCategories] = useState([]); const [taxes, setTaxes] = useState([]); const [sizes, setSizes] = useState([]); const [relevantProduct, setRelevantProduct] = useState([]); const [allreleventSelectedProduct, setallReleventSelectedProduct] = useState( [] ); const navigate = useNavigate(); const [loading, setLoading] = useState(false); const [data, setData] = useState({ name: "", category: "", // sku: "", description: "", master_price: "", // discontinue_on: "", // hsn_code: "", product_Status: "", special_instructions: "", // productImages.length == 0 || // gst_amount === "" || // price === "" || // totalAmt === "" || // gst_amount === "" || }); const [varients, setVarients] = useState([ { variant_Name: "", weight: "", volume: "", price: "", gst_Id: "", }, { variant_Name: "", weight: "", volume: "", price: "", gst_Id: "", }, { variant_Name: "", weight: "", volume: "", price: "", gst_Id: "", }, ]); const [allFabrics, setAllFabrics] = useState([]); const [fabrics, setFabrics] = useState([ { _id: "", fabric_Name: "", for_Part: "" }, { _id: "", fabric_Name: "", for_Part: "" }, { _id: "", fabric_Name: "", for_Part: "" }, ]); const getCategories = () => { axios .get(`/api/category/getCategories`, { headers: { "Access-Control-Allow-Origin": "*", Authorization: `Bearer ${token}`, }, }) .then((res) => { setCategories(res?.data?.categories); setLoading(false); }) .catch((err) => { setLoading(false); }); }; const getTaxes = () => { axios .get(`/api/tax/view_tax`, { headers: { "Access-Control-Allow-Origin": "*", Authorization: `Bearer ${token}`, }, }) .then((res) => { setTaxes(res.data); }); }; // const getSizes = () => { // axios // .get(`/api/erp/sizemaster/size`, { // headers: { // "Access-Control-Allow-Origin": "*", // Authorization: `Bearer ${token}`, // }, // }) // .then((res) => { // setSizes(res.data?.data); // }); // }; // const getItemWhichcontaiNameFabric = () => { // axios // .get(`/api/erp/item/name_contain_fabric`, { // headers: { // "Access-Control-Allow-Origin": "*", // Authorization: `Bearer ${token}`, // }, // }) // .then((res) => { // console.log(res?.data); // // setSizes(res.data?.data) // setAllFabrics(res?.data?.data); // }) // .catch((err) => { // console.log(err); // }); // }; // const getProductsData = async () => { // axios // .get(`/api/product`, { // headers: { // Authorization: `Bearer ${token}`, // }, // }) // .then((res) => { // setRelevantProduct(res.data?.data); // }) // .catch((err) => { // console.log(err); // }); // }; useEffect(() => { getCategories(); getTaxes(); // getSizes(); // getProductsData(); // getItemWhichcontaiNameFabric(); }, []); const handleView = (n) => { if (viewState === n) return; setViewState(n); }; return (
Add Product : {data?.name && data?.name}
{viewState === 1 && ( )} {viewState === 2 && ( )} {viewState === 3 && ( )} {/* {viewState === 4 && ( )} {viewState === 5 && ( )} */} {/* {viewState === 5 && ( )} */}
{/* */} {/* */}
); }; export default AddProduct;