diff --git a/availabili.tf/src/assets/main.css b/availabili.tf/src/assets/main.css index 819edc2..98f1900 100644 --- a/availabili.tf/src/assets/main.css +++ b/availabili.tf/src/assets/main.css @@ -271,7 +271,7 @@ hr { /*box-shadow: 0 0 4px var(--text);*/ } -div[role="menu"] { +[role="menu"] { background-color: var(--base); border: 1px solid var(--overlay-0); border-radius: 4px; @@ -279,22 +279,22 @@ div[role="menu"] { min-width: 8rem; } -div[role="menu"] button { +[role="menu"] button { background-color: var(--base); width: 100%; border-radius: 0; } -div[role="menu"] button.destructive { +[role="menu"] button.destructive { color: var(--destructive); } -div[role="menu"] button.destructive:hover { +[role="menu"] button.destructive:hover { background-color: var(--destructive); color: var(--base); } -div[role="menu"] button > i.bi.margin { +[role="menu"] button > i.bi.margin { margin-right: 0.5em; } /* @@ -309,7 +309,7 @@ div[role="menu"] div[role="menuitem"]:last-child button { } */ -div[role="menu"] button:hover { +[role="menu"] button:hover { background-color: var(--surface-0); width: 100%; } diff --git a/availabili.tf/src/client/index.ts b/availabili.tf/src/client/index.ts index 45058cf..49bd56f 100644 --- a/availabili.tf/src/client/index.ts +++ b/availabili.tf/src/client/index.ts @@ -11,6 +11,7 @@ export { OpenAPI } from './core/OpenAPI'; export type { OpenAPIConfig } from './core/OpenAPI'; export type { AddPlayerJson } from './models/AddPlayerJson'; +export type { AttendanceJson } from './models/AttendanceJson'; export type { AvailabilitySchema } from './models/AvailabilitySchema'; export type { CreateEventJson } from './models/CreateEventJson'; export type { CreateTeamJson } from './models/CreateTeamJson'; diff --git a/availabili.tf/src/client/models/AttendanceJson.ts b/availabili.tf/src/client/models/AttendanceJson.ts new file mode 100644 index 0000000..fbba659 --- /dev/null +++ b/availabili.tf/src/client/models/AttendanceJson.ts @@ -0,0 +1,8 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type AttendanceJson = { + confirm: boolean; +}; + diff --git a/availabili.tf/src/client/services/DefaultService.ts b/availabili.tf/src/client/services/DefaultService.ts index 9acdd5a..ffb0f33 100644 --- a/availabili.tf/src/client/services/DefaultService.ts +++ b/availabili.tf/src/client/services/DefaultService.ts @@ -3,6 +3,7 @@ /* tslint:disable */ /* eslint-disable */ import type { AddPlayerJson } from '../models/AddPlayerJson'; +import type { AttendanceJson } from '../models/AttendanceJson'; import type { CreateEventJson } from '../models/CreateEventJson'; import type { CreateTeamJson } from '../models/CreateTeamJson'; import type { EditMemberRolesJson } from '../models/EditMemberRolesJson'; @@ -197,11 +198,13 @@ export class DefaultService { /** * attend_event * @param eventId + * @param requestBody * @returns EventWithPlayerSchema OK * @throws ApiError */ public attendEvent( eventId: number, + requestBody?: AttendanceJson, ): CancelablePromise { return this.httpRequest.request({ method: 'PUT', @@ -209,6 +212,8 @@ export class DefaultService { path: { 'event_id': eventId, }, + body: requestBody, + mediaType: 'application/json', errors: { 422: `Unprocessable Content`, }, diff --git a/availabili.tf/src/components/EventCard.vue b/availabili.tf/src/components/EventCard.vue index 91b16cf..0efc48e 100644 --- a/availabili.tf/src/components/EventCard.vue +++ b/availabili.tf/src/components/EventCard.vue @@ -6,6 +6,7 @@ import { useTeamsEventsStore } from "@/stores/teams/events"; import moment from "moment"; import { computed } from "vue"; import EventCardDropdown from "./EventCardDropdown.vue"; +import EventConfirmButton from "./EventConfirmButton.vue"; const teamsStore = useTeamsStore(); const rosterStore = useRosterStore(); const teamEventsStore = useTeamsEventsStore(); @@ -46,16 +47,13 @@ function attend() { teamEventsStore.attendEvent(props.event.event.id); } -function unattend() { - teamEventsStore.unattendEvent(props.event.event.id); +function pending() { + console.log("pending"); + teamEventsStore.attendEvent(props.event.event.id, false); } -function attendOrUnattend() { - if (props.event.playerEvent?.hasConfirmed) { - unattend(); - } else { - attend(); - } +function unattend() { + teamEventsStore.unattendEvent(props.event.event.id); } @@ -87,30 +85,12 @@ function attendOrUnattend() { No description provided.
- - +
@@ -193,9 +173,4 @@ h3 { justify-content: space-between; align-items: center; } - -button.confirmed { - background-color: var(--text); - color: var(--base); -} diff --git a/availabili.tf/src/components/EventConfirmButton.vue b/availabili.tf/src/components/EventConfirmButton.vue new file mode 100644 index 0000000..db143d2 --- /dev/null +++ b/availabili.tf/src/components/EventConfirmButton.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/availabili.tf/src/stores/teams/events.ts b/availabili.tf/src/stores/teams/events.ts index c6b8eed..7181260 100644 --- a/availabili.tf/src/stores/teams/events.ts +++ b/availabili.tf/src/stores/teams/events.ts @@ -21,12 +21,15 @@ export const useTeamsEventsStore = defineStore("teamsEvents", () => { ); } - async function attendEvent(eventId: number) { - return client.default.attendEvent(eventId) + async function attendEvent(eventId: number, confirm = true) { + return client.default.attendEvent(eventId, { + confirm, + }) .then((response) => { let index = teamEvents[response.event.teamId] .findIndex((event) => event.event.id == response.event.id); teamEvents[response.event.teamId][index] = response; + return response; }); } diff --git a/backend-flask/events.py b/backend-flask/events.py index af2ff6c..ec967a7 100644 --- a/backend-flask/events.py +++ b/backend-flask/events.py @@ -143,6 +143,9 @@ def create_event(player_team: PlayerTeam, team_id: int, json: CreateEventJson, * return EventSchema.from_model(event).dict(by_alias=True), 200 +class AttendanceJson(BaseModel): + confirm: bool + @api_events.put("//attendance") @spec.validate( resp=Response( @@ -151,7 +154,7 @@ def create_event(player_team: PlayerTeam, team_id: int, json: CreateEventJson, * operation_id="attend_event", ) @requires_authentication -def attend_event(player: Player, event_id: int, **_): +def attend_event(player: Player, event_id: int, json: AttendanceJson, **_): event = db.session.query(Event).where(Event.id == event_id).one_or_none() if not event: @@ -175,7 +178,7 @@ def attend_event(player: Player, event_id: int, **_): player_event.player_id = player.steam_id db.session.add(player_event) - player_event.has_confirmed = True + player_event.has_confirmed = json.confirm db.session.commit()