feat: add product generation and pagination components

- Implemented product generation for categories with a helper function to create 50 products per category.
- Added image assets for English and Persian language support.
- Created a reusable Pagination component for navigating through product lists.
- Developed ProductList component to display products with pagination support.
- Defined TypeScript interfaces for product list props and API response structure.
This commit is contained in:
2025-06-08 15:52:05 +03:30
parent 929960b26f
commit 7073310a22
31 changed files with 424 additions and 205 deletions
+4 -16
View File
@@ -1,30 +1,18 @@
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
headers: {
'Content-Type': 'application/json',
},
withCredentials: true, // Enable sending cookies with requests
});
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;