From fd973105b4ee16c370480cdd171744235550b8ff Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Thu, 23 Jun 2022 22:13:14 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20=E4=BB=AE=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=E3=81=97=E3=81=9F=E3=82=AD=E3=83=A3=E3=83=A9API?= =?UTF-8?q?=E3=82=92=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=82=92=E4=BB=AE=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/usagisan.tsx | 153 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 151 insertions(+), 2 deletions(-) diff --git a/pages/usagisan.tsx b/pages/usagisan.tsx index 1a475bdb..2cd3167e 100644 --- a/pages/usagisan.tsx +++ b/pages/usagisan.tsx @@ -1,11 +1,160 @@ import type { NextPage } from 'next' +import Link from 'next/link' +import Image from 'next/image' +import { useState } from 'react' +import axios from 'axios' + +import HumbergerNavigation from '@/components/humberger-menu/HumbergerNavigation' +import { NavBar } from '@/components/common/NavBar' +import { SiteFooter } from '@/components/common/SiteFooter' + +type CharacterDetails = { + nickname: string + character: string + products: string[] +} const Usagisan: NextPage = () => { + // const [isInitialState, setIsInitialState] = useState(true) + const [nickname, setNickname] = useState('') + const [characterDetails, setCharacterDetails] = useState( + {} as CharacterDetails + ) + const [characterDetailProducts, setCharacterDetailProducts] = useState([]) + const [nowLoading, setNowLoading] = useState(false) + + const changeNickname = (e: any) => { + setNickname(e.target.value) + } + + const clickCheckButton = () => { + const baseUrl = 'https://gss2022-stg.herokuapp.com/characters' + const apiUrl = `${baseUrl}?nickname=${nickname}` + + setNowLoading(true) + + axios + .get(apiUrl) + .then((response) => { + setCharacterDetails(response.data) + setCharacterDetailProducts(response.data.products) + }) + .catch((error) => { + console.error(error) + }) + .finally(() => { + setNowLoading(false) + // setIsInitialState(false) + }) + } + return (
- うさぎさんチーム + うさぎさんチーム - 幻水総選挙2022 +
+ +
+ +
+ +
+
    +
  • + + ホーム + +
  • +
  • うさぎさんチーム
  • +
+
+ +
+
+
+
+
+
+

+ うさぎさんチーム +

+ + <> +
+
+ { + if (e.key === 'Enter') { + clickCheckButton() + } + }} + placeholder="2主とか軍曹とか" + className="input input-bordered input-accent w-full max-w-full bg-white text-black" + value={nickname} + /> + + +
+
+ +
+ {false ? null : ( + <> + {nowLoading ? ( + 幻水総選挙スピナー + ) : ( + <> +

+ ニックネーム +

+

{characterDetails.nickname}

+
+ +

+ キャラ名 +

+

{characterDetails.character}

+
+ +

+ 作品名 +

+ {characterDetailProducts.map((product) => ( +

+ {product} +

+ ))} + + )} + + )} +
+ +
+
+
+
+
+
-
Hello, World!
+
+ +
) }