diff --git a/src/api/index.ts b/src/api/index.ts index 253d0af..74175da 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -20,3 +20,19 @@ export const getAllTanzaku = async () => { return res.data } + +export const getTenTanzaku = async () => { + const res = await client.GET('/tanzaku/{projectId}/show', { + params: { + path: { + projectId: process.env.NEXT_PUBLIC_EVENTID || '', + }, + }, + }) + + if (res.error) { + throw new Error(res.error) + } + + return res.data +} diff --git a/src/api/openapi.yaml b/src/api/openapi.yaml index 189c411..b553287 100644 --- a/src/api/openapi.yaml +++ b/src/api/openapi.yaml @@ -143,7 +143,7 @@ paths: $ref: '#/components/schemas/Error500' /projects/{projectId}/list: get: - operationId: getProjectAuthed + operationId: getProject tags: - Projects summary: Get Project @@ -161,7 +161,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TanzakuResSchemaArray' + $ref: '#/components/schemas/TanzakuSchemaArray' '500': description: Internal Server Error content: @@ -255,7 +255,35 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TanzakuResSchemaArray' + $ref: '#/components/schemas/TanzakuSchemaArray' + '500': + description: Internal Server Error + content: + text/plain: + schema: + $ref: '#/components/schemas/Error500' + + /tanzaku/{projectId}/show: + get: + operationId: getTanzakuPicked + tags: + - Tanzaku + summary: Get Tanzaku + description: 短冊を10個古い順に取ってくるやつ + parameters: + - name: projectId + in: path + required: true + description: ID of the project to get + schema: + type: string + responses: + '200': + description: Project found + content: + application/json: + schema: + $ref: '#/components/schemas/TanzakuSchemaArray' '500': description: Internal Server Error content: @@ -411,7 +439,7 @@ components: disabled: type: boolean example: false - TanzakuResSchemaArray: + TanzakuSchemaArray: type: array items: $ref: '#/components/schemas/TanzakuResponseSchema' diff --git a/src/app/_components/t2i.tsx b/src/app/_components/t2i.tsx index 6766c6a..5719f35 100644 --- a/src/app/_components/t2i.tsx +++ b/src/app/_components/t2i.tsx @@ -1,7 +1,7 @@ 'use client' import { useEffect, useRef, useState } from 'react' -import { getAllTanzaku } from '@/api' +import { getTenTanzaku } from '@/api' import { CreateTanzaku } from './createTanzaku' type tanzakuType = { @@ -19,7 +19,7 @@ export const TanzakuToImage: React.FC = () => { useEffect(() => { const fetchTanzaku = async () => { try { - const tanzakuData = await getAllTanzaku() + const tanzakuData = await getTenTanzaku() if (tanzakuData) { setTanzakuArray(tanzakuData) } else { @@ -27,6 +27,7 @@ export const TanzakuToImage: React.FC = () => { } } catch (error) { console.error('error', error) + location.reload() } } fetchTanzaku().catch((error) => { diff --git a/src/app/page.tsx b/src/app/page.tsx index 07134e5..e426ced 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,4 +1,3 @@ -import { CreateTanzaku } from './_components/createTanzaku' import { Logo } from './_components/Logo' import { QrCode } from './_components/qrcode' import { TanzakuToImage } from './_components/t2i' @@ -16,26 +15,18 @@ export default function Home() { logoColor="#fff" style={{ position: 'absolute', - width: '20%', + width: '30%', top: '10vh', - left: '50px', + right: '50px', }} />

短冊の投稿はこちらから

-
-

ピックアップ短冊

- -
) }