feat: add product category components and services
- Implemented ProductCategoryCard component for displaying product categories with icons, titles, and counts. - Created ProductCategoryCardInProducts component for rendering product categories in a product context. - Defined TypeScript interfaces for product category props. - Added ProductCard component for individual product display with image and title. - Established Axios instance for API calls with request and response interceptors. - Developed services for fetching product categories and category details from the API.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import axios from 'axios';
|
||||
|
||||
// Create an Axios instance
|
||||
const api = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3000/api',
|
||||
withCredentials: true, // Send cookies with requests if needed
|
||||
});
|
||||
|
||||
api.interceptors.request.use(
|
||||
(config) => {
|
||||
// Example: Add lang cookie from browser (client-side only)
|
||||
if (typeof window !== 'undefined') {
|
||||
const match = document.cookie.match(/(^| )lang=([^;]+)/);
|
||||
if (match) {
|
||||
config.headers['lang'] = decodeURIComponent(match[2]);
|
||||
}
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => Promise.reject(error),
|
||||
);
|
||||
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
export default api;
|
||||
Reference in New Issue
Block a user