'use client' import { useTranslation } from 'react-i18next' import useSWR from 'swr' import { useRouter, useSearchParams } from 'next/navigation' import cn from '@/utils/classnames' import Button from '@/app/components/base/button' import { invitationCheck } from '@/service/common' import Loading from '@/app/components/base/loading' const ActivateForm = () => { const router = useRouter() const { t } = useTranslation() const searchParams = useSearchParams() const workspaceID = searchParams.get('workspace_id') const email = searchParams.get('email') const token = searchParams.get('token') const checkParams = { url: '/activate/check', params: { ...workspaceID && { workspace_id: workspaceID }, ...email && { email }, token, }, } const { data: checkRes } = useSWR(checkParams, invitationCheck, { revalidateOnFocus: false, onSuccess(data) { if (data.is_valid) { const params = new URLSearchParams(searchParams) const { email, workspace_id } = data.data params.set('email', encodeURIComponent(email)) params.set('workspace_id', encodeURIComponent(workspace_id)) params.set('invite_token', encodeURIComponent(token as string)) router.replace(`/signin?${params.toString()}`) } }, }) return (