Skip to content

Commit

Permalink
Merge pull request #3 from itl-marubu/fix/endpoint
Browse files Browse the repository at this point in the history
エンドポイントの修正
  • Loading branch information
mizphses authored Jun 28, 2024
2 parents e9803c3 + c23ee64 commit f7c7cb4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
16 changes: 16 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
36 changes: 32 additions & 4 deletions src/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ paths:
$ref: '#/components/schemas/Error500'
/projects/{projectId}/list:
get:
operationId: getProjectAuthed
operationId: getProject
tags:
- Projects
summary: Get Project
Expand All @@ -161,7 +161,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/TanzakuResSchemaArray'
$ref: '#/components/schemas/TanzakuSchemaArray'
'500':
description: Internal Server Error
content:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -411,7 +439,7 @@ components:
disabled:
type: boolean
example: false
TanzakuResSchemaArray:
TanzakuSchemaArray:
type: array
items:
$ref: '#/components/schemas/TanzakuResponseSchema'
Expand Down
5 changes: 3 additions & 2 deletions src/app/_components/t2i.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -19,14 +19,15 @@ export const TanzakuToImage: React.FC = () => {
useEffect(() => {
const fetchTanzaku = async () => {
try {
const tanzakuData = await getAllTanzaku()
const tanzakuData = await getTenTanzaku()
if (tanzakuData) {
setTanzakuArray(tanzakuData)
} else {
console.error('error')
}
} catch (error) {
console.error('error', error)
location.reload()
}
}
fetchTanzaku().catch((error) => {
Expand Down
15 changes: 3 additions & 12 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CreateTanzaku } from './_components/createTanzaku'
import { Logo } from './_components/Logo'
import { QrCode } from './_components/qrcode'
import { TanzakuToImage } from './_components/t2i'
Expand All @@ -16,26 +15,18 @@ export default function Home() {
logoColor="#fff"
style={{
position: 'absolute',
width: '20%',
width: '30%',
top: '10vh',
left: '50px',
right: '50px',
}}
/>
<div style={{ position: 'absolute', bottom: '20px', right: '600px' }}>
<h2>短冊の投稿はこちらから</h2>
<QrCode
url={`${process.env.NEXT_PUBLIC_POSTSITE_BASEURL}/${process.env.NEXT_PUBLIC_EVENTID}/post`}
url={`${process.env.NEXT_PUBLIC_POSTSITE_BASEURL}/${process.env.NEXT_PUBLIC_EVENTID}`}
/>
</div>
</div>
<div className={styles.tanzakuIntro}>
<h2>ピックアップ短冊</h2>
<CreateTanzaku
textLine1="たんざくで"
textLine2="ざっくざく"
nameLine="みずさわ"
/>
</div>
</main>
)
}

0 comments on commit f7c7cb4

Please sign in to comment.