Skip to content

Commit

Permalink
✨ Update
Browse files Browse the repository at this point in the history
  • Loading branch information
kento committed Sep 15, 2023
1 parent de5fbd3 commit 822ac7b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 7 deletions.
10 changes: 8 additions & 2 deletions pages/api/ac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ export default async function handler(
const time = new Date()
const unix = Math.floor(time.getTime() / 1000) - 31536000

const response = await fetch(`https://kenkoooo.com/atcoder/atcoder-api/v3/user/submissions?user=kento_0225&from_second=${unix}`);
const response = await fetch(`${process.env.ATCODER_PROBLEMS_API}&from_second=${unix}`);

const data = await response.json()

res.status(200).json({ data: data })
const acData = data.filter((d: any) => {
return d.result === "AC"
})

console.log(acData)

res.status(200).json({ data: acData })
} catch (e) {
res.status(500)
}
Expand Down
2 changes: 1 addition & 1 deletion pages/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Header = () => {
<p className={Styles.name}>Kento Yoshizu</p>
<h1 className={Styles.headerTitle}>Portfolio Website</h1>
<p className={Styles.message}>I <FontAwesomeIcon icon={faHeart} /> HTML & CSS</p>
<p className={Styles.update}>更新日 : <time className={Styles.date} dateTime="2023-07-27">2023年7月27日</time></p>
<p className={Styles.update}>更新日 : <time className={Styles.date} dateTime="2023-07-27">2023年9月16日</time></p>

<Link
className={Styles.arrowContainer}
Expand Down
55 changes: 52 additions & 3 deletions pages/components/ac.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
import { useEffect, useState } from "react"
import { useState } from "react"
import Container from "./container"

const Ac = () => {
const [data, setData] = useState(null);
const [box, setBox] = useState<any>(null);

const handleClick = async () => {
const res = await fetch("/api/ac");

const { data } = await res.json();

formatData(data)
}

const formatData = (data: any) => {
const today = new Date()

const firstDate = today.getFullYear()-1

// console.log(today.toLocaleDateString(), firstDate.toLocaleString())

setData(data)
}

// 1年前から今日までの日付
function displayDates(startDate: any) {
const currentDate = new Date("2022-07-01");
const today = new Date();

const tmp = [];

while (currentDate <= today) {
const obj = {
date: currentDate.toLocaleDateString(),
status: "none"
}

tmp.push(obj);
currentDate.setDate(currentDate.getDate() + 1);
}

setBox(tmp)
}

return (
<>
<Container>
<h1>AC Test</h1>

<button
Expand All @@ -21,6 +53,12 @@ const Ac = () => {
click me
</button>

<button
onClick={displayDates}
>
1年間の日付
</button>

<div>
{data && (
<ul>
Expand All @@ -31,7 +69,18 @@ const Ac = () => {
</ul>
)}
</div>
</>

{box && (
<>
{box.map((b: any) => (
<>
<p key={`date=${b}`}>{b.date}</p>
<p key={`date=${b}`}>{b.status}</p>
</>
))}
</>
)}
</Container>
)
}

Expand Down
2 changes: 1 addition & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const Home = () => {
url="https://bookstogive-kento-yoshidu.vercel.app/"
title="BooksToGive"
text="読み終わって引き取り手を探している本をリストアップするサイトです。"
technologies={["Next.js", "TypeScript", "Tailwind CSS", "Prisma", "Supabase", "Vercel", "Google Books API"]}
technologies={["Next.js", "TypeScript", "Tailwind CSS", "Zustand", "Prisma", "Supabase", "Vercel", "Google Books API"]}
/>

<AppsAndSites
Expand Down

0 comments on commit 822ac7b

Please sign in to comment.