Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/app/Components/Bidding/Components/Timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ export const Timer: React.FC<Props> = (props) => {
onCurrentTickerState={() => {
const state = currentTimerState(props)
const { label, date } = relevantStateData(state, props)
return { label, date, state } as any // STRICTNESS_MIGRATION
return { label, date, state }
}}
onNextTickerState={({ state }) => {
const nextState = nextTimerState(state as AuctionTimerState, props)
const { label, date } = relevantStateData(nextState, props)
return { state: nextState, label, date } as any // STRICTNESS_MIGRATION
return { state: nextState, label, date }
}}
/>
</TimeOffsetProviderWrapper>
Expand Down
4 changes: 2 additions & 2 deletions src/app/Components/Bidding/Components/Title.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Text } from "@artsy/palette-mobile"
import { Text, TextProps } from "@artsy/palette-mobile"

export const Title = (props: any /* STRICTNESS_MIGRATION */) => (
export const Title = (props: TextProps) => (
<Text variant="sm-display" weight="medium" m={4} textAlign="center" {...props} />
)
16 changes: 13 additions & 3 deletions src/app/Components/Bidding/Elements/Grid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { Flex } from "app/Components/Bidding/Elements/Flex"
import { Flex, FlexProps } from "app/Components/Bidding/Elements/Flex"
import { PropsWithChildren } from "react"

export const Row = (props: any /* STRICTNESS_MIGRATION */) => (
type GridProps = PropsWithChildren<
Omit<FlexProps, "flex"> & {
flex?: FlexProps["flex"] | null
flexGrow?: number
flexShrink?: number
flexBasis?: number | string
}
>

export const Row = (props: GridProps) => (
<Flex flexDirection="row" justifyContent="space-between" alignItems="center" {...props} />
)
export const Col = (props: any /* STRICTNESS_MIGRATION */) => <Flex flex={1} {...props} />
export const Col = (props: GridProps) => <Flex flex={1} {...props} />
42 changes: 16 additions & 26 deletions src/app/Components/Bidding/Screens/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export interface RegistrationProps
}

interface RegistrationState {
billingAddress?: Address
billingAddress?: Address | null
phoneNumber?: string
creditCardFormParams?: PaymentCardTextFieldParams
creditCardToken?: Token.Result
creditCardFormParams?: PaymentCardTextFieldParams | null
creditCardToken?: Token.Result | null
conditionsOfSaleChecked: boolean
isLoading: boolean
missingInformation: "payment" | "phone" | null
Expand Down Expand Up @@ -82,11 +82,8 @@ export class Registration extends React.Component<RegistrationProps, Registratio
}

this.state = {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
billingAddress: null,
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
creditCardToken: null,
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
creditCardFormParams: null,
conditionsOfSaleChecked: false,
missingInformation,
Expand Down Expand Up @@ -351,7 +348,6 @@ export class Registration extends React.Component<RegistrationProps, Registratio

navigation?.navigate("RegistrationResult", {
status,
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
needsIdentityVerification: bidderNeedsIdentityVerification({ sale, user: me }),
})

Expand Down Expand Up @@ -437,27 +433,21 @@ export class Registration extends React.Component<RegistrationProps, Registratio
{this.renderRequiredInfoForm()}
<Flex px={2}>
{this.renderRequiredInfoHint()}
{
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
!!bidderNeedsIdentityVerification({ sale, user: me }) && (
<>
<Hint>This auction requires Artsy to verify your identity before bidding.</Hint>
<Hint>
After you register, you’ll receive an email with a link to complete identity
verification.
</Hint>
</>
)
}
{
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
!missingInformation && !bidderNeedsIdentityVerification({ sale, user: me }) && (
{!!bidderNeedsIdentityVerification({ sale, user: me }) && (
<>
<Hint>This auction requires Artsy to verify your identity before bidding.</Hint>
<Hint>
To complete your registration, please confirm that you agree to the Conditions of
Sale.
After you register, you’ll receive an email with a link to complete identity
verification.
</Hint>
)
}
</>
)}
{!missingInformation && !bidderNeedsIdentityVerification({ sale, user: me }) && (
<Hint>
To complete your registration, please confirm that you agree to the Conditions of
Sale.
</Hint>
)}
<Modal
visible={this.state.errorModalVisible}
headerText="An error occurred"
Expand Down
55 changes: 15 additions & 40 deletions src/app/Components/Bidding/Screens/__tests__/Registration.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { navigate } from "app/system/navigation/navigate"
import { renderWithWrappers, renderWithWrappersLEGACY } from "app/utils/tests/renderWithWrappers"
import { TouchableWithoutFeedback } from "react-native"
import relay from "react-relay"
import { Disposable, MutationConfig, MutationParameters } from "relay-runtime"

const commitMutationMock = (fn?: typeof relay.commitMutation) =>
jest.fn<typeof relay.commitMutation, Parameters<typeof relay.commitMutation>>(fn as any)
const commitMutationMock = (
fn?: (environment: any, config: MutationConfig<MutationParameters>) => Disposable | null
) => jest.fn(fn)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


afterEach(() => {
jest.clearAllMocks()
Expand Down Expand Up @@ -150,18 +152,14 @@ describe("when the sale requires identity verification", () => {
describe("when pressing register button", () => {
it("when a credit card needs to be added, it commits two mutations on button press", async () => {
relay.commitMutation = commitMutationMock()
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted(mockRequestResponses.updateMyUserProfile, null)
onCompleted?.(mockRequestResponses.updateMyUserProfile, null)
return null
})
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onCompleted }) => {
onCompleted?.(mockRequestResponses.creatingCreditCardSuccess, null)
return null
})
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onCompleted }) => {
onCompleted?.(mockRequestResponses.qualifiedBidder, null)
return null
Expand Down Expand Up @@ -280,10 +278,8 @@ describe("when pressing register button", () => {
it("displays the default error message if there are unhandled errors from the updateUserProfile mutation", async () => {
const errors = [{ message: "malformed error" }]

// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
relay.commitMutation = commitMutationMock((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted({}, errors)
onCompleted?.({}, errors)
return null
}) as any

Expand Down Expand Up @@ -323,10 +319,8 @@ describe("when pressing register button", () => {

it("displays an error message on a updateUserProfile failure", async () => {
const errors = [{ message: "There was an error with your request" }]
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
relay.commitMutation = commitMutationMock((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted({}, errors)
onCompleted?.({}, errors)
return null
}) as any

Expand Down Expand Up @@ -405,13 +399,10 @@ describe("when pressing register button", () => {
console.error = jest.fn() // Silences component logging.
;(createToken as jest.Mock).mockReturnValueOnce(stripeToken)
relay.commitMutation = commitMutationMock()
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted(mockRequestResponses.updateMyUserProfile, null)
onCompleted?.(mockRequestResponses.updateMyUserProfile, null)
return null
})
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onCompleted }) => {
onCompleted?.(mockRequestResponses.creatingCreditCardError, null)
return null
Expand Down Expand Up @@ -444,13 +435,10 @@ describe("when pressing register button", () => {
;(createToken as jest.Mock).mockReturnValueOnce(stripeToken)

relay.commitMutation = commitMutationMock()
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted(mockRequestResponses.updateMyUserProfile, null)
onCompleted?.(mockRequestResponses.updateMyUserProfile, null)
return null
})
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onCompleted }) => {
onCompleted?.({}, errors)
return null
Expand Down Expand Up @@ -489,13 +477,10 @@ describe("when pressing register button", () => {
console.error = jest.fn() // Silences component logging.
;(createToken as jest.Mock).mockReturnValueOnce(stripeToken)
relay.commitMutation = commitMutationMock()
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted(mockRequestResponses.creatingCreditCardSuccess, null)
onCompleted?.(mockRequestResponses.creatingCreditCardSuccess, null)
return null
})
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
.mockImplementationOnce((_, { onError }) => {
onError?.(new TypeError("Network request failed"))
return null
Expand Down Expand Up @@ -561,10 +546,8 @@ describe("when pressing register button", () => {
})

it("displays an error message on a network failure", async () => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
relay.commitMutation = commitMutationMock((_, { onError }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onError(new TypeError("Network request failed"))
onError?.(new TypeError("Network request failed"))
return null
}) as any

Expand Down Expand Up @@ -593,10 +576,8 @@ describe("when pressing register button", () => {
})

it("displays the pending result when the bidder is not qualified_for_bidding", async () => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
relay.commitMutation = commitMutationMock((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted({ createBidder: { bidder: { qualified_for_bidding: false } } }, null)
onCompleted?.({ createBidder: { bidder: { qualified_for_bidding: false } } }, null)
return null
}) as any

Expand Down Expand Up @@ -629,10 +610,8 @@ describe("when pressing register button", () => {
requireIdentityVerification: true,
},
}
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
relay.commitMutation = commitMutationMock((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted({ createBidder: { bidder: { qualified_for_bidding: false } } }, null)
onCompleted?.({ createBidder: { bidder: { qualified_for_bidding: false } } }, null)
return null
}) as any

Expand All @@ -651,10 +630,8 @@ describe("when pressing register button", () => {
})

it("displays the completed result when the bidder is qualified_for_bidding", async () => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
relay.commitMutation = commitMutationMock((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted({ createBidder: { bidder: { qualified_for_bidding: true } } }, null)
onCompleted?.({ createBidder: { bidder: { qualified_for_bidding: true } } }, null)
return null
}) as any

Expand Down Expand Up @@ -687,10 +664,8 @@ describe("when pressing register button", () => {
},
}

// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
relay.commitMutation = commitMutationMock((_, { onCompleted }) => {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
onCompleted({ createBidder: { bidder: { qualified_for_bidding: true } } }, null)
onCompleted?.({ createBidder: { bidder: { qualified_for_bidding: true } } }, null)
return null
}) as any

Expand Down
7 changes: 4 additions & 3 deletions src/app/Components/Countdown/CountdownTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ enum TimerState {
PAST = "PAST",
}

// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
function relevantStateData(state, { startAt, endAt, formattedOpeningHours = "" }: Props) {
function relevantStateData(
state: TimerState,
{ startAt, endAt, formattedOpeningHours = "" }: Props
) {
switch (state) {
case TimerState.UPCOMING:
return {
Expand Down Expand Up @@ -54,7 +56,6 @@ function currentState({ startAt, endAt }: Props) {
export const CountdownTimer: React.FC<Props> = (props: Props) => {
const onState = () => {
const state = currentState(props)
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
const { label, date } = relevantStateData(state, props)
return { state, label, date }
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/Components/Countdown/DurationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react"
import { AppState, AppStateStatus, NativeEventSubscription } from "react-native"

interface Props {
startAt?: string
startAt?: string | null
timeOffsetInMilliseconds?: number
children: React.ReactElement<any>
onDurationEnd?: () => void
Expand Down
2 changes: 1 addition & 1 deletion src/app/Components/Countdown/StateManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DurationProvider } from "./DurationProvider"

export interface TickerState {
label?: string
date?: string
date?: string | null
hasStarted?: boolean
state: string
biddingEndAt?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ export const createGeminiAssetWithS3Credentials = (input: CreateGeminiEntryForAs
if (errors && errors.length > 0) {
reject(new Error(JSON.stringify(errors)))
} else {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
resolve(response.createGeminiEntryForAsset.asset.token)
const token = response.createGeminiEntryForAsset?.asset?.token
if (!token) {
reject(new Error("No asset token was returned"))
} else {
resolve(token)
}
}
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {
import { getRelayEnvironment } from "app/system/relay/defaultEnvironment"
import { commitMutation, graphql } from "react-relay"

export type AssetCredentials =
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
getGeminiCredentialsForEnvironmentMutation["response"]["requestCredentialsForAssetUpload"]["asset"]
export type AssetCredentials = NonNullable<
NonNullable<
getGeminiCredentialsForEnvironmentMutation["response"]["requestCredentialsForAssetUpload"]
>["asset"]
>

export const getGeminiCredentialsForEnvironment = (
input: RequestCredentialsForAssetUploadInput
Expand Down Expand Up @@ -47,8 +49,12 @@ export const getGeminiCredentialsForEnvironment = (
if (errors && errors.length > 0) {
reject(new Error(JSON.stringify(errors)))
} else {
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
resolve(response.requestCredentialsForAssetUpload.asset)
const asset = response.requestCredentialsForAssetUpload?.asset
if (!asset) {
reject(new Error("No asset credentials were returned"))
} else {
resolve(asset)
}
}
},
})
Expand Down
6 changes: 2 additions & 4 deletions src/app/Components/PhotoRow/utils/uploadFileToS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ export const uploadFileToS3 = ({
//
// Kinda sucks, but https://github.com/jhen0409/react-native-debugger/issues/38
const request = new XMLHttpRequest()
// @ts-expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
request.onload = (e) => {
request.onload = () => {
if (
e.target.status.toString() ===
assetCredentials.policyDocument.conditions.successActionStatus
request.status.toString() === assetCredentials.policyDocument.conditions.successActionStatus
) {
resolve({
key,
Expand Down
Loading
Loading