|
1 | 1 | "use client"; |
2 | | -import React, { useState } from 'react'; |
| 2 | +import React, { useState, useEffect } from 'react'; |
3 | 3 | import { Search } from 'lucide-react'; |
4 | 4 | import ProductNavbar from '../../../components/Global/ProductsNavbar'; |
5 | 5 |
|
@@ -112,44 +112,26 @@ const DeveloperProductsPage = () => { |
112 | 112 | const [selectedCategory, setSelectedCategory] = useState(null); |
113 | 113 | const [selectedFocus, setSelectedFocus] = useState(null); |
114 | 114 | const [selectedTab, setSelectedTab] = useState("All Products"); |
115 | | - const products = [ |
116 | | - { |
117 | | - title: "Android", |
118 | | - description: "Modern tools to help you build experiences that people love across every Android device.", |
119 | | - image: "/devprod1.jpeg", |
120 | | - link: "#", |
121 | | - }, |
122 | | - { |
123 | | - title: "Google Cloud", |
124 | | - description: "New customers get $300 in free credits to deploy dynamic websites and launch VMs.", |
125 | | - image: "/devprod2.png", |
126 | | - link: "#", |
127 | | - }, |
128 | | - { |
129 | | - title: "Google AI Studio", |
130 | | - description: "Build generative AI applications quickly with Gemini in Google AI Studio.", |
131 | | - image: "/devprod3.jpeg", |
132 | | - link: "#", |
133 | | - }, |
134 | | - { |
135 | | - title: "ChromeOS", |
136 | | - description: "Modern tools and features to help you build high-quality web experiences.", |
137 | | - image: "/devprod4.png", |
138 | | - link: "#", |
139 | | - }, |
140 | | - { |
141 | | - title: "Android Studio", |
142 | | - description: "An integrated development environment (IDE) optimized for Android apps.", |
143 | | - image: "/devprod5.jpeg", |
144 | | - link: "#", |
145 | | - }, |
146 | | - { |
147 | | - title: "Firebase Cloud Messaging", |
148 | | - description: "A cross-platform messaging solution to reliably send messages at no cost.", |
149 | | - image: "/devprod6.jpeg", |
150 | | - link: "#", |
151 | | - }, |
152 | | - ]; |
| 115 | + const [products, setProducts] = useState([]); |
| 116 | + |
| 117 | + // Fetch products data from JSON server |
| 118 | + useEffect(() => { |
| 119 | + const fetchProducts = async () => { |
| 120 | + try { |
| 121 | + const response = await fetch('http://localhost:5000/devproducts'); |
| 122 | + if (!response.ok) { |
| 123 | + throw new Error(`HTTP error! status: ${response.status}`); |
| 124 | + } |
| 125 | + const data = await response.json(); |
| 126 | + setProducts(data || []); |
| 127 | + } catch (error) { |
| 128 | + console.error('Error fetching products:', error); |
| 129 | + setProducts([]); // Optional: Set an empty array if fetching fails |
| 130 | + } |
| 131 | + }; |
| 132 | + |
| 133 | + fetchProducts(); |
| 134 | + }, []); |
153 | 135 |
|
154 | 136 | return ( |
155 | 137 | <div> |
|
0 commit comments