feat: add profile route and sidebar navigation; implement inventory and view product pages
- Added a new profile route under the hidden layout. - Introduced a Sidebar component for navigation between inventory, add product, and profile pages. - Created InventoryPage to display a list of products with sorting and pagination. - Implemented ViewProduct page to show details of a selected product. - Integrated API calls for fetching products and product details. - Updated route tree to include new routes and components.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { API_BASE } from "../config/api.config";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
export const getProducts = async () => {
|
||||
const result = await fetch(`${API_BASE}/products/all-products`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${Cookies.get("token") || ""}`,
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
const response = await result.json();
|
||||
|
||||
if (response.code === "ep002") {
|
||||
return { success: false, code: response.code };
|
||||
}
|
||||
|
||||
if (response.code === "sp002") {
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
|
||||
export const getProductDetails = async (uuid: string) => {
|
||||
const result = await fetch(`${API_BASE}/products/view?uuid=${uuid}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${Cookies.get("token") || ""}`,
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
const response = await result.json();
|
||||
|
||||
if (response.code === "ep003") {
|
||||
return { success: false, code: response.code };
|
||||
}
|
||||
|
||||
if (response.code === "sp003") {
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user