import React, { useState, useEffect } from "react"; import { Button } from "@mui/material"; import axios from "axios"; import { Link, useNavigate } from "react-router-dom"; import { CCard, CCardBody, CCardGroup, CCol, CContainer, CRow } from "@coreui/react"; import ProductDetails from "./Productcomponents/ProductDetails.js"; import ProductsImages from "./Productcomponents/ProductImages.js"; import { isAutheticated } from "src/auth.js"; const AddProduct = () => { const token = isAutheticated(); const [productId, setProductId] = useState(""); const [viewState, setViewState] = useState(1); const [images, setImages] = useState([]); const [categories, setCategories] = useState([]); const [brands, setBrands] = useState([]); const [loading, setLoading] = useState(false); const [data, setData] = useState({ SKU:"", name: "", category: "", brand: "", description: "", price: "", GST: "", HSN_Code: "", product_Status: "Active", }); const getCategories = () => { axios .get(`/api/category/getCategories`, { headers: { "Access-Control-Allow-Origin": "*", Authorization: `Bearer ${token}`, }, }) .then((res) => { setCategories(res?.data?.categories); setLoading(false); }) .catch(() => { setLoading(false); }); }; const getbrands = () => { axios .get(`/api/brand/getBrands`, { headers: { "Access-Control-Allow-Origin": "*", Authorization: `Bearer ${token}`, }, }) .then((res) => { setBrands(res?.data?.brands); setLoading(false); }) .catch(() => { setLoading(false); }); }; useEffect(() => { getCategories(); getbrands(); }, []); const handleView = (n) => { if (viewState === n) return; setViewState(n); }; return (
Add Product : {data?.name && data?.name}
{viewState === 1 && ( )} {viewState === 3 && ( )} {/*
*/}
); }; export default AddProduct;