This commit is contained in:
g
2025-02-07 14:09:21 +00:00
parent 717451ac9f
commit 6158f232db
6 changed files with 111 additions and 47 deletions

View File

@@ -33,10 +33,18 @@ export default function ProductsPage() {
// Fetch products and categories
useEffect(() => {
const authToken = document.cookie
.split("; ")
.find((row) => row.startsWith("Authorization="))
?.split("=")[1];
if (!authToken) {
router.push("/login");
return;
}
const fetchDataAsync = async () => {
try {
const authToken = document.cookie.split("Authorization=")[1];
const [fetchedProducts, fetchedCategories] = await Promise.all([
fetchProductData(
`${process.env.NEXT_PUBLIC_API_URL}/products`,