Skip to content

Commit daa0918

Browse files
authored
Merge pull request #558 from Shariq2003/JSON_DevProd
Added JSON Server Support in the Dev Products Page | Issue #493
2 parents 2b50345 + b785400 commit daa0918

File tree

2 files changed

+60
-40
lines changed

2 files changed

+60
-40
lines changed

data.json

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48365,5 +48365,43 @@
4836548365
{ "title": "Google Cloud NGFW Enterprise CyberRisk Validation Report", "description": "Read SecureIQlab's test results on Google Cloud Next Generation Firewall Enterprise." },
4836648366
{ "title": "Google is a Leader in The Forrester Wave™: AI Foundation Models for Language, Q2 2024", "description": "Access your complimentary copy of the report to learn why Google was named a Leader." },
4836748367
{ "title": "Google is a Leader in the 2024 Gartner® Magic Quadrant™ for Cloud AI Developer Services (CAIDS)", "description": "Access your complimentary copy of the report to learn why Google was named a Leader." }
48368-
]
48368+
],
48369+
"devproducts":[
48370+
{
48371+
"title": "Android",
48372+
"description": "Modern tools to help you build experiences that people love across every Android device.",
48373+
"image": "/devprod1.jpeg",
48374+
"link": "#"
48375+
},
48376+
{
48377+
"title": "Google Cloud",
48378+
"description": "New customers get $300 in free credits to deploy dynamic websites and launch VMs.",
48379+
"image": "/devprod2.png",
48380+
"link": "#"
48381+
},
48382+
{
48383+
"title": "Google AI Studio",
48384+
"description": "Build generative AI applications quickly with Gemini in Google AI Studio.",
48385+
"image": "/devprod3.jpeg",
48386+
"link": "#"
48387+
},
48388+
{
48389+
"title": "ChromeOS",
48390+
"description": "Modern tools and features to help you build high-quality web experiences.",
48391+
"image": "/devprod4.png",
48392+
"link": "#"
48393+
},
48394+
{
48395+
"title": "Android Studio",
48396+
"description": "An integrated development environment (IDE) optimized for Android apps.",
48397+
"image": "/devprod5.jpeg",
48398+
"link": "#"
48399+
},
48400+
{
48401+
"title": "Firebase Cloud Messaging",
48402+
"description": "A cross-platform messaging solution to reliably send messages at no cost.",
48403+
"image": "/devprod6.jpeg",
48404+
"link": "#"
48405+
}
48406+
]
4836948407
}

src/app/(pages)/devprod/page.jsx

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use client";
2-
import React, { useState } from 'react';
2+
import React, { useState, useEffect } from 'react';
33
import { Search } from 'lucide-react';
44
import ProductNavbar from '../../../components/Global/ProductsNavbar';
55

@@ -112,44 +112,26 @@ const DeveloperProductsPage = () => {
112112
const [selectedCategory, setSelectedCategory] = useState(null);
113113
const [selectedFocus, setSelectedFocus] = useState(null);
114114
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+
}, []);
153135

154136
return (
155137
<div>

0 commit comments

Comments
 (0)