Merge branch 'feat/edu-version' into deploy/dev
This commit is contained in:
commit
c48168084f
@ -22,6 +22,7 @@ import Button from '@/app/components/base/button'
|
||||
import UsageInfo from '@/app/components/billing/usage-info'
|
||||
import VerifyStateModal from '@/app/education-apply/components/verify-state-modal'
|
||||
import { EDUCATION_VERIFYING_LOCALSTORAGE_ITEM } from '@/app/education-apply/components/constants'
|
||||
import { useEducationVerify } from '@/service/use-education'
|
||||
|
||||
type Props = {
|
||||
loc: string
|
||||
@ -44,14 +45,14 @@ const PlanComp: FC<Props> = ({
|
||||
} = plan
|
||||
|
||||
const [showModal, setShowModal] = React.useState(false)
|
||||
const { mutateAsync } = useEducationVerify()
|
||||
const handleVerify = () => {
|
||||
if (userProfile.email.endsWith('.edu')) {
|
||||
mutateAsync().then((res) => {
|
||||
localStorage.removeItem(EDUCATION_VERIFYING_LOCALSTORAGE_ITEM)
|
||||
router.push('/education-apply')
|
||||
}
|
||||
else {
|
||||
router.push(`/education-apply?token=${res.token}`)
|
||||
}).catch(() => {
|
||||
setShowModal(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
return (
|
||||
<div className='bg-background-section-burn rounded-2xl border-[0.5px] border-effects-highlight-lightmode-off'>
|
||||
|
@ -4,7 +4,10 @@ import {
|
||||
useState,
|
||||
} from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import {
|
||||
useRouter,
|
||||
useSearchParams,
|
||||
} from 'next/navigation'
|
||||
import UserInfo from './user-info'
|
||||
import SearchInput from './search-input'
|
||||
import RoleSelector from './role-selector'
|
||||
@ -13,7 +16,6 @@ import Button from '@/app/components/base/button'
|
||||
import Checkbox from '@/app/components/base/checkbox'
|
||||
import {
|
||||
useEducationAdd,
|
||||
useEducationVerify,
|
||||
useInvalidateEducationStatus,
|
||||
} from '@/service/use-education'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
@ -31,7 +33,6 @@ const EducationApplyAge = () => {
|
||||
mutateAsync: educationAdd,
|
||||
} = useEducationAdd({ onSuccess: () => {} })
|
||||
const [modalShow, setShowModal] = useState<undefined | { title: string; desc: string; onConfirm?: () => void }>(undefined)
|
||||
const { data } = useEducationVerify()
|
||||
const { onPlanInfoChanged } = useProviderContext()
|
||||
const updateEducationStatus = useInvalidateEducationStatus()
|
||||
const { notify } = useToastContext()
|
||||
@ -45,9 +46,11 @@ const EducationApplyAge = () => {
|
||||
router.replace('/')
|
||||
}
|
||||
|
||||
const searchParams = useSearchParams()
|
||||
const token = searchParams.get('token')
|
||||
const handleSubmit = () => {
|
||||
educationAdd({
|
||||
token: data?.token || '',
|
||||
token: token || '',
|
||||
role,
|
||||
institution: schoolName,
|
||||
}).then((res) => {
|
||||
|
@ -4,21 +4,26 @@ import {
|
||||
useEffect,
|
||||
useMemo,
|
||||
} from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import {
|
||||
useRouter,
|
||||
useSearchParams,
|
||||
} from 'next/navigation'
|
||||
import EducationApplyAge from './components/education-apply-page'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
|
||||
export default function EducationApply() {
|
||||
const router = useRouter()
|
||||
const { enableEducationPlan, isEducationAccount } = useProviderContext()
|
||||
const hiddenEducationApply = useMemo(() => {
|
||||
return enableEducationPlan && isEducationAccount
|
||||
}, [enableEducationPlan, isEducationAccount])
|
||||
const searchParams = useSearchParams()
|
||||
const token = searchParams.get('token')
|
||||
const showEducationApplyPage = useMemo(() => {
|
||||
return enableEducationPlan && !isEducationAccount && token
|
||||
}, [enableEducationPlan, isEducationAccount, token])
|
||||
|
||||
useEffect(() => {
|
||||
if (hiddenEducationApply)
|
||||
if (!showEducationApplyPage)
|
||||
router.replace('/')
|
||||
}, [hiddenEducationApply, router])
|
||||
}, [showEducationApplyPage, router])
|
||||
|
||||
return <EducationApplyAge />
|
||||
}
|
||||
|
@ -9,12 +9,11 @@ import type { EducationAddParams } from '@/app/education-apply/components/types'
|
||||
const NAME_SPACE = 'education'
|
||||
|
||||
export const useEducationVerify = () => {
|
||||
return useQuery({
|
||||
queryKey: [NAME_SPACE, 'education-verify'],
|
||||
queryFn: () => {
|
||||
return useMutation({
|
||||
mutationKey: [NAME_SPACE, 'education-verify'],
|
||||
mutationFn: () => {
|
||||
return get<{ token: string }>('/account/education/verify')
|
||||
},
|
||||
retry: false,
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user