|
|
@ -27,7 +27,7 @@ export const NewRoom = ({}) => {
|
|
|
|
// const [questions, setQuestions] = useState<{ group: string; name: string }[]>([{ group: '', name: '' }])
|
|
|
|
// const [questions, setQuestions] = useState<{ group: string; name: string }[]>([{ group: '', name: '' }])
|
|
|
|
const [questions, setQuestions] = useState<{ group: string; name: string }[]>(
|
|
|
|
const [questions, setQuestions] = useState<{ group: string; name: string }[]>(
|
|
|
|
Array.from({ length: 18 }, (_, i) => ({
|
|
|
|
Array.from({ length: 18 }, (_, i) => ({
|
|
|
|
group: `P${Math.floor(i / 6) + 1}`,
|
|
|
|
group: ['A', 'B', 'C'][Math.floor(i / 6)],
|
|
|
|
name: `${(i % 6) + 1}`,
|
|
|
|
name: `${(i % 6) + 1}`,
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -54,19 +54,20 @@ export const NewRoom = ({}) => {
|
|
|
|
class="square"
|
|
|
|
class="square"
|
|
|
|
onClick={() => {
|
|
|
|
onClick={() => {
|
|
|
|
const teamsSyntax = prompt(`Aggiungi squadre separate da virgola, e.g. "Team 1, Team 2, ..."`)
|
|
|
|
const teamsSyntax = prompt(`Aggiungi squadre separate da virgola, e.g. "Team 1, Team 2, ..."`)
|
|
|
|
|
|
|
|
if (!teamsSyntax) {
|
|
|
|
if (!teamsSyntax) return
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setTeams(teams => {
|
|
|
|
setTeams(teams => {
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
...teams,
|
|
|
|
...teams,
|
|
|
|
...teamsSyntax.split(',').flatMap(t => {
|
|
|
|
...teamsSyntax.split(',').flatMap(t => {
|
|
|
|
if (t.includes('*')) {
|
|
|
|
if (t.includes('*')) {
|
|
|
|
const [team, count] = t.split('*')
|
|
|
|
const [team, count] = t.trim().split('*')
|
|
|
|
return Array.from({ length: Number(count) }, (_, i) => `${team}-${i + 1}`)
|
|
|
|
return Array.from({ length: Number(count) }, (_, i) => `${team}-${i + 1}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return [t]
|
|
|
|
return [t.trim()]
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -119,15 +120,16 @@ export const NewRoom = ({}) => {
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
class="square"
|
|
|
|
class="square"
|
|
|
|
onClick={() => {
|
|
|
|
onClick={() => {
|
|
|
|
const questionsSyntax = prompt(`Aggiungi domande separate da virgola, e.g. "P1*6, P2*4"`)
|
|
|
|
const questionsSyntax = prompt(`Aggiungi domande separate da virgola, e.g. "A*6, B*4"`)
|
|
|
|
|
|
|
|
if (!questionsSyntax) {
|
|
|
|
if (!questionsSyntax) return
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setQuestions(questions => {
|
|
|
|
setQuestions(questions => {
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
...questions,
|
|
|
|
...questions,
|
|
|
|
...questionsSyntax.split(',').flatMap(q => {
|
|
|
|
...questionsSyntax.split(',').flatMap(q => {
|
|
|
|
const [group, count] = q.split('*')
|
|
|
|
const [group, count] = q.trim().split('*')
|
|
|
|
|
|
|
|
|
|
|
|
return Array.from({ length: Number(count) }, (_, i) => ({
|
|
|
|
return Array.from({ length: Number(count) }, (_, i) => ({
|
|
|
|
group,
|
|
|
|
group,
|
|
|
@ -187,11 +189,13 @@ export const NewRoom = ({}) => {
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
onClick={() =>
|
|
|
|
onClick={() =>
|
|
|
|
handleCreateRoom(
|
|
|
|
handleCreateRoom(
|
|
|
|
roomName,
|
|
|
|
roomName.trim(),
|
|
|
|
teams,
|
|
|
|
teams.map(t => t.trim()).filter(t => t.length > 0),
|
|
|
|
questions.map(q => ({
|
|
|
|
questions
|
|
|
|
id: `${q.group}.${q.name}`,
|
|
|
|
.filter(q => [q.group, q.name].every(s => s.trim().length > 0))
|
|
|
|
group: q.group,
|
|
|
|
.map(q => ({
|
|
|
|
|
|
|
|
id: `${q.group.trim()}.${q.name.trim()}`,
|
|
|
|
|
|
|
|
group: q.group.trim(),
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|