This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Monolith Integration]: Update to align with current implementation (#…
…263) * Introduce route methods and removed payment mocks * Use wcif for schedule and events * remove accidental import of process * added route for payment finish * Update Frontend/package.json Co-authored-by: Kevin Matthews <49137025+kr-matthews@users.noreply.github.com> * Update Frontend/src/pages/register/components/StripeWrapper.jsx Co-authored-by: Kevin Matthews <49137025+kr-matthews@users.noreply.github.com> * Update Frontend/src/pages/register/components/StripeWrapper.jsx Co-authored-by: Kevin Matthews <49137025+kr-matthews@users.noreply.github.com> * Update Frontend/src/pages/schedule/index.jsx Co-authored-by: Kevin Matthews <49137025+kr-matthews@users.noreply.github.com> * review changes * Get Swagger up to date and introduce open-api fetch in the frontend * fix missing js changes in schedule and events * changed HTTP Versb to be capital as per new openapi-fetch version * fix API contract for getSingleRegistration * fix API contract for getAllRegistrations * fix API contract for updateRegistration * fix API Contract for updateRegistrations * linting * fixed tests * fix rubocop * Add error message if events or schedule fails to load --------- Co-authored-by: Kevin Matthews <49137025+kr-matthews@users.noreply.github.com>
- Loading branch information
1 parent
30fa22b
commit 1c4f4db
Showing
41 changed files
with
758 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import externalServiceFetch from '../../helper/external_service_fetch' | ||
import { competitionInfoRoute } from '../../helper/routes' | ||
import { CompetitionInfo } from '../../types' | ||
|
||
export default async function getCompetitionInfo( | ||
competitionId: string | ||
): Promise<CompetitionInfo> { | ||
return externalServiceFetch( | ||
`https://test-registration.worldcubeassociation.org/api/v10/competitions/${competitionId}` | ||
) | ||
return externalServiceFetch(competitionInfoRoute(competitionId)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Competition } from '@wca/helpers' | ||
import externalServiceFetch from '../../helper/external_service_fetch' | ||
import { competitionWCIFRoute } from '../../helper/routes' | ||
|
||
export default async function getCompetitionWcif( | ||
competitionId: string | ||
): Promise<Competition> { | ||
return externalServiceFetch(competitionWCIFRoute(competitionId)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
// see app/helpers/error_codes.rb | ||
// TODO generate these errors out of some kind of shared error file | ||
export const INVALID_TOKEN = -1 | ||
export const EXPIRED_TOKEN = -2 | ||
export const MISSING_AUTHENTICATION = -3 | ||
export const SERVICE_DOWN = -4 | ||
|
||
export const COMPETITION_NOT_FOUND = -1000 | ||
export const COMPETITION_API_5XX = -1001 | ||
export const COMPETITION_CLOSED = -1002 | ||
export const COMPETITION_INVALID_EVENTS = -1003 | ||
|
||
export const USER_IMPERSONATION = -2000 | ||
export const USER_IS_BANNED = -2001 | ||
export const USER_PROFILE_INCOMPLETE = -2002 | ||
export const USER_INSUFFICIENT_PERMISSIONS = -2003 | ||
export const USER_NOT_LOGGED_IN = -2004 | ||
|
||
export const REGISTRATION_NOT_FOUND = -3000 | ||
export const PAYMENT_NOT_ENABLED = -3001 | ||
export const PAYMENT_NOT_READY = -3002 | ||
export const INVALID_REQUEST_DATA = -4000 | ||
export const EVENT_EDIT_DEADLINE_PASSED = -4001 | ||
export const GUEST_LIMIT_EXCEEDED = -4002 | ||
export const USER_COMMENT_TOO_LONG = -4003 | ||
export const INVALID_EVENT_SELECTION = -4004 | ||
export const REQUIRED_COMMENT_MISSING = -4005 | ||
export const COMPETITOR_LIMIT_REACHED = -4006 | ||
export const INVALID_REGISTRATION_STATUS = -4007 | ||
export const REGISTRATION_CLOSED = -4008 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export const tokenRoute = `${process.env.WCA_URL}/api/v0/users/token` | ||
export const permissionsRoute = `${process.env.WCA_URL}/api/v0/users/me/permissions` | ||
export const paymentConfigRoute = `${process.env.WCA_URL}/payment/config` | ||
export const paymentFinishRoute = (competitionId: string, userId: string) => | ||
`${process.env.WCA_URL}/payment/${competitionId}-${userId}/finish` | ||
// TODO: Move this to swagger once finalised | ||
export const paymentIdRoute = (id: string) => | ||
`${process.env.API_URL}/${id}/payment` | ||
export const meRoute = `${process.env.WCA_URL}/api/v0/users/me` | ||
// This will break when urls get really big, maybe we should switch to POST? | ||
export const usersInfoRoute = (ids: string[]) => | ||
`${process.env.WCA_URL}/api/v0/users?${ids | ||
.map((id) => 'ids[]=' + id) | ||
.join('&')}` | ||
// Hardcoded because these are currently not mocked | ||
export const competitionInfoRoute = (id: string) => | ||
`https://api.worldcubeassociation.org/competitions/${id}` | ||
export const competitionWCIFRoute = (id: string) => | ||
`https://api.worldcubeassociation.org/competitions/${id}/wcif/public` | ||
export const userInfoRoute = (id: string) => | ||
`https://api.worldcubeassociation.org/users/${id}` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
import externalServiceFetch from '../../helper/external_service_fetch' | ||
import getStripeConfigMock from '../../mocks/get_stripe_config' | ||
import { paymentConfigRoute } from '../../helper/routes' | ||
|
||
export interface StripeConfig { | ||
stripe_publishable_key: string | ||
connected_account_id: string | ||
client_secret: string | ||
} | ||
|
||
export default async function getStripeConfig( | ||
competitionId: string | ||
competitionId: string, | ||
paymentId: string | ||
): Promise<StripeConfig> { | ||
if (process.env.NODE_ENV === 'production') { | ||
// This should live in the payment service? | ||
return externalServiceFetch( | ||
`https://test-registration.worldcubeassociation.org/api/v10/payment/${competitionId}/config` | ||
) | ||
} | ||
|
||
return getStripeConfigMock() | ||
return externalServiceFetch(paymentConfigRoute, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: { | ||
competitionId, | ||
paymentId, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
import backendFetch from '../../helper/backend_fetch' | ||
import getPaymentIntentMock from '../../mocks/get_payment_intent' | ||
import { paymentIdRoute } from '../../helper/routes' | ||
|
||
export interface PaymentInfo { | ||
client_secret_id: string | ||
// This is the MySQL payment id that can be give to the payment service | ||
// to get the relevant data, not the Stripe ID! | ||
payment_id: string | ||
} | ||
// We get the user_id out of the JWT key, which is why we only send the | ||
// competition_id | ||
export default async function getPaymentIntent( | ||
export default async function getPaymentId( | ||
competitionId: string | ||
): Promise<PaymentInfo> { | ||
if (process.env.NODE_ENV === 'production') { | ||
// This should live in the payment service? | ||
return backendFetch(`/${competitionId}/payment`, 'GET', { | ||
needsAuthentication: true, | ||
}) as Promise<PaymentInfo> | ||
} | ||
return getPaymentIntentMock() | ||
return backendFetch(paymentIdRoute(competitionId), 'GET', { | ||
needsAuthentication: true, | ||
}) as Promise<PaymentInfo> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.