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