Skip to content

Commit

Permalink
attempt to fix json api call
Browse files Browse the repository at this point in the history
  • Loading branch information
mattk committed Aug 6, 2024
1 parent 012fe20 commit 1ddac2b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
"use client";

import { useState, useEffect } from 'react';
import { RogueApp } from '../lib/types';
import styles from '../styles/Home.module.css';
import Callout from './components/Callout';
import { getRogueApps } from '../lib/getRogueApps';

export async function getStaticProps() {
const rogueApps = getRogueApps();
return {
props: {
rogueApps,
},
};
}

export default function Home({ rogueApps }: { rogueApps: RogueApp[] }) {
export default function Home() {
const [rogueApps, setRogueApps] = useState<RogueApp[]>([]);
const [searchTerm, setSearchTerm] = useState('');
const [expandedCard, setExpandedCard] = useState<number | null>(null);

useEffect(() => {
async function fetchRogueApps() {
const res = await fetch('/rogueapps.json');
const data: RogueApp[] = await res.json();
setRogueApps(data);
}
fetchRogueApps();
}, []);

const filteredApps = rogueApps.filter(app =>
app.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
app.description.toLowerCase().includes(searchTerm.toLowerCase()) ||
Expand Down

0 comments on commit 1ddac2b

Please sign in to comment.