Skip to content

Commit

Permalink
Merge pull request #521 from cloudnativedaysjp/feat/entry
Browse files Browse the repository at this point in the history
イベント受付用のページでプリンターを選択可能にする
  • Loading branch information
jacopen authored Nov 21, 2024
2 parents ba6ba60 + b835a92 commit be5c65b
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: build container image when branches are pushed

on:
push:
branches: ["*"]
branches:

jobs:
build:
Expand Down
Binary file added public/cndw2024/ui/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cndw2024/ui/cndw2024_header_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cndw2024/ui/cndw2024_trademark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cndw2024/ui/talk_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cndw2024/ui/wave.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cndw2024/ui/x_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 29 additions & 1 deletion schemas/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,26 @@ paths:
$ref: '#/components/schemas/Sponsor'
'400':
description: Invalid params supplied
/api/v1/print_node_printers:
get:
tags:
- PrintNodePrinter
parameters:
- name: eventAbbr
in: query
description: abbr of event (e.g. cndt2020)
required: true
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PrintNodePrinter'
/api/v1/booths/{boothId}:
get:
tags:
Expand Down Expand Up @@ -1578,6 +1598,8 @@ components:
type: string
checkInTimestamp:
type: number
printerId:
type: string
required:
- profileId
- eventAbbr
Expand All @@ -1598,7 +1620,13 @@ components:
- profileId
- talkId
- checkInTimestamp

PrintNodePrinter:
type: object
properties:
id:
type: string
name:
type: string

# dreamkast-function
Vote:
Expand Down
6 changes: 6 additions & 0 deletions src/components/CheckIn/CheckIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type CheckInType = 'event' | 'session'
type Props = {
checkInType: CheckInType
eventAbbr: string
printerId?: string
talk?: Talk
debug?: boolean
}
Expand All @@ -23,12 +24,14 @@ type CheckInData = {
eventAbbr: string
profileId: string
checkInTimestamp: number
printerId?: string
talkId?: string
}

export const CheckIn: React.FC<Props> = ({
checkInType,
eventAbbr,
printerId,
talk,
debug,
}) => {
Expand Down Expand Up @@ -74,6 +77,9 @@ export const CheckIn: React.FC<Props> = ({
if (checkInType === 'session') {
value.talkId = talk?.id.toString()
}
if (checkInType == 'event') {
value.printerId = printerId
}
localStorage.setItem(key, JSON.stringify(value))
setStoredKeys((prev) => [...prev, key])
}
Expand Down
23 changes: 23 additions & 0 deletions src/generated/dreamkast-api.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const addTagTypes = [
'VideoRegistration',
'ChatMessage',
'Sponsor',
'PrintNodePrinter',
'Booth',
'Point',
'Vote',
Expand Down Expand Up @@ -211,6 +212,16 @@ const injectedRtkApi = api
}),
providesTags: ['Sponsor'],
}),
getApiV1PrintNodePrinters: build.query<
GetApiV1PrintNodePrintersApiResponse,
GetApiV1PrintNodePrintersApiArg
>({
query: (queryArg) => ({
url: `/api/v1/print_node_printers`,
params: { eventAbbr: queryArg.eventAbbr },
}),
providesTags: ['PrintNodePrinter'],
}),
getApiV1BoothsByBoothId: build.query<
GetApiV1BoothsByBoothIdApiResponse,
GetApiV1BoothsByBoothIdApiArg
Expand Down Expand Up @@ -438,6 +449,12 @@ export type GetApiV1SponsorsApiArg = {
/** abbr of event (e.g. cndt2020) */
eventAbbr: string
}
export type GetApiV1PrintNodePrintersApiResponse =
/** status 200 OK */ PrintNodePrinter[]
export type GetApiV1PrintNodePrintersApiArg = {
/** abbr of event (e.g. cndt2020) */
eventAbbr: string
}
export type GetApiV1BoothsByBoothIdApiResponse = /** status 200 OK */ Booth
export type GetApiV1BoothsByBoothIdApiArg = {
/** ID of booth */
Expand Down Expand Up @@ -527,6 +544,7 @@ export type CheckInEvent = {
profileId: string
eventAbbr: string
checkInTimestamp: number
printerId?: string | undefined
}
export type CheckInTalk = {
profileId: string
Expand Down Expand Up @@ -672,6 +690,10 @@ export type Sponsor = {
}
| undefined
}
export type PrintNodePrinter = {
id?: string | undefined
name?: string | undefined
}
export type Booth = {
id: number
sponsorId: number
Expand Down Expand Up @@ -762,6 +784,7 @@ export const {
usePostApiV1ChatMessagesMutation,
usePutApiV1ChatMessagesByMessageIdMutation,
useGetApiV1SponsorsQuery,
useGetApiV1PrintNodePrintersQuery,
useGetApiV1BoothsByBoothIdQuery,
useGetApiV1ProfileByProfileIdPointsQuery,
useOptionsApiV1ProfileByProfileIdPointsMutation,
Expand Down
50 changes: 46 additions & 4 deletions src/pages/[eventAbbr]/ui/admin/check_in_event/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { NextPage } from 'next'
import React, { useMemo } from 'react'
import React, { useEffect, useMemo, useState } from 'react'
import { Layout } from '../../../../../components/Layout'
import { useGetApiV1EventsByEventAbbrQuery } from '../../../../../generated/dreamkast-api.generated'
import {
PrintNodePrinter,
useGetApiV1EventsByEventAbbrQuery,
useGetApiV1PrintNodePrintersQuery,
} from '../../../../../generated/dreamkast-api.generated'
import { useRouter } from 'next/router'
import Error404 from '../../../../404'
import { CheckIn } from '../../../../../components/CheckIn/CheckIn'
import { Typography } from '@material-ui/core'
import { MenuItem, Select, Typography } from '@material-ui/core'
import { useSelector } from 'react-redux'
import { authSelector } from '../../../../../store/auth'
import { ENV } from '../../../../../config'
Expand All @@ -30,15 +34,53 @@ const IndexMain = () => {
{ eventAbbr },
{ skip },
)
const [printers, setPrinters] = useState<PrintNodePrinter[]>([])
const { data, isLoading, isError, error } = useGetApiV1PrintNodePrintersQuery(
{ eventAbbr },
)
useEffect(() => {
if (isLoading) {
return
}
if (isError) {
throw error
}
if (data) {
console.log(data)
setPrinters(data)
}
}, [data, isLoading, isError])

const [selectedPrinter, setSelectedPrinter] =
useState<PrintNodePrinter | null>(null)
const handleSelectChange = (event: React.ChangeEvent<{ value: unknown }>) => {
setSelectedPrinter(
printers.find((printer) => printer.id === event.target.value) || null,
)
}
if (event) {
if (isAdminRole) {
return (
<Layout title={event.name} event={event}>
<Typography variant="h5">
イベント受付 ({event.abbr.toUpperCase()})
</Typography>
<CheckIn checkInType={'event'} eventAbbr={event.abbr} />
(
<Select
value={selectedPrinter ? selectedPrinter.id : 'default'}
onChange={handleSelectChange}
>
<MenuItem value="default">プリンターを選択</MenuItem>
{printers.map((printer) => {
return <MenuItem value={printer.id}>{printer.name}</MenuItem>
})}
</Select>
)
<CheckIn
checkInType={'event'}
eventAbbr={event.abbr}
printerId={selectedPrinter?.id}
/>
</Layout>
)
} else {
Expand Down

0 comments on commit be5c65b

Please sign in to comment.