Skip to content

Commit

Permalink
bug(plan) fix redirection when closing a plan duplication form
Browse files Browse the repository at this point in the history
  • Loading branch information
ansmonjol committed Nov 3, 2023
1 parent fee96f4 commit 0e9377b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cypress/e2e/10-resources/t50-edit-plan.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ describe('Edit plan', () => {
cy.get(`[data-test="add-subscription"]`).click({ force: true })
cy.get('[data-test="submit"]').should('be.disabled')
cy.get('input[name="planId"]').click({ force: true })
cy.get('[data-option-index="0"]').click({ force: true })
cy.get('[data-option-index="0"]').click()
cy.get('[data-test="submit"]').click({ force: true })
cy.get('[data-test="submit"]').should('not.exist')
cy.contains(customerName).should('exist')
})

Expand Down
4 changes: 3 additions & 1 deletion src/pages/CreatePlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { FixedFeeSection } from '~/components/plans/FixedFeeSection'
import { PlanCodeSnippet } from '~/components/plans/PlanCodeSnippet'
import { PlanSettingsSection } from '~/components/plans/PlanSettingsSection'
import { WarningDialog, WarningDialogRef } from '~/components/WarningDialog'
import { useDuplicatePlanVar } from '~/core/apolloClient'
import { FORM_TYPE_ENUM } from '~/core/constants/form'
import { PLAN_DETAILS_ROUTE, PLANS_ROUTE } from '~/core/router'
import {
Expand Down Expand Up @@ -103,14 +104,15 @@ gql`
const CreatePlan = () => {
const navigate = useNavigate()
const { translate } = useInternationalization()
const { type: actionType } = useDuplicatePlanVar()
const { errorCode, formikProps, isEdition, loading, plan, type } = usePlanForm({})
const warningDialogRef = useRef<WarningDialogRef>(null)
const editInvoiceDisplayNameRef = useRef<EditInvoiceDisplayNameRef>(null)

const canBeEdited = !plan?.subscriptionsCount

const planCloseRedirection = () => {
if (plan?.id) {
if (plan?.id && actionType !== FORM_TYPE_ENUM.duplicate) {
navigate(
generatePath(PLAN_DETAILS_ROUTE, {
planId: plan.id,
Expand Down

0 comments on commit 0e9377b

Please sign in to comment.