diff --git a/backend/app/session/engine.py b/backend/app/session/engine.py
index 093cbe4..b9dbc40 100644
--- a/backend/app/session/engine.py
+++ b/backend/app/session/engine.py
@@ -50,34 +50,37 @@ def __init__(self, code: enums.EventErrorCode, message: str) -> None:
Motions.POSTPONE_SESSION,
Motions.TOUR_DE_TABLE,
Motions.END_DEBATE,
- Motions.VOTE_AMENDMENT,
- Motions.VOTE_BY_ROLL_CALL,
Motions.CLOSE_SPEAKERS_LIST,
- Motions.SPLIT_PROPOSAL,
Motions.INTRODUCE_RESOLUTION_PROPOSAL,
- Motions.INTRODUCE_AMENDMENT_PROPOSAL,
Motions.CHANGE_TOPIC,
Motions.QUORUM,
Motions.CUSTOM_MOTION,
},
States.CLOSED_GSL: {
- Motions.REOPEN_SPEAKERS_LIST,
+ Motions.CHANGE_DEBATE_TYPE,
+ Motions.POSTPONE_SESSION,
+ Motions.TOUR_DE_TABLE,
Motions.END_DEBATE,
- Motions.VOTE_AMENDMENT,
- Motions.VOTE_BY_ROLL_CALL,
+ Motions.REOPEN_SPEAKERS_LIST,
Motions.INTRODUCE_RESOLUTION_PROPOSAL,
- Motions.INTRODUCE_AMENDMENT_PROPOSAL,
+ Motions.CHANGE_TOPIC,
Motions.QUORUM,
Motions.CUSTOM_MOTION,
},
States.VOTING_PREPARATION: {
Motions.VOTE_BY_ROLL_CALL,
Motions.SPLIT_PROPOSAL,
+ Motions.INTRODUCE_AMENDMENT_PROPOSAL,
+ Motions.VOTE_AMENDMENT,
Motions.CUSTOM_MOTION,
},
States.MODERATED_CAUCUS: {
+ Motions.CHANGE_DEBATE_TYPE,
Motions.POSTPONE_SESSION,
+ Motions.TOUR_DE_TABLE,
Motions.END_DEBATE,
+ Motions.INTRODUCE_RESOLUTION_PROPOSAL,
+ Motions.CHANGE_TOPIC,
Motions.QUORUM,
Motions.CUSTOM_MOTION,
},
@@ -110,14 +113,19 @@ def validate_motion_payload(
"""Should validate motion payload before submitting"""
# can also raise error if there are missing fields
- if (
- payload.type == Motions.CHANGE_DEBATE_TYPE
- and payload.debate_type == DebateTypes.MODERATED_DEBATE
- and payload.per_speaker_seconds is None
+ if payload.type == Motions.CHANGE_DEBATE_TYPE and (
+ (
+ payload.debate_type == DebateTypes.UNMODERATED_DEBATE
+ and payload.total_duration_minutes is None
+ )
+ or (
+ payload.debate_type == DebateTypes.MODERATED_DEBATE
+ and payload.per_speaker_seconds is None
+ )
):
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_MESSAGE,
- message="Cannot submit motion without speaking time",
+ message="Cannot submit debate motion without the required duration",
)
@@ -278,7 +286,11 @@ def handle_delegate_submit_motion(
)
if (
- current_state in {States.MODERATED_CAUCUS, States.UNMODERATED_CAUCUS}
+ current_state
+ in {
+ States.MODERATED_CAUCUS,
+ States.UNMODERATED_CAUCUS,
+ }
and not state.can_set_motion
):
raise EventRejectedError(
@@ -422,10 +434,10 @@ def handle_close_session(
) -> DispatchOutcome:
require_chair(actor)
- if state.current_state not in (States.SETUP, States.ROLL_CALL, States.FINISHED):
+ if state.current_state != States.ROLL_CALL:
raise EventRejectedError(
code=enums.EventErrorCode.INVALID_STATE,
- message="Session may only be closed from setup, roll_call or finished",
+ message="Session may only be closed during roll call",
)
state.current_state = States.FINISHED
@@ -551,50 +563,56 @@ def apply_passed_motion(
state.timer_is_running = False
state.timer_expiration = None
- # 1st block: change of debate motions
- if motion.type == Motions.CHANGE_DEBATE_TYPE and motion.debate_type is not None:
- state.caucus_list = []
- state.current_speaker = None
- duration_seconds = (
- (motion.total_duration_minutes * 60)
- if motion.total_duration_minutes is not None
- else 600
- ) # defaults to 10 minutes as fallback
-
- match motion.debate_type:
- case DebateTypes.MODERATED_DEBATE:
- next_state = States.MODERATED_CAUCUS
- state.debate = DebateContext(
- debate_type=DebateTypes.MODERATED_DEBATE,
- return_state=return_state,
- total_duration_seconds=duration_seconds,
- per_speaker_seconds=motion.per_speaker_seconds,
- expires_at=datetime.now(UTC) + timedelta(seconds=duration_seconds),
- )
- reset_timer(
- state,
- motion.per_speaker_seconds
- if motion.per_speaker_seconds is not None
- else 60,
- )
-
- case DebateTypes.UNMODERATED_DEBATE:
- next_state = States.UNMODERATED_CAUCUS
- state.debate = DebateContext(
- debate_type=DebateTypes.UNMODERATED_DEBATE,
- return_state=return_state,
- total_duration_seconds=duration_seconds,
- per_speaker_seconds=None,
- expires_at=datetime.now(UTC) + timedelta(seconds=duration_seconds),
- )
- reset_timer(state) # should not display per_speaker timer
-
- case DebateTypes.SPEAKERS_LIST:
- next_state = States.OPEN_GSL
- state.debate = None
- reset_timer(state, state.gsl_default_time_seconds)
-
match motion.type:
+ case Motions.CHANGE_DEBATE_TYPE:
+ if motion.debate_type is None:
+ raise EventRejectedError(
+ code=enums.EventErrorCode.INVALID_MESSAGE,
+ message="No Debate Type Provided",
+ )
+ state.current_speaker = None
+ duration_seconds = (
+ (motion.total_duration_minutes * 60)
+ if motion.total_duration_minutes is not None
+ else 600
+ ) # defaults to 10 minutes as fallback
+
+ match motion.debate_type:
+ case DebateTypes.MODERATED_DEBATE:
+ next_state = States.MODERATED_CAUCUS
+ state.debate = DebateContext(
+ debate_type=DebateTypes.MODERATED_DEBATE,
+ return_state=return_state,
+ total_duration_seconds=duration_seconds,
+ per_speaker_seconds=motion.per_speaker_seconds
+ if motion.per_speaker_seconds is not None
+ else state.gsl_default_time_seconds,
+ expires_at=datetime.now(UTC)
+ + timedelta(seconds=duration_seconds),
+ )
+ reset_timer(
+ state,
+ motion.per_speaker_seconds
+ if motion.per_speaker_seconds is not None
+ else state.gsl_default_time_seconds,
+ )
+
+ case DebateTypes.UNMODERATED_DEBATE:
+ next_state = States.UNMODERATED_CAUCUS
+ state.debate = DebateContext(
+ debate_type=DebateTypes.UNMODERATED_DEBATE,
+ return_state=return_state,
+ total_duration_seconds=duration_seconds,
+ per_speaker_seconds=None,
+ expires_at=datetime.now(UTC)
+ + timedelta(seconds=duration_seconds),
+ )
+ reset_timer(state) # should not display per_speaker timer
+
+ case DebateTypes.SPEAKERS_LIST:
+ next_state = States.OPEN_GSL
+ state.debate = None
+ reset_timer(state, state.gsl_default_time_seconds)
case Motions.POSTPONE_SESSION:
pass
case Motions.REOPEN_SESSION:
@@ -681,16 +699,11 @@ def handle_close_procedural_voting(
present = count_present_delegations(state)
passed = tally_votes(state.voting, present)
+
+ # TODO: Change this
effect = SessionEffect(
type=enums.SessionEffectType.VOTE_CLOSED,
- data={
- "present": present,
- "favour": sum(
- vote == enums.VotingChoice.FAVOUR
- for vote in state.voting.voting_registry.values()
- ),
- "passed": passed,
- },
+ data={**state.voting.model_dump(mode="json"), "passed": passed},
)
if passed:
@@ -960,6 +973,72 @@ def handle_grant_floor(
return DispatchOutcome(state=state)
+def handle_cede_time(
+ state: SessionLiveState, event: schemas.CedeTimeEvent, actor: SessionActor
+) -> DispatchOutcome:
+
+ representation_id = event.payload.representation_id
+ if representation_id not in state.delegations:
+ raise EventRejectedError(
+ code=enums.EventErrorCode.NOT_FOUND,
+ message="Representation not found",
+ )
+
+ if state.current_state not in [
+ States.MODERATED_CAUCUS,
+ States.OPEN_GSL,
+ States.CLOSED_GSL,
+ ]:
+ raise EventRejectedError(
+ code=enums.EventErrorCode.INVALID_STATE,
+ message="Can only cede time during moderated debate or debate by list",
+ )
+
+ if state.timer_is_running:
+ raise EventRejectedError(
+ code=enums.EventErrorCode.INVALID_STATE,
+ message="Cannot cede time while timer is running",
+ )
+
+ if not state.current_speaker:
+ raise EventRejectedError(
+ code=enums.EventErrorCode.INVALID_STATE,
+ message="Cannot cede time if there's no speaker",
+ )
+
+ if state.timer_remaining_seconds <= 0:
+ raise EventRejectedError(
+ code=enums.EventErrorCode.INVALID_STATE,
+ message="Cannot cede time if there's no time",
+ )
+
+ state.current_speaker = representation_id
+
+ return DispatchOutcome(state=state)
+
+
+def handle_end_speech(
+ state: SessionLiveState, event: schemas.EndSpeechEvent, actor: SessionActor
+) -> DispatchOutcome:
+
+ if state.current_speaker is None:
+ raise EventRejectedError(
+ code=enums.EventErrorCode.INVALID_STATE,
+ message="Cannot end speech without speaker",
+ )
+
+ if state.timer_is_running:
+ raise EventRejectedError(
+ code=enums.EventErrorCode.INVALID_STATE,
+ message="Cannot end speech while timer is running",
+ )
+
+ state.current_speaker = None
+ reset_timer(state)
+
+ return DispatchOutcome(state=state)
+
+
def handle_mark_roll_call(
state: SessionLiveState, event: schemas.MarkRollCallEvent, actor: SessionActor
) -> DispatchOutcome:
@@ -980,11 +1059,6 @@ def handle_mark_roll_call_bulk(
state: SessionLiveState, event: schemas.MarkRollCallBulkEvent, actor: SessionActor
) -> DispatchOutcome:
require_chair(actor)
- if state.current_state != States.ROLL_CALL or state.roll_call is None:
- raise EventRejectedError(
- code=enums.EventErrorCode.INVALID_STATE,
- message="Cannot mark roll call right now",
- )
for delegation_id in event.payload.Rollcalls.keys():
if delegation_id not in state.delegations:
@@ -1056,6 +1130,8 @@ def handle_close_roll_call(
ChairEvents.NEXT_SPEAKER: handle_next_speaker,
ChairEvents.ADD_GSL_SPEAKER: handle_add_gsl_speaker,
ChairEvents.GRANT_FLOOR: handle_grant_floor,
+ ChairEvents.CEDE_TIME: handle_cede_time,
+ ChairEvents.END_SPEECH: handle_end_speech,
ChairEvents.MARK_ROLLCALL: handle_mark_roll_call,
ChairEvents.MARK_ROLLCALL_BULK: handle_mark_roll_call_bulk,
ChairEvents.CLOSE_ROLLCALL: handle_close_roll_call,
diff --git a/backend/app/session/enums.py b/backend/app/session/enums.py
index 99d3445..731266c 100644
--- a/backend/app/session/enums.py
+++ b/backend/app/session/enums.py
@@ -70,9 +70,13 @@ class ChairEvents(StrEnum):
MARK_AGENDA_ITEM = "MarkAgendaItemEvent"
DELETE_AGENDA_ITEM = "DeleteAgendaItemEvent"
SET_AGENDA = "SetAgenda"
+
NEXT_SPEAKER = "NextSpeakerEvent"
ADD_GSL_SPEAKER = "AddGslSpeakerEvent"
GRANT_FLOOR = "GrantFloorEvent"
+ CEDE_TIME = "CedeTimeEvent"
+ END_SPEECH = "EndSpeechEvent"
+
MARK_ROLLCALL = "MarkRollCallEvent"
MARK_ROLLCALL_BULK = "MarkRollCallBulkEvent"
CLOSE_ROLLCALL = "CloseRollCallEvent"
diff --git a/backend/app/session/models.py b/backend/app/session/models.py
index 566aa8b..c49aae0 100644
--- a/backend/app/session/models.py
+++ b/backend/app/session/models.py
@@ -150,9 +150,13 @@ class SessionLiveState(BaseModel):
has_veto_power: bool = False
+# Add more effect payload shapes as they are introduced.
+EffectPayloads = dict[str, Any]
+
+
class SessionEffect(BaseModel):
type: enums.SessionEffectType
- data: dict[str, Any] = {}
+ data: EffectPayloads = {}
class DispatchOutcome(BaseModel):
diff --git a/backend/app/session/schemas.py b/backend/app/session/schemas.py
index e4ee663..90ff0b5 100644
--- a/backend/app/session/schemas.py
+++ b/backend/app/session/schemas.py
@@ -111,6 +111,10 @@ class GrantFloorPayload(BaseModel):
seconds: int | None = Field(default=None, ge=1)
+class CedeTimePayload(BaseModel):
+ representation_id: int
+
+
class ChairSetAgendaPayload(BaseModel):
agenda: list[str]
@@ -201,6 +205,16 @@ class GrantFloorEvent(BaseModel):
payload: GrantFloorPayload
+class CedeTimeEvent(BaseModel):
+ type: Literal[enums.ChairEvents.CEDE_TIME]
+ payload: CedeTimePayload
+
+
+class EndSpeechEvent(BaseModel):
+ type: Literal[enums.ChairEvents.END_SPEECH]
+ payload: EmptyPayload
+
+
class SetAgendaEvent(BaseModel):
type: Literal[enums.ChairEvents.SET_AGENDA]
payload: ChairSetAgendaPayload
@@ -277,6 +291,8 @@ class DeleteAgendaItemEvent(BaseModel):
| NextSpeakerEvent
| AddGslSpeakerEvent
| GrantFloorEvent
+ | CedeTimeEvent
+ | EndSpeechEvent
| SetAgendaEvent
| SetAgendaItemEvent
| MarkAgendaItemEvent
diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js
index 478338b..946769a 100644
--- a/frontend/eslint.config.js
+++ b/frontend/eslint.config.js
@@ -4,23 +4,26 @@ import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'
+import tsPlugin from "@typescript-eslint/eslint-plugin";
export default defineConfig([
- globalIgnores(['dist']),
- {
- files: ['**/*.{ts,tsx}'],
- extends: [
- js.configs.recommended,
- tseslint.configs.recommended,
- reactHooks.configs.flat.recommended,
- reactRefresh.configs.vite,
- ],
- languageOptions: {
- ecmaVersion: 2020,
- globals: globals.browser,
- },
- rules: {
- "react-refresh/only-export-components" : "off"
- }
- },
+ globalIgnores(['dist']),
+ {
+ files: ['**/*.{ts,tsx}'],
+ extends: [
+ js.configs.recommended,
+ tseslint.configs.recommended,
+ reactHooks.configs.flat.recommended,
+ reactRefresh.configs.vite,
+ ],
+ languageOptions: {
+ ecmaVersion: 2020,
+ globals: globals.browser,
+ },
+ rules: {
+ "react-refresh/only-export-components": "off",
+ "no-unused-vars": "off",
+ "@typescript-eslint/no-unused-vars": "off"
+ }
+ },
])
diff --git a/frontend/public/Images/branding/WebMunLogoHorizontal.png b/frontend/public/Images/branding/WebMunLogoHorizontal.png
new file mode 100644
index 0000000..a7bce11
Binary files /dev/null and b/frontend/public/Images/branding/WebMunLogoHorizontal.png differ
diff --git a/frontend/public/Images/branding/WebmunLogoWhite.png b/frontend/public/Images/branding/WebmunLogoWhite.png
new file mode 100644
index 0000000..b332a5b
Binary files /dev/null and b/frontend/public/Images/branding/WebmunLogoWhite.png differ
diff --git a/frontend/public/Images/branding/logo.png b/frontend/public/Images/branding/logo.png
index 2df12a2..3743882 100644
Binary files a/frontend/public/Images/branding/logo.png and b/frontend/public/Images/branding/logo.png differ
diff --git a/frontend/src/components/homepage/footer.tsx b/frontend/src/components/homepage/footer.tsx
index 2a0de37..828d817 100644
--- a/frontend/src/components/homepage/footer.tsx
+++ b/frontend/src/components/homepage/footer.tsx
@@ -17,7 +17,7 @@ const footerLinkGroups = [
{ label: "Documentação", to: "/dashboard" },
{ label: "Preços", to: "/pricing" },
{ label: "Changelog", to: "/dashboard" },
- { label: "Repositório GitHub", href: "https://github.com" },
+ { label: "Repositório GitHub", href: "https://github.com/uspcodelab/webmun" },
],
},
{
@@ -31,7 +31,7 @@ const footerLinkGroups = [
{
title: "Redes Sociais",
items: [
- { label: "Instagram", href: "https://instagram.com" },
+ { label: "Instagram", href: "https://www.instagram.com/webmun.oficial/" },
{ label: "Twitter", href: "https://x.com" },
{ label: "LinkedIn", href: "https://linkedin.com" },
{ label: "TikTok", href: "https://tiktok.com" },
@@ -48,7 +48,7 @@ export default function Footer() {
-

+
O melhor e o mais facil para a sua MUN
{footerLinkGroups.map((group) => (
diff --git a/frontend/src/components/homepage/navbar.tsx b/frontend/src/components/homepage/navbar.tsx
index 3e06498..92aa2a1 100644
--- a/frontend/src/components/homepage/navbar.tsx
+++ b/frontend/src/components/homepage/navbar.tsx
@@ -17,7 +17,7 @@ export default function Navbar() {
>
)
-}
\ No newline at end of file
+}
diff --git a/frontend/src/components/session/delegation-map.tsx b/frontend/src/components/session/delegation-map.tsx
index 16eb8c9..633bc75 100644
--- a/frontend/src/components/session/delegation-map.tsx
+++ b/frontend/src/components/session/delegation-map.tsx
@@ -16,12 +16,16 @@ import {
import { useCommitteeStore } from "@/store/useCommitteeStore"
import { CircleFlag } from 'react-circle-flags'
import { sendMessage } from "@/context/SessionContext"
-import { type AddGslSpeakerEvent, type MarkRollCallEvent, type GrantFloorEvent , ChairEvents, RollCallChoice } from "@/schemas/types.gen"
+import { type AddGslSpeakerEvent, type MarkRollCallEvent, type GrantFloorEvent, ChairEvents, RollCallChoice, type CedeTimeEvent } from "@/schemas/types.gen"
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip"
+import { useSession } from "@/context/SessionContext"
+
+import { States, VotingChoice, SessionRoles } from '@/schemas/types.gen';
+import { useEffect, useState } from "react"
type DelegationMapProps = {
@@ -34,6 +38,10 @@ export default function DelegationMap({
semicircleCount = 3,
buttonsPerSemicircle = 12,
}: DelegationMapProps) {
+
+ const { role } = useSession()
+ const isChair = role === SessionRoles.CHAIR
+
const circles = Array.from({ length: Math.max(1, semicircleCount) }, (_, i) => i)
const getSeatCount = (circleIndex: number) => {
@@ -60,13 +68,55 @@ export default function DelegationMap({
const qualifiedMajority = Math.ceil((presentDelegations * 2) / 3)
const currentState = useCommitteeStore((state) => state.current_state)
- const ringColors : Record
= {
- "None" : "ring-sky-300/30",
- "Absent" : "ring-red-500/50",
- "Present" : "ring-yellow-500/50",
- "Present and Voting" : "ring-lime-600/50"
+ const votingRegistry = useCommitteeStore((state) => state.voting?.voting_registry ?? null)
+
+
+
+ const getDelegationRingColor = (state: string | undefined, presence: string | undefined, vote: VotingChoice | null) => {
+ switch (state) {
+ case States.ROLL_CALL:
+ if (presence === RollCallChoice.PRESENT_AND_VOTING) return "ring-green-700/50"
+ if (presence === RollCallChoice.PRESENT) return "ring-green-500/50"
+ if (presence === RollCallChoice.ABSENT) return "ring-red-500/50"
+ return "ring-sky-300/30"
+ case States.VOTING_EXECUTION:
+ if (vote === VotingChoice.FAVOUR) return "ring-green-500/50"
+ if (vote === VotingChoice.YES_WITH_RIGHTS) return "ring-green-300/50"
+ if (vote === VotingChoice.AGAINST) return "ring-red-500/50"
+ if (vote === VotingChoice.NO_WITH_RIGHTS) return "ring-red-300/50"
+ if (vote === VotingChoice.ABSTAIN) return "ring-gray-400/50"
+ return "ring-neutral-300/30"
+ default:
+ if (active) return "ring-yellow-300/50"
+ if (presence == RollCallChoice.PRESENT_AND_VOTING || presence === RollCallChoice.PRESENT) return "ring-sky-300/50"
+ return "ring-neutral-400/30"
+ }
}
+ const [active, setActive] = useState(false)
+
+ useEffect(() => {
+ const setAc = (e: CustomEvent) => {
+ if (!e.detail || e.detail.type === null) {
+ setActive(false)
+ return
+ }
+
+ if (e.detail.type === "cedetime") {
+ setActive(true)
+ return
+ }
+
+ setActive(false)
+ }
+
+ window.addEventListener("mapselection", setAc as EventListener)
+
+ return () => {
+ window.removeEventListener("mapselection", setAc as EventListener)
+ }
+ }, [])
+
return (
@@ -119,7 +169,8 @@ export default function DelegationMap({
const delegation = delegationsBySeat.get(seat)
const presence = rcregistry && delegation ? rcregistry[delegation.id] : "None"
- const ringcolor = ringColors[presence?? "None"]
+ const vote = votingRegistry && delegation ? votingRegistry[delegation.id] : null
+ const ringcolor = getDelegationRingColor(currentState, presence, vote)
if (!delegation) {
return
@@ -134,70 +185,100 @@ export default function DelegationMap({
transform: "translate(-50%, -50%)",
}}
>
-
-
-
-
-
-
-
-
-
-
-
- {/* TODO: Replace by country full name */}
-
- {delegation.name}
-
-
-
-
- Ações sobre a Delegação
- sendMessage({ type: ChairEvents.ADD_GSL_SPEAKER_EVENT, payload: { representation_id: delegation.id } } satisfies AddGslSpeakerEvent)}>
- Colocar na Lista de Discursos
-
- sendMessage({ type: ChairEvents.GRANT_FLOOR_EVENT, payload: { representation_id: delegation.id } } satisfies GrantFloorEvent)}>
- Dar a palavra
-
-
-
-
- Ausência Temporária
-
- Mudar Presença
-
- sendMessage({ type: ChairEvents.MARK_ROLL_CALL_EVENT, payload: { delegation_id: delegation.id, choice: RollCallChoice.PRESENT_AND_VOTING } } satisfies MarkRollCallEvent)}>
- Presente Votante
-
- sendMessage({ type: ChairEvents.MARK_ROLL_CALL_EVENT, payload: { delegation_id: delegation.id, choice: RollCallChoice.PRESENT } } satisfies MarkRollCallEvent)}>
- Presente
-
- sendMessage({ type: ChairEvents.MARK_ROLL_CALL_EVENT, payload: { delegation_id: delegation.id, choice: RollCallChoice.ABSENT } } satisfies MarkRollCallEvent)}>
- Ausente
-
-
-
-
-
-
-
-
- Punições
-
- Aviso Formal
- Expulsão
-
-
-
-
-
+ {isChair && (
+
+
+
+
+ {
+ if (active) {
+ sendMessage({ type: ChairEvents.CEDE_TIME_EVENT, payload: { representation_id: delegation.id } } satisfies CedeTimeEvent)
+ setActive(false);
+ const mapSelectionEvent = new CustomEvent("mapselection", {
+ detail: { type: null },
+ })
+ window.dispatchEvent(mapSelectionEvent)
+
+ }
+ }}
+ >
+
+
+
+
+
+
+ {/* TODO: Replace by country full name */}
+
+ {delegation.name}
+
+
+
+
+ Ações sobre a Delegação
+ sendMessage({ type: ChairEvents.ADD_GSL_SPEAKER_EVENT, payload: { representation_id: delegation.id } } satisfies AddGslSpeakerEvent)}>
+ Colocar na Lista de Discursos
+
+ sendMessage({ type: ChairEvents.GRANT_FLOOR_EVENT, payload: { representation_id: delegation.id } } satisfies GrantFloorEvent)}>
+ Dar a palavra
+
+
+
+
+ {/*
+ Ausência Temporária
+ */}
+
+ Mudar Presença
+
+ sendMessage({ type: ChairEvents.MARK_ROLL_CALL_EVENT, payload: { delegation_id: delegation.id, choice: RollCallChoice.PRESENT_AND_VOTING } } satisfies MarkRollCallEvent)}>
+ Presente Votante
+
+ sendMessage({ type: ChairEvents.MARK_ROLL_CALL_EVENT, payload: { delegation_id: delegation.id, choice: RollCallChoice.PRESENT } } satisfies MarkRollCallEvent)}>
+ Presente
+
+ sendMessage({ type: ChairEvents.MARK_ROLL_CALL_EVENT, payload: { delegation_id: delegation.id, choice: RollCallChoice.ABSENT } } satisfies MarkRollCallEvent)}>
+ Ausente
+
+
+
+
+
+ {/*
+
+
+
+ Punições
+
+ Aviso Formal
+ Expulsão
+
+
+
+ */}
+
+ )}
+ {!isChair && (
+
+
+
+
+
+
+ )}
{delegation.name}
diff --git a/frontend/src/components/session/speaker-list.tsx b/frontend/src/components/session/speaker-list.tsx
deleted file mode 100644
index a740831..0000000
--- a/frontend/src/components/session/speaker-list.tsx
+++ /dev/null
@@ -1,125 +0,0 @@
-import { Button } from "@/components/ui/button"
-import { Separator } from "@/components/ui/separator"
-import { ScrollArea } from "@/components/ui/scroll-area"
-import {
- Item,
- ItemContent,
- ItemMedia,
- ItemTitle,
-} from "@/components/ui/item"
-import { Badge } from "@/components/ui/badge"
-import Flags from "@/components/ui/flags"
-import { useCommitteeStore } from "@/store/useCommitteeStore"
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/components/ui/tooltip"
-import { sendMessage } from "@/context/SessionContext"
-import { type JoinQueueEvent, type NextSpeakerEvent, ChairEvents, DelegateEvents } from "@/schemas/types.gen"
-import { useSession } from "@/context/SessionContext"
-import { SessionRoles } from "@/schemas/types.gen"
-
-//TODO determine if queue is open, if not obscure the button and show a message that the queue is closed
-
-export default function SpeakerList() {
-
- const {role, representation_id} = useSession()
- const isChair = role===SessionRoles.CHAIR
- const gslQueue = useCommitteeStore((state) => state.gsl_queue ?? [])
- const currentSpeaker = useCommitteeStore((state) => state.current_speaker)
- const delegationsById = useCommitteeStore((state) => state.delegations)
-
- const alreadyInQueue = representation_id ? gslQueue.includes(representation_id) : false
- const queuedDelegations = gslQueue.flatMap((delegationId) => {
- const delegation = delegationsById[String(delegationId)]
- return delegation ? [delegation] : []
- })
- const waitingCount = queuedDelegations.length
-
-
- return (
-
-
-
Lista de Oradores
- {String(waitingCount).padStart(2, "0")} em espera
-
-
- {queuedDelegations.map((delegate, index) => {
- const isSpeaking = currentSpeaker === delegate.id
- const position = index + 1
-
- return (
-
-
-
-
-
-
- {String(position).padStart(2, "0")}
-
-
-
-
-
- {delegate.name}
-
-
-
-
- {index < queuedDelegations.length - 1 && (
-
- )}
-
- )
- })}
-
- {!isChair && (
-
sendMessage({type:DelegateEvents.JOIN_QUEUE_EVENT, payload:{}} satisfies JoinQueueEvent)}
- >
- Se colocar na lista de oradores
-
- )}
- {isChair && (
-
-
-
- sendMessage({ type: ChairEvents.NEXT_SPEAKER_EVENT, payload: {} } satisfies NextSpeakerEvent)}
- >
- Proximo
- Proximo Orador
-
-
-
- Passar para o próximo orador da lista
-
-
-
-
-
- Cessao
- Cessao de Tempo
-
-
-
- Ceder tempo restante a outra delegacao
-
-
-
-
-
- )}
-
-
-
)
-}
diff --git a/frontend/src/components/session/timer.tsx b/frontend/src/components/session/timer.tsx
index 22da730..b87e944 100644
--- a/frontend/src/components/session/timer.tsx
+++ b/frontend/src/components/session/timer.tsx
@@ -11,16 +11,16 @@ import { SessionRoles } from "@/schemas/types.gen"
export default function Timer() {
- const { role } = useSession()
- const isChair = role === SessionRoles.CHAIR
- const delegations = useCommitteeStore((state) => state.delegations);
- const currentSpeaker = useCommitteeStore((state) => state.current_speaker);
- const speaker = currentSpeaker !== null && currentSpeaker !== undefined ? delegations[currentSpeaker] : {
- id: -1,
- seat: "",
- name: "Mesa",
- code: "null",
- };
+ const {role} = useSession()
+ const isChair = role===SessionRoles.CHAIR
+ const delegations = useCommitteeStore((state) => state.delegations);
+ const currentSpeaker = useCommitteeStore((state) => state.current_speaker);
+ const speaker = currentSpeaker !== null && currentSpeaker !== undefined ? delegations[currentSpeaker] : {
+ id: -1,
+ seat: "",
+ name: "Mesa",
+ code: "null",
+ };
const timerIsRunning = useCommitteeStore((state) => state.timer_is_running) ?? false;
const timerExpiration = useCommitteeStore((state) => state.timer_expiration);
diff --git a/frontend/src/components/session/top-bar.tsx b/frontend/src/components/session/top-bar.tsx
index 3f954c0..54a1c47 100644
--- a/frontend/src/components/session/top-bar.tsx
+++ b/frontend/src/components/session/top-bar.tsx
@@ -2,13 +2,16 @@ import { Separator } from "@/components/ui/separator"
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import Timer from "./timer"
import { useCommitteeStore } from "@/store/useCommitteeStore"
+import { States } from '@/schemas/types.gen';
-import Agenda from "./Agenda"
+import Agenda from "./Agenda"
export default function TopBar() {
const agendaTopics = useCommitteeStore((state) => state.agenda_topics)
const activeTopicIndex = useCommitteeStore((state) => state.active_topic_index)
+ const currentState = useCommitteeStore((state) => state.current_state)
+
const currentTopicLabel =
activeTopicIndex !== null && activeTopicIndex !== undefined && agendaTopics !== undefined && agendaTopics[activeTopicIndex] !== undefined
@@ -21,7 +24,10 @@ export default function TopBar() {
Conselho de Segurança
-
+ {currentState != States.UNMODERATED_CAUCUS &&
+
+ }
+
@@ -47,6 +53,6 @@ export default function TopBar() {
-
+
>)
}
\ No newline at end of file
diff --git a/frontend/src/components/session/voting-popup.tsx b/frontend/src/components/session/voting-popup.tsx
index 814b633..8bc6af7 100644
--- a/frontend/src/components/session/voting-popup.tsx
+++ b/frontend/src/components/session/voting-popup.tsx
@@ -40,10 +40,9 @@ export default function VotingPopup() {
const voting = useCommitteeStore((state) => state.voting ?? null)
const voted = voting && representation_id ? representation_id in voting.voting_registry! : true
const voteTitle = voting?.title
- const [clicked, setClicked] = useState(false)
return (
-
+
Votação
@@ -81,11 +80,11 @@ export default function VotingPopup() {
{setClicked(true); sendMessage({type:DelegateEvents.CAST_VOTE_EVENT, payload: {vote:VotingChoice.FAVOUR}} satisfies CastVoteEvent)}}
+ () => { sendMessage({type:DelegateEvents.CAST_VOTE_EVENT, payload: {vote:VotingChoice.FAVOUR}} satisfies CastVoteEvent)}}
className="flex-1 bg-green-800 text-white hover:bg-green-700">A Favor
{setClicked(true); sendMessage({type:DelegateEvents.CAST_VOTE_EVENT, payload: {vote:VotingChoice.FAVOUR}} satisfies CastVoteEvent)}}
+ () => { sendMessage({type:DelegateEvents.CAST_VOTE_EVENT, payload: {vote:VotingChoice.FAVOUR}} satisfies CastVoteEvent)}}
disabled={isRollCall && !canAbstain}
className="flex-1 bg-gray-700 text-white hover:bg-gray-600 disabled:cursor-not-allowed disabled:opacity-50"
>
@@ -96,7 +95,7 @@ export default function VotingPopup() {
Pular
)}
- {setClicked(true); sendMessage({type:DelegateEvents.CAST_VOTE_EVENT, payload: {vote:VotingChoice.FAVOUR}} satisfies CastVoteEvent)}}
+ { sendMessage({type:DelegateEvents.CAST_VOTE_EVENT, payload: {vote:VotingChoice.FAVOUR}} satisfies CastVoteEvent)}}
className="flex-1 bg-red-800 text-white hover:bg-red-700">Contra
diff --git a/frontend/src/components/session/voting-results-popup.tsx b/frontend/src/components/session/voting-results-popup.tsx
new file mode 100644
index 0000000..b47c02f
--- /dev/null
+++ b/frontend/src/components/session/voting-results-popup.tsx
@@ -0,0 +1,161 @@
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogClose,
+} from "@/components/ui/dialog"
+
+import { useCommitteeStore } from "@/store/useCommitteeStore"
+import { MajorityTypes, VotingChoice, RollCallChoice, type SessionEffect, type VotingContext } from "@/schemas/types.gen"
+import { Button } from "@/components/ui/button"
+import { useEffect, useState } from "react"
+
+
+
+export default function VotingResultsPopup() {
+
+
+
+ const [voting, setVoting] = useState(null);
+ const voteTitle = voting?.title ?? voting?.motion_in_vote?.type ?? "ERROR:VotingTitle not found"
+
+ const expectedVotes = useCommitteeStore((state) => Object.entries(state.roll_call?.registry ?? {}).filter(([, choice]) => choice !== RollCallChoice.ABSENT).length)
+ const yayVotes = Object.entries(voting?.voting_registry ?? {}).filter(([, choice]) => choice === VotingChoice.FAVOUR).length
+ const nayVotes = Object.entries(voting?.voting_registry ?? {}).filter(([, choice]) => choice === VotingChoice.AGAINST).length
+
+ const abstentions = expectedVotes - yayVotes - nayVotes
+ const yayPercentage = expectedVotes > 0 ? (yayVotes / expectedVotes) * 100 : 0
+ const nayPercentage = expectedVotes > 0 ? (nayVotes / expectedVotes) * 100 : 0
+ const majorityType = voting?.majority ?? MajorityTypes.MAIORIA_SIMPLES
+ const requiredMajority = majorityType === MajorityTypes.MAIORIA_QUALIFICADA
+ ? Math.ceil(expectedVotes * 2 / 3)
+ : majorityType === MajorityTypes.CONSENSO
+ ? expectedVotes
+ : Math.floor(expectedVotes / 2) + 1
+ const requiredMajorityPercentage = expectedVotes > 0 ? (requiredMajority / expectedVotes) * 100 : 0
+ const requiredMajorityAngle = Math.PI * requiredMajorityPercentage / 100
+ const markerInnerRadius = 67
+ const markerOuterRadius = 94
+ const markerStartX = 100 - markerInnerRadius * Math.cos(requiredMajorityAngle)
+ const markerStartY = 100 - markerInnerRadius * Math.sin(requiredMajorityAngle)
+ const markerEndX = 100 - markerOuterRadius * Math.cos(requiredMajorityAngle)
+ const markerEndY = 100 - markerOuterRadius * Math.sin(requiredMajorityAngle)
+
+ const canBeVetoed = voting?.allow_veto_power ?? false
+ const delegations = useCommitteeStore((state) => state.delegations)
+ const whoCanVeto = Object.values(delegations)
+ .filter((delegation) => ["fr", "us", "cn", "ru", "uk"].includes(delegation.code?.toLowerCase() ?? ""))
+ .map((delegation) => delegation.id)
+ const isVetoed = () => {
+ const votingRegistry = voting?.voting_registry
+ if (!votingRegistry) return false
+
+ return Object.entries(votingRegistry)
+ .some(([id, choice]) => choice === VotingChoice.AGAINST
+ && whoCanVeto.some((vetoId) => String(vetoId) === id))
+ }
+
+ const [open, setOpen] = useState(false)
+
+ useEffect(()=>{
+
+ const setOp = (e:CustomEvent) => {setOpen(true); setVoting(e.detail.data as VotingContext)};
+
+ window.addEventListener("voteclose", setOp as EventListener);
+
+ return () => { window.removeEventListener("voteclose", setOp as EventListener)}
+ }, []);
+
+ return (
+
+
+
+ Resultados da Votação
+ {voteTitle}
+
+
+
+
+
+
+
+
+ A favor: {yayVotes}
+
+
+
+ Contra: {nayVotes}
+
+
+
+ Abstenções: {Math.max(abstentions, 0)}
+
+
+ {canBeVetoed && isVetoed() && (
+
A moção foi vetada.
+ )}
+ {!canBeVetoed || !isVetoed() ? yayVotes >= requiredMajority ? (
+
A moção passa!
+ ) : (
+
A moção nao passsa.
+ ) : null}
+
+
+
+
+
+
+ Fechar
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/frontend/src/components/ui/spinner.tsx b/frontend/src/components/ui/spinner.tsx
new file mode 100644
index 0000000..8dca22b
--- /dev/null
+++ b/frontend/src/components/ui/spinner.tsx
@@ -0,0 +1,10 @@
+import { cn } from "@/lib/utils"
+import { Loader2Icon } from "lucide-react"
+
+function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+
+ )
+}
+
+export { Spinner }
diff --git a/frontend/src/context/SessionContext.tsx b/frontend/src/context/SessionContext.tsx
index 2e37bd1..c2347a4 100644
--- a/frontend/src/context/SessionContext.tsx
+++ b/frontend/src/context/SessionContext.tsx
@@ -3,7 +3,7 @@ import { createContext, useEffect, useState } from 'react';
import { useAuth } from './AuthContext';
import { useParams } from 'react-router-dom';
import { UpdateStore } from '@/store/useCommitteeStore';
-import { type SessionEvent, type SessionRepresentation, type AuthenticateMessage, type ServerSessionMessage, type EventMessage } from '@/schemas/types.gen';
+import { type SessionEvent, type SessionRepresentation, type AuthenticateMessage, type ServerSessionMessage, type EventMessage, SessionEffectType, type SessionEffect } from '@/schemas/types.gen';
interface SessionContextType {
@@ -18,6 +18,15 @@ const SessionContext = createContext({
let socket: WebSocket | null = null
+
+
+// 2. Augment the global HTMLElementEventMap (or WindowEventMap)
+declare global {
+ interface HTMLElementEventMap {
+ 'voteclose': CustomEvent;
+ }
+}
+
export function SessionProvider({ children }: { children: ReactNode }) {
const { token } = useAuth()
const { sessionId } = useParams<{ sessionId: string }>();
@@ -58,6 +67,11 @@ export function SessionProvider({ children }: { children: ReactNode }) {
UpdateStore(data.state);
if (data.effect) {
console.log("Side effect / event result", data.effect);
+
+ if(data.effect?.type === SessionEffectType.VOTE_CLOSED){
+ const closeevnt = new CustomEvent("voteclose", {"detail": data.effect});
+ window.dispatchEvent(closeevnt); //possibly inefficient
+ }
}
break;
}
diff --git a/frontend/src/pages/Session.tsx b/frontend/src/pages/Session.tsx
index 72c9075..6511751 100644
--- a/frontend/src/pages/Session.tsx
+++ b/frontend/src/pages/Session.tsx
@@ -2,22 +2,37 @@ import { Navigate, useParams } from 'react-router-dom';
import { useAuth } from '@/context/AuthContext';
import { useCommitteeStore } from '../store/useCommitteeStore.ts'
import { SessionProvider } from '@/context/SessionContext.tsx';
-import MotionsList from "@/components/session/motions-list"
-import SpeakerList from "@/components/session/speaker-list"
+import MotionsList from "@/components/session/Sidebar/motions-list.tsx"
+import SpeakerList from "@/components/session/Sidebar/speaker-list.tsx"
+import ModeratedDebate from "@/components/session/Sidebar/moderated-debate.tsx"
+import UnmoderatedDebate from "@/components/session/Sidebar/unmoderated-debate.tsx"
+import VotingMenu from "@/components/session/Sidebar/voting.tsx"
import BottomBar from "@/components/session/bottom-bar"
import TopBar from '@/components/session/top-bar';
import DelegationMap from '@/components/session/delegation-map';
import VotingPopup from '@/components/session/voting-popup.tsx';
+import VotingResultsPopup from '@/components/session/voting-results-popup.tsx';
+import RollCall from '@/components/session/Sidebar/rollcall.tsx';
+import { Spinner } from "@/components/ui/spinner"
+import { States } from '@/schemas/types.gen';
+import { Clock8 } from 'lucide-react';
export default function SessionPage() {
- const {loading, token } = useAuth()
+
+ const { loading, token } = useAuth()
// id that matches the name given in the Route path, at App.tsx
const { sessionId } = useParams<{ sessionId: string }>();
const parsedSessionId = Number(sessionId);
const all = useCommitteeStore();
+ const currentState = useCommitteeStore((state) => state.current_state)
- if (loading) return Loading session…
;
+ if (loading) return (
+
+
+ < p > Loading session…
+
+ );
if (!token) return ;
if (!Number.isInteger(parsedSessionId) || parsedSessionId < 1) {
return Invalid session ID.
;
@@ -25,35 +40,38 @@ export default function SessionPage() {
console.log(all);
return (
-
-
- {/*
+
+
+ {/*
{status}
{sessionStart ? `${uptime}s` : "Waiting for session..."}
*/}
-
-
-
-
-
-
-
- {//{debateType === DebateTypes.UNMODERATED_DEBATE &&
}
- //{debateType === DebateTypes.MODERATED_DEBATE &&
}
- //{debateType === DebateTypes.SPEAKERS_LIST &&
}
- }
-
-
+
+
+
+
+
+
+
+
+ {currentState === States.SETUP_ROOM &&
}
+ {currentState === States.OPEN_GSL &&
}
+ {currentState === States.ROLL_CALL &&
}
+ {currentState === States.MODERATED_CAUCUS &&
}
+ {currentState === States.UNMODERATED_CAUCUS &&
}
+ {currentState === States.VOTING_EXECUTION &&
}
+ {currentState !== States.SETUP_ROOM &&
}
+
+
+
-
-
-
+
);
}
diff --git a/frontend/src/schemas/types.gen.ts b/frontend/src/schemas/types.gen.ts
index 17e3a5c..329d2af 100644
--- a/frontend/src/schemas/types.gen.ts
+++ b/frontend/src/schemas/types.gen.ts
@@ -101,6 +101,8 @@ export const ChairEvents = {
NEXT_SPEAKER_EVENT: 'NextSpeakerEvent',
ADD_GSL_SPEAKER_EVENT: 'AddGslSpeakerEvent',
GRANT_FLOOR_EVENT: 'GrantFloorEvent',
+ CEDE_TIME_EVENT: 'CedeTimeEvent',
+ END_SPEECH_EVENT: 'EndSpeechEvent',
MARK_ROLL_CALL_EVENT: 'MarkRollCallEvent',
MARK_ROLL_CALL_BULK_EVENT: 'MarkRollCallBulkEvent',
CLOSE_ROLL_CALL_EVENT: 'CloseRollCallEvent'
@@ -182,6 +184,27 @@ export type CastVoteEvent = {
payload: DelegateVotingPayload;
};
+/**
+ * CedeTimeEvent
+ */
+export type CedeTimeEvent = {
+ /**
+ * Type
+ */
+ type: 'CedeTimeEvent';
+ payload: CedeTimePayload;
+};
+
+/**
+ * CedeTimePayload
+ */
+export type CedeTimePayload = {
+ /**
+ * Representation Id
+ */
+ representation_id: number;
+};
+
/**
* ChairIncreaseTimerPayload
*/
@@ -407,6 +430,17 @@ export type EmptyPayload = {
[key: string]: unknown;
};
+/**
+ * EndSpeechEvent
+ */
+export type EndSpeechEvent = {
+ /**
+ * Type
+ */
+ type: 'EndSpeechEvent';
+ payload: EmptyPayload;
+};
+
/**
* FinishCaucusEvent
*/
@@ -857,6 +891,10 @@ export type SessionEvent = ({
} & AddGslSpeakerEvent) | ({
type: 'GrantFloorEvent';
} & GrantFloorEvent) | ({
+ type: 'CedeTimeEvent';
+} & CedeTimeEvent) | ({
+ type: 'EndSpeechEvent';
+} & EndSpeechEvent) | ({
type: 'SetAgenda';
} & SetAgendaEvent) | ({
type: 'SetAgendaItemEvent';
@@ -942,6 +980,10 @@ export type EventMessage = {
} & AddGslSpeakerEvent) | ({
type: 'GrantFloorEvent';
} & GrantFloorEvent) | ({
+ type: 'CedeTimeEvent';
+ } & CedeTimeEvent) | ({
+ type: 'EndSpeechEvent';
+ } & EndSpeechEvent) | ({
type: 'SetAgenda';
} & SetAgendaEvent) | ({
type: 'SetAgendaItemEvent';
@@ -1167,12 +1209,7 @@ export type RollCallContext = {
*/
export type SessionEffect = {
type: SessionEffectType;
- /**
- * Data
- */
- data?: {
- [key: string]: unknown;
- };
+ data?: VotingContext;
};
/**