|
|
@ -5,8 +5,8 @@ import { format } from 'date-fns'
|
|
|
|
import { type Dispatch, type StateUpdater } from 'preact/hooks'
|
|
|
|
import { type Dispatch, type StateUpdater } from 'preact/hooks'
|
|
|
|
|
|
|
|
|
|
|
|
type ActionCardProps = {
|
|
|
|
type ActionCardProps = {
|
|
|
|
moveUp: () => void
|
|
|
|
// moveUp: () => void
|
|
|
|
moveDown: () => void
|
|
|
|
// moveDown: () => void
|
|
|
|
|
|
|
|
|
|
|
|
remove: () => void
|
|
|
|
remove: () => void
|
|
|
|
|
|
|
|
|
|
|
@ -20,14 +20,17 @@ type Props = {
|
|
|
|
refreshRoom: () => void
|
|
|
|
refreshRoom: () => void
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const CardActions = ({ moveUp, moveDown, remove }: ActionCardProps) => (
|
|
|
|
const CardActions = ({
|
|
|
|
|
|
|
|
// moveUp, moveDown,
|
|
|
|
|
|
|
|
remove,
|
|
|
|
|
|
|
|
}: ActionCardProps) => (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<button class="square" onClick={moveUp}>
|
|
|
|
{/* <button class="square" onClick={moveUp}>
|
|
|
|
<div class="icon">arrow_upward</div>
|
|
|
|
<div class="icon">arrow_upward</div>
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
<button class="square" onClick={moveDown}>
|
|
|
|
<button class="square" onClick={moveDown}>
|
|
|
|
<div class="icon">arrow_downward</div>
|
|
|
|
<div class="icon">arrow_downward</div>
|
|
|
|
</button>
|
|
|
|
</button> */}
|
|
|
|
{/* <button class="square"
|
|
|
|
{/* <button class="square"
|
|
|
|
onClick={edit}
|
|
|
|
onClick={edit}
|
|
|
|
>
|
|
|
|
>
|
|
|
@ -118,27 +121,27 @@ export const ActionRegistry = ({ room, refreshRoom }: Props) => {
|
|
|
|
refreshRoom()
|
|
|
|
refreshRoom()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const moveActionUp = (index: number) => {
|
|
|
|
// const moveActionUp = (index: number) => {
|
|
|
|
if (index === 0) return
|
|
|
|
// if (index === 0) return
|
|
|
|
|
|
|
|
|
|
|
|
setActions(actions => {
|
|
|
|
// setActions(actions => {
|
|
|
|
const newActions = [...actions]
|
|
|
|
// const newActions = [...actions]
|
|
|
|
const [action] = newActions.splice(index, 1)
|
|
|
|
// const [action] = newActions.splice(index, 1)
|
|
|
|
newActions.splice(index - 1, 0, action)
|
|
|
|
// newActions.splice(index - 1, 0, action)
|
|
|
|
return newActions
|
|
|
|
// return newActions
|
|
|
|
})
|
|
|
|
// })
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
const moveActionDown = (index: number) => {
|
|
|
|
// const moveActionDown = (index: number) => {
|
|
|
|
if (index === room.actions.length - 1) return
|
|
|
|
// if (index === room.actions.length - 1) return
|
|
|
|
|
|
|
|
|
|
|
|
setActions(actions => {
|
|
|
|
// setActions(actions => {
|
|
|
|
const newActions = [...actions]
|
|
|
|
// const newActions = [...actions]
|
|
|
|
const [action] = newActions.splice(index, 1)
|
|
|
|
// const [action] = newActions.splice(index, 1)
|
|
|
|
newActions.splice(index + 1, 0, action)
|
|
|
|
// newActions.splice(index + 1, 0, action)
|
|
|
|
return newActions
|
|
|
|
// return newActions
|
|
|
|
})
|
|
|
|
// })
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// const editAction = (index: number) => {
|
|
|
|
// const editAction = (index: number) => {
|
|
|
|
// setEditing(index)
|
|
|
|
// setEditing(index)
|
|
|
@ -170,8 +173,8 @@ export const ActionRegistry = ({ room, refreshRoom }: Props) => {
|
|
|
|
action.type === 'answer' ? (
|
|
|
|
action.type === 'answer' ? (
|
|
|
|
<ActionCardAnswer
|
|
|
|
<ActionCardAnswer
|
|
|
|
action={action}
|
|
|
|
action={action}
|
|
|
|
moveUp={() => moveActionUp(index)}
|
|
|
|
// moveUp={() => moveActionUp(index)}
|
|
|
|
moveDown={() => moveActionDown(index)}
|
|
|
|
// moveDown={() => moveActionDown(index)}
|
|
|
|
remove={() => removeAction(index)}
|
|
|
|
remove={() => removeAction(index)}
|
|
|
|
// editing={editing === index}
|
|
|
|
// editing={editing === index}
|
|
|
|
// edit={() => editAction(index)}
|
|
|
|
// edit={() => editAction(index)}
|
|
|
@ -180,8 +183,8 @@ export const ActionRegistry = ({ room, refreshRoom }: Props) => {
|
|
|
|
) : action.type === 'jolly' ? (
|
|
|
|
) : action.type === 'jolly' ? (
|
|
|
|
<ActionCardJolly
|
|
|
|
<ActionCardJolly
|
|
|
|
action={action}
|
|
|
|
action={action}
|
|
|
|
moveUp={() => moveActionUp(index)}
|
|
|
|
// moveUp={() => moveActionUp(index)}
|
|
|
|
moveDown={() => moveActionDown(index)}
|
|
|
|
// moveDown={() => moveActionDown(index)}
|
|
|
|
remove={() => removeAction(index)}
|
|
|
|
remove={() => removeAction(index)}
|
|
|
|
// editing={editing === index}
|
|
|
|
// editing={editing === index}
|
|
|
|
// edit={() => editAction(index)}
|
|
|
|
// edit={() => editAction(index)}
|
|
|
|