diff --git a/src/Registration/Registration.API/Controllers/VolunteerController.cs b/src/Registration/Registration.API/Controllers/VolunteerController.cs index 42a0956..2992c3e 100644 --- a/src/Registration/Registration.API/Controllers/VolunteerController.cs +++ b/src/Registration/Registration.API/Controllers/VolunteerController.cs @@ -2,25 +2,24 @@ using Microsoft.AspNetCore.Mvc; using Registration.API.Services; using Registration.Domain.Models; -namespace Registration.API.Controllers +namespace Registration.API.Controllers; + +[Route("api/[controller]")] +[ApiController] +public class VolunteerController(IVbytesVolunteerRelayService relayService) : ControllerBase { - [Route("api/[controller]")] - [ApiController] - public class VolunteerController(IVbytesVolunteerRelayService relayService) : ControllerBase + private readonly IVbytesVolunteerRelayService _relayService = relayService; + + [HttpPost("register")] + public async Task RegisterVolunteer([FromBody] Volunteer volunteer, CancellationToken cancellationToken) { - private readonly IVbytesVolunteerRelayService _relayService = relayService; + var result = await _relayService.RegisterVolunteerAsync(volunteer, cancellationToken); - [HttpPost("register")] - public async Task RegisterVolunteer([FromBody] Volunteer volunteer, CancellationToken cancellationToken) + if (result.StatusCode == 200 && !result.Message.Contains("401")) { - var result = await _relayService.RegisterVolunteerAsync(volunteer, cancellationToken); - - if (result.Success) - { - return Ok(); - } - - return StatusCode(result.StatusCode, new { message = result.Message }); + return Ok(); } + + return Unauthorized(); } } diff --git a/src/Registration/Registration.Domain/Models/EventContent.cs b/src/Registration/Registration.Domain/Models/EventContent.cs index 5a4b9c3..3eb6441 100644 --- a/src/Registration/Registration.Domain/Models/EventContent.cs +++ b/src/Registration/Registration.Domain/Models/EventContent.cs @@ -10,4 +10,8 @@ public class EventContent public string LocationAddress { get; set; } = string.Empty; public string WhatToBring { get; set; } = string.Empty; public string RulesAndGdpr { get; set; } = string.Empty; + public string AdditionalInfo { get; set; } = string.Empty; + public bool RegistrationEnabled { get; set; } = true; + public bool VisitorOnly { get; set; } = false; + public string VolunteerAreas { get; set; } = string.Empty; } diff --git a/src/Registration/Registration.Infra/Repositories/MemberRepository.cs b/src/Registration/Registration.Infra/Repositories/MemberRepository.cs index 66c85a3..b6593e1 100644 --- a/src/Registration/Registration.Infra/Repositories/MemberRepository.cs +++ b/src/Registration/Registration.Infra/Repositories/MemberRepository.cs @@ -46,7 +46,7 @@ public class MemberRepository(IConfiguration configuration) : IMemberRepository CREATE INDEX IF NOT EXISTS idx_members_ssn_index ON members(ssn_index); CREATE TABLE IF NOT EXISTS event_content ( - id INT PRIMARY KEY, + id SERIAL PRIMARY KEY, title TEXT, sub_title TEXT, event_date TEXT, @@ -54,11 +54,21 @@ public class MemberRepository(IConfiguration configuration) : IMemberRepository location_name TEXT, location_address TEXT, what_to_bring TEXT, - rules_and_gdpr TEXT + rules_and_gdpr TEXT, + additional_info TEXT, + registration_enabled BOOLEAN DEFAULT TRUE, + visitor_only BOOLEAN DEFAULT FALSE, + volunteer_areas TEXT DEFAULT '' ); + ALTER TABLE event_content ADD COLUMN IF NOT EXISTS additional_info TEXT; + ALTER TABLE event_content ADD COLUMN IF NOT EXISTS registration_enabled BOOLEAN DEFAULT TRUE; + ALTER TABLE event_content ADD COLUMN IF NOT EXISTS visitor_only BOOLEAN DEFAULT FALSE; + ALTER TABLE event_content ADD COLUMN IF NOT EXISTS volunteer_areas TEXT DEFAULT ''; - INSERT INTO event_content (id, title, sub_title, event_date, event_time, location_name, location_address, what_to_bring, rules_and_gdpr) - SELECT 1, '', '', '', '', '', '', '', '' + UPDATE event_content SET volunteer_areas = 'Kiosk & Kök' || chr(10) || 'Städning' || chr(10) || 'Entré & Incheckning' || chr(10) || 'Teknisk Support' || chr(10) || 'All-round' WHERE id = 1 AND (volunteer_areas IS NULL OR volunteer_areas = ''); + + INSERT INTO event_content (id, title, sub_title, event_date, event_time, location_name, location_address, what_to_bring, rules_and_gdpr, additional_info, registration_enabled, visitor_only, volunteer_areas) + SELECT 1, '', '', '', '', '', '', '', '', '', TRUE, FALSE, 'Kiosk & Kök' || chr(10) || 'Städning' || chr(10) || 'Entré & Incheckning' || chr(10) || 'Teknisk Support' || chr(10) || 'All-round' WHERE NOT EXISTS (SELECT 1 FROM event_content WHERE id = 1); "; @@ -98,7 +108,7 @@ public class MemberRepository(IConfiguration configuration) : IMemberRepository public async Task GetEventContent() { using var connection = CreateConnection(); - var content = await connection.QueryFirstOrDefaultAsync("SELECT title, sub_title as SubTitle, event_date as EventDate, event_time as EventTime, location_name as LocationName, location_address as LocationAddress, what_to_bring as WhatToBring, rules_and_gdpr as RulesAndGdpr FROM event_content WHERE id = 1"); + var content = await connection.QueryFirstOrDefaultAsync("SELECT title, sub_title as SubTitle, event_date as EventDate, event_time as EventTime, location_name as LocationName, location_address as LocationAddress, what_to_bring as WhatToBring, rules_and_gdpr as RulesAndGdpr, additional_info as AdditionalInfo, registration_enabled as RegistrationEnabled, visitor_only as VisitorOnly, volunteer_areas as VolunteerAreas FROM event_content WHERE id = 1"); return content ?? new EventContent(); } @@ -114,7 +124,11 @@ public class MemberRepository(IConfiguration configuration) : IMemberRepository location_name = @LocationName, location_address = @LocationAddress, what_to_bring = @WhatToBring, - rules_and_gdpr = @RulesAndGdpr + rules_and_gdpr = @RulesAndGdpr, + additional_info = @AdditionalInfo, + registration_enabled = @RegistrationEnabled, + visitor_only = @VisitorOnly, + volunteer_areas = @VolunteerAreas WHERE id = 1"; await connection.ExecuteAsync(sql, content); } diff --git a/src/Web/lan-frontend/app/admin/dashboard/page.tsx b/src/Web/lan-frontend/app/admin/dashboard/page.tsx index 4b0a051..ca7a895 100644 --- a/src/Web/lan-frontend/app/admin/dashboard/page.tsx +++ b/src/Web/lan-frontend/app/admin/dashboard/page.tsx @@ -13,6 +13,10 @@ interface EventContent { locationAddress: string; whatToBring: string; rulesAndGdpr: string; + additionalInfo: string; + registrationEnabled: boolean; + visitorOnly: boolean; + volunteerAreas: string; } export default function AdminDashboard() { @@ -97,8 +101,37 @@ export default function AdminDashboard() {
+
+
+ setContent(prev => prev ? { ...prev, registrationEnabled: e.target.checked } : null)} + /> + +
+
+ setContent(prev => prev ? { ...prev, visitorOnly: e.target.checked } : null)} + /> + +
+
+
- +
- +
- +
- +
- +
- + +