-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/app-migration-bot-firewall
- Loading branch information
Showing
14 changed files
with
120 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { useState } from 'react'; | ||
'use client'; | ||
|
||
import { FunctionComponent, Suspense, useState } from 'react'; | ||
import { UseCaseWrapper } from '../../client/components/common/UseCaseWrapper/UseCaseWrapper'; | ||
import React from 'react'; | ||
import { USE_CASES } from '../../client/components/common/content'; | ||
|
@@ -9,13 +11,14 @@ import { CloseSnackbarButton } from '../../client/components/common/Alert/Alert' | |
import { enqueueSnackbar } from 'notistack'; | ||
import { useCopyToClipboard } from 'react-use'; | ||
import { BackArrow } from '../../client/components/common/BackArrow/BackArrow'; | ||
import { GetServerSideProps, NextPage } from 'next'; | ||
import { SubmitCodeForm } from '../../client/components/sms-pumping/SubmitCodeForm'; | ||
import { PhoneNumberForm } from '../../client/components/sms-pumping/PhoneNumberForm'; | ||
import { GetServerSideProps } from 'next'; | ||
import { SubmitCodeForm } from './components/SubmitCodeForm'; | ||
import { PhoneNumberForm } from './components/PhoneNumberForm'; | ||
import { useVisitorData } from '@fingerprintjs/fingerprintjs-pro-react'; | ||
import { useMutation } from 'react-query'; | ||
import { SendSMSResponse, SendSMSPayload } from '../api/sms-pumping/send-verification-sms'; | ||
import { TEST_PHONE_NUMBER } from '../../server/sms-pumping/smsPumpingConst'; | ||
import { useSearchParams } from 'next/navigation'; | ||
import { SendSMSPayload, SendSMSResponse } from './api/send-verification-sms/route'; | ||
import { TEST_PHONE_NUMBER } from './api/smsPumpingConst'; | ||
|
||
type FormStep = 'Send SMS' | 'Submit code'; | ||
type QueryAsProps = { | ||
|
@@ -50,7 +53,7 @@ export const useSendMessage = ({ onSuccess, disableBotDetection = false }: SendM | |
mutationKey: 'sendSms', | ||
mutationFn: async ({ phoneNumber, email }) => { | ||
const { requestId } = await getData(); | ||
const response = await fetch(`/api/sms-pumping/send-verification-sms`, { | ||
const response = await fetch(`/sms-pumping/api/send-verification-sms`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
|
@@ -76,12 +79,16 @@ export const useSendMessage = ({ onSuccess, disableBotDetection = false }: SendM | |
}); | ||
}; | ||
|
||
const SmsFraudUseCase: NextPage<QueryAsProps> = ({ disableBotDetection }) => { | ||
const SmsFraud: FunctionComponent = () => { | ||
// Default mocked user data | ||
const [phoneNumber, setPhoneNumber] = useState(TEST_PHONE_NUMBER); | ||
const [email, setEmail] = useState('[email protected]'); | ||
const [formStep, setFormStep] = useState<FormStep>('Send SMS'); | ||
|
||
const searchParams = useSearchParams(); | ||
const disableBotDetection = | ||
searchParams?.get('disableBotDetection') === '1' || searchParams?.get('disableBotDetection') === 'true'; | ||
|
||
const [, copyToClipboard] = useCopyToClipboard(); | ||
const sendMessageMutation = useSendMessage({ | ||
onSuccess: (data) => { | ||
|
@@ -138,4 +145,11 @@ const SmsFraudUseCase: NextPage<QueryAsProps> = ({ disableBotDetection }) => { | |
); | ||
}; | ||
|
||
export default SmsFraudUseCase; | ||
export const SmsPumpingUseCase = () => { | ||
// Suspense required due to useSearchParams() https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout | ||
return ( | ||
<Suspense> | ||
<SmsFraud /> | ||
</Suspense> | ||
); | ||
}; |
2 changes: 1 addition & 1 deletion
2
src/server/sms-pumping/database.ts → src/app/sms-pumping/api/database.ts
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
6 changes: 3 additions & 3 deletions
6
src/server/sms-pumping/smsPumpingConst.ts → src/app/sms-pumping/api/smsPumpingConst.ts
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
4 changes: 2 additions & 2 deletions
4
...omponents/sms-pumping/PhoneNumberForm.tsx → ...ms-pumping/components/PhoneNumberForm.tsx
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
8 changes: 4 additions & 4 deletions
8
...ents/sms-pumping/SendSMSMessageButton.tsx → ...mping/components/SendSMSMessageButton.tsx
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
File renamed without changes.
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 { USE_CASES } from '../../../client/components/common/content'; | ||
import { generateUseCaseMetadata } from '../../../client/components/common/seo'; | ||
import { SmsPumpingUseCase } from '../SmsPumping'; | ||
|
||
export const metadata = generateUseCaseMetadata(USE_CASES.smsPumping); | ||
|
||
export default function SmsPumping() { | ||
return <SmsPumpingUseCase />; | ||
} |
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 { USE_CASES } from '../../client/components/common/content'; | ||
import { generateUseCaseMetadata } from '../../client/components/common/seo'; | ||
import { SmsPumpingUseCase } from './SmsPumping'; | ||
|
||
export const metadata = generateUseCaseMetadata(USE_CASES.smsPumping); | ||
|
||
export default function SmsPumping() { | ||
return <SmsPumpingUseCase />; | ||
} |
Oops, something went wrong.