feat: add URL parameter support for pricing modal using action=showPricing

This commit is contained in:
lyzno1 2025-11-11 15:15:40 +08:00
parent 81afd087f6
commit 707c94f86e
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View File

@ -2,3 +2,4 @@ export const EDUCATION_VERIFY_URL_SEARCHPARAMS_ACTION = 'getEducationVerify'
export const EDUCATION_VERIFYING_LOCALSTORAGE_ITEM = 'educationVerifying'
export const EDUCATION_PRICING_SHOW_ACTION = 'educationPricing'
export const EDUCATION_RE_VERIFY_ACTION = 'educationReVerify'
export const SHOW_PRICING_MODAL_ACTION = 'showPricing'

View File

@ -3,7 +3,7 @@
import type { Dispatch, SetStateAction } from 'react'
import { useCallback, useState } from 'react'
import { createContext, useContext, useContextSelector } from 'use-context-selector'
import { useRouter, useSearchParams } from 'next/navigation'
import { useSearchParams } from 'next/navigation'
import type {
ConfigurationMethodEnum,
Credential,
@ -13,6 +13,7 @@ import type {
} from '@/app/components/header/account-setting/model-provider-page/declarations'
import {
EDUCATION_VERIFYING_LOCALSTORAGE_ITEM,
SHOW_PRICING_MODAL_ACTION,
} from '@/app/education-apply/constants'
import type { ModerationConfig, PromptVariable } from '@/models/debug'
import type {
@ -151,8 +152,9 @@ export const ModalContextProvider = ({
const [showEducationExpireNoticeModal, setShowEducationExpireNoticeModal] = useState<ModalState<ExpireNoticeModalPayloadProps> | null>(null)
const searchParams = useSearchParams()
const router = useRouter()
const [showPricingModal, setShowPricingModal] = useState(searchParams.get('show-pricing') === '1')
const [showPricingModal, setShowPricingModal] = useState(
searchParams.get('action') === SHOW_PRICING_MODAL_ACTION,
)
const [showAnnotationFullModal, setShowAnnotationFullModal] = useState(false)
const handleCancelAccountSettingModal = () => {
const educationVerifying = localStorage.getItem(EDUCATION_VERIFYING_LOCALSTORAGE_ITEM)
@ -308,8 +310,6 @@ export const ModalContextProvider = ({
{
!!showPricingModal && (
<Pricing onCancel={() => {
if (searchParams.get('show-pricing') === '1')
router.push(location.pathname, { forceOptimisticNavigation: true } as any)
removeSpecificQueryParam('action')
setShowPricingModal(false)
}} />