Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Fix issues found on staging #283

Merged
merged 10 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"build:types": "TYPES_ONLY=true node src/build.mjs",
"build:dev": "NODE_ENV=\"development\" ASSET_PATH=\"/dist\" API_URL=\"http://localhost:3001/api/v1\" AUTH_URL=\"http://localhost:3001/jwt\" node src/build.mjs",
"build:staging": "POLL_URL=\"https://1rq8d7dif3.execute-api.us-west-2.amazonaws.com/v1/staging\" NODE_ENV=\"staging\" ASSET_PATH=\"https://d1qizdh27al0a7.cloudfront.net/staging/dist\" API_URL=\"https://staging.registration.worldcubeassociation.org/api/v1\" WCA_URL=\"https://staging.worldcubeassociation.org\" node src/build.mjs",
"build:staging": "POLL_URL=\"https://1rq8d7dif3.execute-api.us-west-2.amazonaws.com/v1/staging\" NODE_ENV=\"production\" ASSET_PATH=\"https://d1qizdh27al0a7.cloudfront.net/staging/dist\" API_URL=\"https://staging.registration.worldcubeassociation.org/api/v1\" WCA_URL=\"https://staging.worldcubeassociation.org\" node src/build.mjs",
FinnIckler marked this conversation as resolved.
Show resolved Hide resolved
"build:prod": "POLL_URL=\"https://1rq8d7dif3.execute-api.us-west-2.amazonaws.com/v1/prod\" NODE_ENV=\"production\" ASSET_PATH=\"https://d1qizdh27al0a7.cloudfront.net/dist\" API_URL=\"https://registration.worldcubeassociation.org/api/v1\" WCA_URL=\"https://worldcubeassociation.org\" node src/build.mjs",
"watch": "node src/watch.mjs",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
Expand Down
19 changes: 10 additions & 9 deletions Frontend/src/index.dev.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Registrations from './pages/registrations'
import Schedule from './pages/schedule'
import TestLogin from './pages/test/login'
import TestLogout from './pages/test/logout'
import { BASE_ROUTE } from './routes'
import App from './ui/App'
import Competition from './ui/Competition'
import CustomTab from './ui/CustomTab'
Expand Down Expand Up @@ -60,7 +61,7 @@ const router = createBrowserRouter([
),
},
{
path: '/competitions/:competition_id',
path: `${BASE_ROUTE}/:competition_id`,
element: (
<Container>
<Competition>
Expand All @@ -73,35 +74,35 @@ const router = createBrowserRouter([
),
children: [
{
path: '/competitions/:competition_id',
path: `${BASE_ROUTE}/:competition_id`,
element: <HomePage />,
},
{
path: '/competitions/:competition_id/events',
path: `${BASE_ROUTE}/:competition_id/events`,
element: <Events />,
},
{
path: '/competitions/:competition_id/schedule',
path: `${BASE_ROUTE}/:competition_id/schedule`,
element: <Schedule />,
},
{
path: '/competitions/:competition_id/register',
path: `${BASE_ROUTE}/:competition_id/register`,
element: <Register />,
},
{
path: '/competitions/:competition_id/tabs/:tab_id',
path: `${BASE_ROUTE}/:competition_id/tabs/:tab_id`,
element: <CustomTab />,
},
{
path: '/competitions/:competition_id/registrations',
path: `${BASE_ROUTE}/:competition_id/registrations`,
element: <Registrations />,
},
{
path: '/competitions/:competition_id/:user_id/edit',
path: `${BASE_ROUTE}/:competition_id/:user_id/edit`,
element: <RegistrationEdit />,
},
{
path: '/competitions/:competition_id/registrations/edit',
path: `${BASE_ROUTE}/:competition_id/registrations/edit`,
element: <RegistrationAdministration />,
},
],
Expand Down
81 changes: 3 additions & 78 deletions Frontend/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,10 @@
import '@thewca/wca-components/dist/index.esm.css'
import React from 'react'
import { createRoot } from 'react-dom/client'
import { createBrowserRouter, Outlet, RouterProvider } from 'react-router-dom'
import { Container } from 'semantic-ui-react'
import Events from './pages/events'
import HomePage from './pages/home'
import Register from './pages/register'
import RegistrationAdministration from './pages/registration_administration'
import RegistrationEdit from './pages/registration_edit'
import Registrations from './pages/registrations'
import Schedule from './pages/schedule'
import App from './ui/App'
import Competition from './ui/Competition'
import CustomTab from './ui/CustomTab'
import FlashMessage from './ui/messages/flashMessage'
import PermissionsProvider from './ui/providers/PermissionsProvider'
import UserProvider from './ui/providers/UserProvider'
import PageTabs from './ui/Tabs'
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
import routes from './routes'

const router = createBrowserRouter([
{
path: '/competitions',
element: (
<App>
<FlashMessage />
<UserProvider>
<Outlet />
</UserProvider>
</App>
),
children: [
{
path: '/competitions/:competition_id',
element: (
<Container>
<Competition>
<PermissionsProvider>
<PageTabs />
<Outlet />
</PermissionsProvider>
</Competition>
</Container>
),
children: [
{
path: '/competitions/:competition_id',
element: <HomePage />,
},
{
path: '/competitions/:competition_id/events',
element: <Events />,
},
{
path: '/competitions/:competition_id/schedule',
element: <Schedule />,
},
{
path: '/competitions/:competition_id/register',
element: <Register />,
},
{
path: '/competitions/:competition_id/tabs/:tab_id',
element: <CustomTab />,
},
{
path: '/competitions/:competition_id/registrations',
element: <Registrations />,
},
{
path: '/competitions/:competition_id/:user_id/edit',
element: <RegistrationEdit />,
},
{
path: '/competitions/:competition_id/registrations/edit',
element: <RegistrationAdministration />,
},
],
},
],
},
])
const router = createBrowserRouter(routes)

// Render the React component into the body of the monolith
const root = createRoot(document.querySelector('#registration-app'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { setMessage } from '../../../ui/events/messages'
import LoadingMessage from '../../../ui/messages/loadingMessage'
import styles from './list.module.scss'
import RegistrationActions from './RegistrationActions'
import { BASE_ROUTE } from '../../../routes'

// Currently it is at the developer's discretion to make sure
// an attendee is added to the right list.
Expand Down Expand Up @@ -276,7 +277,7 @@ function RegistrationAdministrationTable({
</Table.Cell>
<Table.Cell>
<Link
to={`/competitions/${competition_id}/${registration.user.id}/edit`}
to={`${BASE_ROUTE}/${competition_id}/${registration.user.id}/edit`}
>
Edit
</Link>
Expand Down
84 changes: 84 additions & 0 deletions Frontend/src/routes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React from 'react'
import { Outlet } from 'react-router-dom'
import { Container } from 'semantic-ui-react'
import Events from './pages/events'
import HomePage from './pages/home'
import Register from './pages/register'
import RegistrationAdministration from './pages/registration_administration'
import RegistrationEdit from './pages/registration_edit'
import Registrations from './pages/registrations'
import Schedule from './pages/schedule'
import App from './ui/App'
import Competition from './ui/Competition'
import CustomTab from './ui/CustomTab'
import FlashMessage from './ui/messages/flashMessage'
import PermissionsProvider from './ui/providers/PermissionsProvider'
import UserProvider from './ui/providers/UserProvider'
import PageTabs from './ui/Tabs'

export const BASE_ROUTE = '/competitions/v2'

const routes = [
{
path: BASE_ROUTE,
element: (
<App>
<FlashMessage />
<UserProvider>
<Outlet />
</UserProvider>
</App>
),
children: [
{
path: `${BASE_ROUTE}/:competition_id`,
element: (
<Container>
<Competition>
<PermissionsProvider>
<PageTabs />
<Outlet />
</PermissionsProvider>
</Competition>
</Container>
),
children: [
{
path: `${BASE_ROUTE}/:competition_id`,
element: <HomePage />,
},
{
path: `${BASE_ROUTE}/:competition_id/events`,
element: <Events />,
},
{
path: `${BASE_ROUTE}/:competition_id/schedule`,
element: <Schedule />,
},
{
path: `${BASE_ROUTE}/:competition_id/register`,
element: <Register />,
},
{
path: `${BASE_ROUTE}/:competition_id/tabs/:tab_id`,
element: <CustomTab />,
},
{
path: `${BASE_ROUTE}/:competition_id/registrations`,
element: <Registrations />,
},
{
path: `${BASE_ROUTE}/:competition_id/:user_id/edit`,
element: <RegistrationEdit />,
},
{
path: `${BASE_ROUTE}/:competition_id/registrations/edit`,
element: <RegistrationAdministration />,
},
],
},
],
},
]

export default routes
3 changes: 2 additions & 1 deletion Frontend/src/ui/Competition.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import getCompetitionInfo from '../api/competition/get/get_competition_info'
import { CompetitionContext } from '../api/helper/context/competition_context'
import styles from './competition.module.scss'
import LoadingMessage from './messages/loadingMessage'
import { BASE_ROUTE } from '../routes'

export default function Competition({ children }) {
const { competition_id } = useParams()
Expand Down Expand Up @@ -64,7 +65,7 @@ export default function Competition({ children }) {
onClick={(_, data) => {
if (!data.disabled) {
if (competitionInfo.use_wca_registration) {
navigate(`/competitions/${competitionInfo.id}/register`)
navigate(`${BASE_ROUTE}/${competitionInfo.id}/register`)
} else {
window.location =
competitionInfo.external_registration_page
Expand Down
15 changes: 8 additions & 7 deletions Frontend/src/ui/Tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Menu, Tab } from 'semantic-ui-react'
import { CompetitionContext } from '../api/helper/context/competition_context'
import { PermissionsContext } from '../api/helper/context/permission_context'
import styles from './tabs.module.scss'
import { BASE_ROUTE } from '../routes'

function pathMatch(name, pathname) {
const registerExpression = /\/competitions\/[a-zA-Z0-9]+\/register/
Expand Down Expand Up @@ -50,7 +51,7 @@ export default function PageTabs() {
name="register"
className={styles.tabItem}
onClick={() =>
navigate(`/competitions/${competitionInfo.id}/register`)
navigate(`${BASE_ROUTE}/${competitionInfo.id}/register`)
}
>
<UiIcon name="sign in alt" />
Expand All @@ -68,7 +69,7 @@ export default function PageTabs() {
name="registrations"
className={styles.tabItem}
onClick={() =>
navigate(`/competitions/${competitionInfo.id}/registrations/edit`)
navigate(`${BASE_ROUTE}/${competitionInfo.id}/registrations/edit`)
}
>
<UiIcon name="list ul" />
Expand All @@ -86,7 +87,7 @@ export default function PageTabs() {
name="competitors"
className={styles.tabItem}
onClick={() =>
navigate(`/competitions/${competitionInfo.id}/registrations`)
navigate(`${BASE_ROUTE}/${competitionInfo.id}/registrations`)
}
>
<UiIcon name="users" />
Expand All @@ -103,7 +104,7 @@ export default function PageTabs() {
key="tab-info"
name="info"
className={styles.tabItem}
onClick={() => navigate(`/competitions/${competitionInfo.id}`)}
onClick={() => navigate(`${BASE_ROUTE}/${competitionInfo.id}`)}
>
<UiIcon name="info" />
General Info
Expand All @@ -119,7 +120,7 @@ export default function PageTabs() {
name="events"
className={styles.tabItem}
onClick={() =>
navigate(`/competitions/${competitionInfo.id}/events`)
navigate(`${BASE_ROUTE}/${competitionInfo.id}/events`)
}
>
<CubingIcon event={competitionInfo.main_event_id} selected />
Expand All @@ -135,7 +136,7 @@ export default function PageTabs() {
name="schedule"
className={styles.tabItem}
onClick={() =>
navigate(`/competitions/${competitionInfo.id}/schedule`)
navigate(`${BASE_ROUTE}/${competitionInfo.id}/schedule`)
}
>
<UiIcon name="calendar" />
Expand All @@ -152,7 +153,7 @@ export default function PageTabs() {
name={`tabs-${tab.id}`}
className={styles.tabItem}
onClick={() =>
navigate(`/competitions/${competitionInfo.id}/tabs/${tab.id}`)
navigate(`${BASE_ROUTE}/${competitionInfo.id}/tabs/${tab.id}`)
}
>
{tab.name}
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/registration_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def validate_create_request

user_can_create_registration!

can_compete, reasons = UserApi.can_compete?(@user_id)
raise RegistrationError.new(:unauthorized, reasons) unless can_compete
can_compete = UserApi.can_compete?(@user_id)
raise RegistrationError.new(:unauthorized, ErrorCodes::USER_PROFILE_INCOMPLETE) unless can_compete

validate_events!
raise RegistrationError.new(:unprocessable_entity, ErrorCodes::GUEST_LIMIT_EXCEEDED) if params.key?(:guests) && @competition.guest_limit_exceeded?(params[:guests])
Expand Down Expand Up @@ -171,12 +171,12 @@ def payment_ticket
refresh = params[:refresh]
if refresh || @registration.payment_ticket.nil?
amount, currency_code = @competition.payment_info
ticket, account_id = PaymentApi.get_ticket(@registration[:attendee_id], amount, currency_code)
ticket = PaymentApi.get_ticket(@registration[:attendee_id], amount, currency_code)
@registration.init_payment_lane(amount, currency_code, ticket)
else
ticket = @registration.payment_ticket
end
render json: { client_secret_id: ticket, connected_account_id: account_id }
render json: { id: ticket }
end

def validate_payment_ticket_request
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/lane_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def self.competing_lane(event_ids = [], comment = '', guests = 0)
competing_lane
end

def self.payment_lane(fee_lowest_denominator, currency_code, payment_intent_client_secret)
def self.payment_lane(fee_lowest_denominator, currency_code, payment_id)
payment_lane = Lane.new({})
payment_lane.lane_name = 'payment'
payment_lane.completed_steps = ['Payment Intent Init']
payment_lane.lane_state = 'initialized'
payment_lane.lane_details = {
amount_lowest_denominator: fee_lowest_denominator,
payment_intent_client_secret: payment_intent_client_secret,
payment_intent_client_secret: payment_id,
currency_code: currency_code,
}
payment_lane
Expand Down
Loading