From 53d6505d53e4d4230e26bc29e05fe3df856fa2c6 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 28 Nov 2023 10:12:59 +0100 Subject: [PATCH] Fix Frontend Tests (#319) * correctly save and display guests * Correctly disable the button if no comment is set and show placeholder * Don't disable the register button if you are an organizer * safe access user id * fix rubocop * fix update competing lane * safe access of user * don't show error message if not logged in * don't show error message if not logged in * set user to null explicitly if not logged in * combing permission messages * Don't show Delete Registration button if you are not allowed to * switch to column parameters * rubocop changes * Only show delete registration button if registration is open * Don't allow whitespace comments * Don't show update button after event change deadline * Show Re-Register button if registration status is cancelled * Handle cases where no event_change_deadline is set * Don't show update event button when deadline has passed for admins * fix typo when updating events as an admin * fix eslint * fix rubocop * move guests out of competing lane in factory * fix typo * fix typo * remove include and better control flow for reset method * new token route * localstack 3.0 fixes * fix event_details being accessed wrong * don't fetch user info if there are no registrations * switch get_stripe_config to GET * add whitespace: break to competition ui * distinguish betwenn Closed and Not Yet Open * show message when Registration edit deadline has passed * rename time cutoff to cutoff --- Frontend/src/api/helper/routes.ts | 5 +- .../src/api/payment/get/get_stripe_config.ts | 9 +- .../api/registration/get/get_registrations.ts | 17 ++- Frontend/src/pages/home/index.jsx | 50 ++++--- Frontend/src/pages/home/index.module.scss | 8 +- .../register/components/CompetingStep.jsx | 127 ++++++++++++------ Frontend/src/pages/register/index.jsx | 22 ++- .../components/RegistrationEditor.jsx | 100 +++++++++----- Frontend/src/pages/schedule/index.jsx | 2 +- Frontend/src/ui/Competition.jsx | 18 ++- Frontend/src/ui/competition.module.scss | 4 +- .../src/ui/providers/PermissionsProvider.jsx | 4 - Frontend/src/ui/providers/UserProvider.jsx | 11 +- app/controllers/registration_controller.rb | 4 +- app/helpers/lane_factory.rb | 3 +- app/models/registration.rb | 18 +-- app/worker/registration_processor.rb | 6 +- docker-compose.dev.yml | 13 +- lib/csv_import.rb | 6 +- spec/factories/registration_factory.rb | 2 +- 20 files changed, 266 insertions(+), 163 deletions(-) diff --git a/Frontend/src/api/helper/routes.ts b/Frontend/src/api/helper/routes.ts index 8d68492f..fc0ed3cb 100644 --- a/Frontend/src/api/helper/routes.ts +++ b/Frontend/src/api/helper/routes.ts @@ -1,6 +1,7 @@ -export const tokenRoute = `${process.env.WCA_URL}/api/v0/users/token` +export const tokenRoute = `${process.env.WCA_URL}/api/v0/users/me/token` export const permissionsRoute = `${process.env.WCA_URL}/api/v0/users/me/permissions` -export const paymentConfigRoute = `${process.env.WCA_URL}/payment/config` +export const paymentConfigRoute = (competitionId: string, paymentId: string) => + `${process.env.WCA_URL}/payment/config?competition_id=${competitionId}&payment_id=${paymentId}` export const paymentFinishRoute = (competitionId: string, userId: string) => `${process.env.WCA_URL}/payment/finish?attendee_id=${competitionId}-${userId}` diff --git a/Frontend/src/api/payment/get/get_stripe_config.ts b/Frontend/src/api/payment/get/get_stripe_config.ts index 2f960af9..62f96df7 100644 --- a/Frontend/src/api/payment/get/get_stripe_config.ts +++ b/Frontend/src/api/payment/get/get_stripe_config.ts @@ -11,12 +11,5 @@ export default async function getStripeConfig( competitionId: string, paymentId: string ): Promise { - return externalServiceFetch(paymentConfigRoute, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - competition_id: competitionId, - payment_id: paymentId, - }), - }) + return externalServiceFetch(paymentConfigRoute(competitionId, paymentId)) } diff --git a/Frontend/src/api/registration/get/get_registrations.ts b/Frontend/src/api/registration/get/get_registrations.ts index cd555d45..0a18304f 100644 --- a/Frontend/src/api/registration/get/get_registrations.ts +++ b/Frontend/src/api/registration/get/get_registrations.ts @@ -25,13 +25,16 @@ export async function getConfirmedRegistrations( if (!response.ok) { throw new BackendError(500, response.status) } - const userInfos = await getCompetitorsInfo(data!.map((d) => d.user_id)) - return data!.map((registration) => ({ - ...registration, - user: userInfos.users.find( - (user) => user.id === Number(registration.user_id) - ), - })) + if (data!.length > 0) { + const userInfos = await getCompetitorsInfo(data!.map((d) => d.user_id)) + return data!.map((registration) => ({ + ...registration, + user: userInfos.users.find( + (user) => user.id === Number(registration.user_id) + ), + })) + } + return [] } export async function getAllRegistrations( diff --git a/Frontend/src/pages/home/index.jsx b/Frontend/src/pages/home/index.jsx index d3a3865d..ddcb2567 100644 --- a/Frontend/src/pages/home/index.jsx +++ b/Frontend/src/pages/home/index.jsx @@ -42,42 +42,54 @@ export default function HomePage() { -
Date
-
City
-
Venue
-
Address
+
Date
+
City
+
Venue
+
+ Address +
{competitionInfo.venue_details && ( -
Details
+
+ Details +
)} -
Competitor Limit
-
Contact
-
Organizers
-
Delegates
+
+ Competitor Limit +
+
Contact
+
Organizers
+
Delegates
-
+
{competitionInfo.start_date === competitionInfo.end_date ? `${moment(competitionInfo.start_date).format('ll')}` : `${moment(competitionInfo.start_date).format( 'll' )} to ${moment(competitionInfo.end_date).format('ll')}`}
-
+
{competitionInfo.city}, {competitionInfo.country_iso2}
-
+

-
{competitionInfo.venue_address}
+
+ {competitionInfo.venue_address} +
{competitionInfo.venue_details && ( -
{competitionInfo.venue_details}
+
+ {competitionInfo.venue_details} +
)} -
{competitionInfo.competitor_limit}
-
+
+ {competitionInfo.competitor_limit} +
+
{competitionInfo.contact ? ( )}
-
+
{competitionInfo.organizers.map((organizer, index) => ( ))}
-
+
{competitionInfo.delegates.map((delegate, index) => ( -
+
Download all of the competitions details as a PDF{' '} diff --git a/Frontend/src/pages/home/index.module.scss b/Frontend/src/pages/home/index.module.scss index 8aab3b8f..83dac1b5 100644 --- a/Frontend/src/pages/home/index.module.scss +++ b/Frontend/src/pages/home/index.module.scss @@ -3,4 +3,10 @@ img{ display: none; } -} \ No newline at end of file +} + +.information-header{ + @media only screen and (max-width: 600px) { + font-size: 1.1em !important; + } +} diff --git a/Frontend/src/pages/register/components/CompetingStep.jsx b/Frontend/src/pages/register/components/CompetingStep.jsx index 65068492..7073a67e 100644 --- a/Frontend/src/pages/register/components/CompetingStep.jsx +++ b/Frontend/src/pages/register/components/CompetingStep.jsx @@ -52,7 +52,8 @@ export default function CompetingStep({ nextStep }) { setRegistration(registrationRequest.registration) setComment(registrationRequest.registration.competing.comment ?? '') setSelectedEvents(registrationRequest.registration.competing.event_ids) - setGuests(registrationRequest.registration.guests) + // Ruby sends this as "1.0" + setGuests(Number(registrationRequest.registration.guests)) } }, [registrationRequest]) const { mutate: updateRegistrationMutation, isLoading: isUpdating } = @@ -189,12 +190,17 @@ export default function CompetingStep({ nextStep }) {