-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add check-in page (event and session)
- Loading branch information
Showing
20 changed files
with
403 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { uuid4 } from '@sentry/utils' | ||
import { ConfirmDialog } from './internal/ConfirmDialog' | ||
import { DummyCheckInButton } from './internal/DummyCheckInButton/DummyCheckInButton' | ||
import { Debug } from './internal/Debug/Debug' | ||
import { DummyCamera } from './internal/DummyCamera' | ||
import { Typography } from '@material-ui/core' | ||
|
||
type CheckInType = 'event' | 'session' | ||
|
||
type Props = { | ||
checkInType: CheckInType | ||
} | ||
|
||
export const CheckIn: React.FC<Props> = ({ checkInType }) => { | ||
const [storedKeys, setStoredKeys] = React.useState<string[]>([]) | ||
const storedKeysRef = React.useRef(storedKeys) | ||
const [open, setOpen] = useState(false) | ||
useEffect(() => { | ||
storedKeysRef.current = storedKeys | ||
}, [storedKeys]) | ||
useEffect(() => { | ||
for (const key in localStorage) { | ||
if (key.startsWith('check_in_')) { | ||
setStoredKeys((prev) => (prev.includes(key) ? prev : [...prev, key])) | ||
} | ||
} | ||
|
||
const interval = setInterval(() => { | ||
console.log('Send check-in logs to dreamkast api:') | ||
console.log(storedKeys) | ||
|
||
for (const key of storedKeysRef.current) { | ||
console.log( | ||
`Success to send check-in log: key:L ${key}, value: ${JSON.stringify( | ||
localStorage.getItem(key), | ||
)}`, | ||
) | ||
deleteItem(key) | ||
} | ||
}, 10000) | ||
return () => clearInterval(interval) | ||
}, []) | ||
|
||
const checkInConference = () => { | ||
;(async () => { | ||
const uuid = uuid4() | ||
const key = `check_in_${uuid}` | ||
const value = { | ||
checkInType: checkInType, | ||
profileId: 2, | ||
checkInTimestamp: Math.floor(Date.now() / 1000), | ||
} | ||
localStorage.setItem(key, JSON.stringify(value)) | ||
setStoredKeys((prev) => [...prev, key]) | ||
})() | ||
setOpen(true) | ||
} | ||
|
||
const handleClose = () => { | ||
setOpen(false) | ||
} | ||
|
||
const deleteItem = (key: string) => { | ||
localStorage.removeItem(key) | ||
setStoredKeys(storedKeys.filter((k) => k !== key)) | ||
} | ||
|
||
return ( | ||
<div> | ||
{/*<Camera height={100} width={100} />*/} | ||
<DummyCamera /> | ||
<DummyCheckInButton onClick={checkInConference} /> | ||
<ConfirmDialog open={open} handleClose={handleClose} /> | ||
<Typography variant="h5">↓Debug↓</Typography> | ||
<Debug storedKeys={storedKeys} deleteItem={deleteItem} /> | ||
</div> | ||
) | ||
} |
Empty file.
47 changes: 47 additions & 0 deletions
47
src/components/CheckIn/internal/ConfirmDialog/ConfirmDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogContentText, | ||
DialogTitle, | ||
IconButton, | ||
} from '@material-ui/core' | ||
import React from 'react' | ||
import { CloseIcon } from 'next/dist/client/components/react-dev-overlay/internal/icons/CloseIcon' | ||
|
||
type Props = { | ||
open: boolean | ||
handleClose: () => void | ||
} | ||
|
||
export const ConfirmDialog: React.FC<Props> = ({ open, handleClose }) => { | ||
return ( | ||
<Dialog | ||
open={open} | ||
onClose={handleClose} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
> | ||
<DialogTitle id="alert-dialog-title"> | ||
<IconButton | ||
aria-label="close" | ||
onClick={handleClose} | ||
style={{ position: 'absolute', right: '8px', top: '8px' }} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description"> | ||
チェックインが完了しました。 | ||
</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleClose} color="primary" autoFocus> | ||
確認 | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ConfirmDialog } from './ConfirmDialog' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Button, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@material-ui/core' | ||
import React from 'react' | ||
|
||
type Props = { | ||
storedKeys: string[] | ||
deleteItem: (key: string) => void | ||
} | ||
|
||
export const Debug: React.FC<Props> = ({ storedKeys, deleteItem }) => { | ||
return ( | ||
<TableContainer> | ||
<Table> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell>type</TableCell> | ||
<TableCell>profileId</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
|
||
<TableBody> | ||
{storedKeys.map((key) => { | ||
const value = localStorage.getItem(key) | ||
if (value) { | ||
const { checkInType, profileId } = JSON.parse(value) | ||
return ( | ||
<TableRow key={key}> | ||
<TableCell>{checkInType}</TableCell> | ||
<TableCell>{profileId}</TableCell> | ||
<TableCell> | ||
<Button | ||
type="submit" | ||
onClick={() => deleteItem(key)} | ||
variant="contained" | ||
> | ||
Delete | ||
</Button> | ||
</TableCell> | ||
</TableRow> | ||
) | ||
} | ||
})} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Debug } from './Debug' |
10 changes: 10 additions & 0 deletions
10
src/components/CheckIn/internal/DummyCamera/DummyCamera.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react' | ||
import * as Styled from './styled' | ||
|
||
export const DummyCamera: React.FC = () => { | ||
return ( | ||
<Styled.DummyCamera> | ||
実際にはスマートフォンで見た際ここにカメラ映像が映ります | ||
</Styled.DummyCamera> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { DummyCamera } from './DummyCamera' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import styled from 'styled-components' | ||
|
||
export const DummyCamera = styled.div` | ||
width: 500px; | ||
height: 500px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
text-align: center; | ||
border: 1px solid #000; /* Optional, just to visualize the space */ | ||
// | ||
@media (max-width: 600px) { | ||
width: 90vw; | ||
height: 90vw; | ||
} | ||
` |
14 changes: 14 additions & 0 deletions
14
src/components/CheckIn/internal/DummyCheckInButton/DummyCheckInButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react' | ||
import { Button } from '@material-ui/core' | ||
|
||
type Props = { | ||
onClick: () => void | ||
} | ||
|
||
export const DummyCheckInButton: React.FC<Props> = ({onClick}) => { | ||
return ( | ||
<Button type="submit" onClick={onClick} variant="contained"> | ||
イベントチェックイン用のダミーボタン | ||
</Button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { DummyCheckInButton } from './DummyCheckInButton' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/components/Menu/internal/AdminMobileMenu/AdminMobileMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react' | ||
import { Button, ListItem, ListItemIcon, ListItemText } from '@material-ui/core' | ||
import CheckIcon from '@material-ui/icons/Check' | ||
import KeyboardArrowRightIcon from '@material-ui/icons/KeyboardArrowRight' | ||
import * as Styled from './styled' | ||
import * as CommonStyled from '../../../../styles/styled' | ||
import { Event } from '../../../../generated/dreamkast-api.generated' | ||
|
||
type Props = { | ||
event?: Event | ||
} | ||
|
||
export const AdminMobileMenu: React.FC<Props> = ({ event }) => { | ||
return ( | ||
<div> | ||
<ListItem button> | ||
<ListItemIcon> | ||
<KeyboardArrowRightIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary="Admin" /> | ||
</ListItem> | ||
|
||
<Styled.NestedListItem button key="check_in_event"> | ||
<ListItemIcon> | ||
<CheckIcon /> | ||
</ListItemIcon> | ||
<CommonStyled.MenuLink | ||
href={`/${event?.abbr}/ui/admin/check_in_event`} | ||
rel="noreferrer noopener" | ||
> | ||
<Button style={{ color: '#423A57' }}>Check-In (Event)</Button> | ||
</CommonStyled.MenuLink> | ||
</Styled.NestedListItem> | ||
|
||
<Styled.NestedListItem button key="check_in_session"> | ||
<ListItemIcon> | ||
<CheckIcon /> | ||
</ListItemIcon> | ||
<CommonStyled.MenuLink | ||
href={`/${event?.abbr}/ui/admin/check_in_session`} | ||
rel="noreferrer noopener" | ||
> | ||
<Button style={{ color: '#423A57' }}>Check-In (Session)</Button> | ||
</CommonStyled.MenuLink> | ||
</Styled.NestedListItem> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AdminMobileMenu } from './AdminMobileMenu' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ListItem } from '@material-ui/core' | ||
import styled from 'styled-components' | ||
|
||
export const NestedListItem = styled(ListItem)` | ||
padding-left: ${(props) => `${props.theme.spacing(4)}px`}; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.