feat: notice of the expire of education verify (#24210)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -26,6 +26,7 @@ import type { UpdatePluginPayload } from '@/app/components/plugins/types'
|
||||
import { removeSpecificQueryParam } from '@/utils'
|
||||
import { noop } from 'lodash-es'
|
||||
import dynamic from 'next/dynamic'
|
||||
import type { ExpireNoticeModalPayloadProps } from '@/app/education-apply/expire-notice-modal'
|
||||
|
||||
const AccountSetting = dynamic(() => import('@/app/components/header/account-setting'), {
|
||||
ssr: false,
|
||||
@@ -64,6 +65,10 @@ const UpdatePlugin = dynamic(() => import('@/app/components/plugins/update-plugi
|
||||
ssr: false,
|
||||
})
|
||||
|
||||
const ExpireNoticeModal = dynamic(() => import('@/app/education-apply/expire-notice-modal'), {
|
||||
ssr: false,
|
||||
})
|
||||
|
||||
export type ModalState<T> = {
|
||||
payload: T
|
||||
onCancelCallback?: () => void
|
||||
@@ -102,6 +107,7 @@ export type ModalContextState = {
|
||||
onAutoAddPromptVariable?: (variable: PromptVariable[]) => void
|
||||
}> | null>>
|
||||
setShowUpdatePluginModal: Dispatch<SetStateAction<ModalState<UpdatePluginPayload> | null>>
|
||||
setShowEducationExpireNoticeModal: Dispatch<SetStateAction<ModalState<ExpireNoticeModalPayloadProps> | null>>
|
||||
}
|
||||
const ModalContext = createContext<ModalContextState>({
|
||||
setShowAccountSettingModal: noop,
|
||||
@@ -116,6 +122,7 @@ const ModalContext = createContext<ModalContextState>({
|
||||
setShowModelLoadBalancingEntryModal: noop,
|
||||
setShowOpeningModal: noop,
|
||||
setShowUpdatePluginModal: noop,
|
||||
setShowEducationExpireNoticeModal: noop,
|
||||
})
|
||||
|
||||
export const useModalContext = () => useContext(ModalContext)
|
||||
@@ -145,6 +152,7 @@ export const ModalContextProvider = ({
|
||||
onAutoAddPromptVariable?: (variable: PromptVariable[]) => void
|
||||
}> | null>(null)
|
||||
const [showUpdatePluginModal, setShowUpdatePluginModal] = useState<ModalState<UpdatePluginPayload> | null>(null)
|
||||
const [showEducationExpireNoticeModal, setShowEducationExpireNoticeModal] = useState<ModalState<ExpireNoticeModalPayloadProps> | null>(null)
|
||||
|
||||
const searchParams = useSearchParams()
|
||||
const router = useRouter()
|
||||
@@ -272,6 +280,7 @@ export const ModalContextProvider = ({
|
||||
setShowModelLoadBalancingEntryModal,
|
||||
setShowOpeningModal,
|
||||
setShowUpdatePluginModal,
|
||||
setShowEducationExpireNoticeModal,
|
||||
}}>
|
||||
<>
|
||||
{children}
|
||||
@@ -318,7 +327,7 @@ export const ModalContextProvider = ({
|
||||
<Pricing onCancel={() => {
|
||||
if (searchParams.get('show-pricing') === '1')
|
||||
router.push(location.pathname, { forceOptimisticNavigation: true } as any)
|
||||
|
||||
removeSpecificQueryParam('action')
|
||||
setShowPricingModal(false)
|
||||
}} />
|
||||
)
|
||||
@@ -398,6 +407,13 @@ export const ModalContextProvider = ({
|
||||
/>
|
||||
)
|
||||
}
|
||||
{
|
||||
!!showEducationExpireNoticeModal && (
|
||||
<ExpireNoticeModal
|
||||
{...showEducationExpireNoticeModal.payload}
|
||||
onClose={() => setShowEducationExpireNoticeModal(null)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
</ModalContext.Provider>
|
||||
)
|
||||
|
||||
@@ -48,6 +48,10 @@ type ProviderContextState = {
|
||||
enableEducationPlan: boolean
|
||||
isEducationWorkspace: boolean
|
||||
isEducationAccount: boolean
|
||||
allowRefreshEducationVerify: boolean
|
||||
educationAccountExpireAt: number | null
|
||||
isLoadingEducationAccountInfo: boolean
|
||||
isFetchingEducationAccountInfo: boolean
|
||||
webappCopyrightEnabled: boolean
|
||||
licenseLimit: {
|
||||
workspace_members: {
|
||||
@@ -90,6 +94,10 @@ const ProviderContext = createContext<ProviderContextState>({
|
||||
enableEducationPlan: false,
|
||||
isEducationWorkspace: false,
|
||||
isEducationAccount: false,
|
||||
allowRefreshEducationVerify: false,
|
||||
educationAccountExpireAt: null,
|
||||
isLoadingEducationAccountInfo: false,
|
||||
isFetchingEducationAccountInfo: false,
|
||||
webappCopyrightEnabled: false,
|
||||
licenseLimit: {
|
||||
workspace_members: {
|
||||
@@ -135,7 +143,7 @@ export const ProviderContextProvider = ({
|
||||
|
||||
const [enableEducationPlan, setEnableEducationPlan] = useState(false)
|
||||
const [isEducationWorkspace, setIsEducationWorkspace] = useState(false)
|
||||
const { data: isEducationAccount } = useEducationStatus(!enableEducationPlan)
|
||||
const { data: educationAccountInfo, isLoading: isLoadingEducationAccountInfo, isFetching: isFetchingEducationAccountInfo } = useEducationStatus(!enableEducationPlan)
|
||||
const [isAllowTransferWorkspace, setIsAllowTransferWorkspace] = useState(false)
|
||||
|
||||
const fetchPlan = async () => {
|
||||
@@ -223,7 +231,11 @@ export const ProviderContextProvider = ({
|
||||
datasetOperatorEnabled,
|
||||
enableEducationPlan,
|
||||
isEducationWorkspace,
|
||||
isEducationAccount: isEducationAccount?.result || false,
|
||||
isEducationAccount: educationAccountInfo?.is_student || false,
|
||||
allowRefreshEducationVerify: educationAccountInfo?.allow_refresh || false,
|
||||
educationAccountExpireAt: educationAccountInfo?.expire_at || null,
|
||||
isLoadingEducationAccountInfo,
|
||||
isFetchingEducationAccountInfo,
|
||||
webappCopyrightEnabled,
|
||||
licenseLimit,
|
||||
refreshLicenseLimit: fetchPlan,
|
||||
|
||||
Reference in New Issue
Block a user