Skip to content

Commit

Permalink
Merge pull request #2223 from saithsab877/add-content-modal-flows
Browse files Browse the repository at this point in the history
Fixed: Hide `Location` Step during `Add Content` Flow
  • Loading branch information
Rassl authored Sep 25, 2024
2 parents 46a8b38 + 41ec733 commit a6d9457
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
3 changes: 1 addition & 2 deletions cypress/e2e/addContent/addTweet.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ describe('Add Tweet Content', () => {
cy.get('#addContent').should('exist')
cy.get('[id="cy-youtube-channel-id"]').type('https://twitter.com/ijbguy/status/1771096005162729663')
cy.get('[data-testid="add-content-btn"]').click()
cy.get('[data-testid="skip-location-btn"').click()
cy.get('[data-testid="check-icon"]').click()

cy.wait('@addTweet').then((interception) => {
//check we get a 402 response code, when trying to add content for the first time
// check we get a 402 response code, when trying to add content for the first time
expect(interception.response.statusCode).to.eq(402)
})

Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/addContent/addWebpage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ describe('Add Webpage Content', () => {
cy.get('[id="cy-youtube-channel-id"]').type('https://www.netflix.com/browse')
cy.wait(1000)
cy.get('[data-testid="add-content-btn"]').should('not.be.disabled').click()
cy.get('[data-testid="skip-location-btn"').click()
cy.get('[data-testid="check-icon"]').click()

cy.wait('@addWebpage').then((interception) => {
//check we get a 402 response code, when trying to add content for the first time
// check we get a 402 response code, when trying to add content for the first time
expect(interception.response.statusCode).to.eq(402)
})

Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/addContent/addYoutube.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ describe('Add Youtube Content', () => {
cy.get('[id="cy-youtube-channel-id"]').type('https://www.youtube.com/watch?v=dPLPSaFqJmY')
cy.wait(1000)
cy.get('[data-testid="add-content-btn"]').should('not.be.disabled').click()
cy.get('[data-testid="skip-location-btn"').click()
cy.get('[data-testid="check-icon"]').click()

cy.wait('@addYoutube').then((interception) => {
//check we get a 402 response code, when trying to add content for the first time
// check we get a 402 response code, when trying to add content for the first time
expect(interception.response.statusCode).to.eq(402)
})

Expand Down
20 changes: 7 additions & 13 deletions src/components/AddContentModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { SubmitErrRes } from '~/types'
import { getLSat, payLsat, updateBudget } from '~/utils'
import { SuccessNotify } from '../common/SuccessToast'
import { BudgetStep } from './BudgetStep'
import { LocationStep } from './LocationStep'
import { SourceStep } from './SourceStep'
import { validateSourceURL } from './SourceStep/utils'
import { SourceTypeStep } from './SourceTypeStep'
Expand Down Expand Up @@ -165,9 +164,6 @@ export const AddContentModal = () => {
const type = watch('inputType')
const sourceValue = watch('source')

const longitude = watch('longitude')
const latitude = watch('latitude')

const source = watch('source')

const isValidSource = validateSourceURL(sourceValue)
Expand All @@ -181,7 +177,11 @@ export const AddContentModal = () => {
}

const onNextStep = () => {
setCurrentStep(currentStep + 1)
if (currentStep === 0) {
setCurrentStep(isSource(type) ? 1 : 2)
} else {
setCurrentStep(currentStep + 1)
}
}

const onPrevStep = () => {
Expand Down Expand Up @@ -218,14 +218,8 @@ export const AddContentModal = () => {
<FormProvider {...form}>
<form id="add-node-form" onSubmit={onSubmit}>
{currentStep === 0 && <SourceStep allowNextStep={isValidSource} onNextStep={onNextStep} type={type} />}
{currentStep === 1 && (
<>
{!isSource(type) ? (
<LocationStep form={form} latitude={latitude} longitude={longitude} onNextStep={onNextStep} />
) : (
<SourceTypeStep onNextStep={onNextStep} onPrevStep={onPrevStep} type={type} value={sourceValue} />
)}
</>
{currentStep === 1 && isSource(type) && (
<SourceTypeStep onNextStep={onNextStep} onPrevStep={onPrevStep} type={type} value={sourceValue} />
)}
{currentStep === 2 && <BudgetStep error={error} loading={loading} onClick={() => null} type={type} />}
</form>
Expand Down

0 comments on commit a6d9457

Please sign in to comment.