diff --git a/frontend/src/pages/home.tsx b/frontend/src/pages/home.tsx index c0d7faa..ecf59af 100644 --- a/frontend/src/pages/home.tsx +++ b/frontend/src/pages/home.tsx @@ -1,48 +1,43 @@ -import { Box, Container, Typography, Button } from '@mui/material' +import { Box, Container, Typography } from '@mui/material' +import Button from '@mui/material/Button' import type { NextPage } from 'next' +import Link from 'next/link' import { useState, useEffect } from 'react' import ArticleCard from '@/components/ArticleCard' -import Error from '@/components/Error' import Loading from '@/components/Loading' +import { ky } from '@/libs/ky' type ArticleProps = { - id: number title: string - content: string + summary: string + company_name: string url: string } const Index: NextPage = () => { const [articles, setArticles] = useState([]) const [loading, setLoading] = useState(true) - const [error, setError] = useState(false) - const [itemsToShow, setItemsToShow] = useState(30) + const [readMoreDisabled, setReadMoreDisabled] = useState(false) useEffect(() => { - fetch('https://jsonplaceholder.typicode.com/photos') - .then((response) => { - if (!response.ok) { - return - } - return response.json() + ky.get('./api/press-release/recommend') + .then((v) => { + return v.json< + { + title: string + summary: string + company_name: string + url: string + }[] + >() }) - .then((data) => { - setArticles(data) - setLoading(false) - }) - .catch((error) => { - console.error('Error fetching data:', error) - setError(true) + .then((value) => { setLoading(false) + setArticles(value) }) }, []) - const handleLoadMore = () => { - setItemsToShow(itemsToShow + 30) - } - if (loading) return - if (error) return return ( @@ -51,28 +46,48 @@ const Index: NextPage = () => { component="h1" sx={{ textAlign: 'center', mb: 2, color: 'text.primary' }} > - オススメ記事 + カスタマイズされたプレスリリースを見る - あなたが気になる記事を選ぼう + あなたが気になる記事を見よう - {articles.slice(0, itemsToShow).map((article) => ( - + {articles.map((article, id) => ( + ))} - {itemsToShow < articles.length && ( - - - - )} + + + )