import axios from 'axios';

const WC_URL = process.env.REACT_APP_WC_URL;
const WC_CONSUMER_KEY = process.env.REACT_APP_WC_CONSUMER_KEY;
const WC_CONSUMER_SECRET = process.env.REACT_APP_WC_CONSUMER_SECRET;

// Create axios instance with WooCommerce API configuration
const wooCommerceAPI = axios.create({
  baseURL: `${WC_URL}/wp-json/wc/v3`,
  auth: {
    username: WC_CONSUMER_KEY,
    password: WC_CONSUMER_SECRET
  },
  timeout: 10000
});

export const WooCommerce = {
  // Get products
  get: async (endpoint, params = {}) => {
    try {
      const response = await wooCommerceAPI.get(`/${endpoint}`, { params });
      return { data: response.data };
    } catch (error) {
      console.error('WooCommerce API Error:', error);
      throw error;
    }
  },

  // Create order
  post: async (endpoint, data) => {
    try {
      const response = await wooCommerceAPI.post(`/${endpoint}`, data);
      return { data: response.data };
    } catch (error) {
      console.error('WooCommerce API Error:', error);
      throw error;
    }
  },

  // Update data
  put: async (endpoint, data) => {
    try {
      const response = await wooCommerceAPI.put(`/${endpoint}`, data);
      return { data: response.data };
    } catch (error) {
      console.error('WooCommerce API Error:', error);
      throw error;
    }
  },

  // Delete data
  delete: async (endpoint) => {
    try {
      const response = await wooCommerceAPI.delete(`/${endpoint}`);
      return { data: response.data };
    } catch (error) {
      console.error('WooCommerce API Error:', error);
      throw error;
    }
  }
};

export default WooCommerce;
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://creationphotographystudio.in/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://creationphotographystudio.in/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://creationphotographystudio.in/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://creationphotographystudio.in/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://creationphotographystudio.in/wp-sitemap-posts-wpr_mega_menu-1.xml</loc></sitemap><sitemap><loc>https://creationphotographystudio.in/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://creationphotographystudio.in/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://creationphotographystudio.in/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
