Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/xi.web/src/pages/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
!location.pathname.includes('/signup') &&
!location.pathname.includes('/reset-password')
) {
if (location.pathname.startsWith('/invite/') && typeof window !== 'undefined') {
const segments = location.pathname.split('/');
const inviteId = segments[segments.length - 1];
if (inviteId) {
localStorage.setItem('invite.pending_code', inviteId);
}
}

throw redirect({
to: '/signin',
search: {
Expand Down
5 changes: 5 additions & 0 deletions packages/pages.invites/src/ui/InvitesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Logo } from 'common.ui';
import { useParams } from '@tanstack/react-router';
import { useEffect } from 'react';
import { Invite } from './Invite';
import { ErrorInvite } from './ErrorInvite';
import { useInvitePreview } from '../services';
Expand All @@ -8,6 +9,10 @@ export const InvitesPage = () => {
const { inviteId } = useParams({ strict: false }) as { inviteId: string };
const { data, error, isLoading } = useInvitePreview(inviteId);

useEffect(() => {
localStorage.removeItem('invite.pending_code');
}, []);

if (isLoading) {
return (
<section className="bg-gray-0 relative flex h-screen flex-col items-center justify-center">
Expand Down
12 changes: 10 additions & 2 deletions packages/pages.welcome/src/hooks/useWelcomeSocialsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ export const useWelcomeSocialsForm = () => {
// Небольшая задержка для обновления данных пользователя
await new Promise((resolve) => setTimeout(resolve, 100));

if (search.invite) {
const storedInviteId =
typeof window !== 'undefined' ? localStorage.getItem('invite.pending_code') : null;

const inviteId = storedInviteId || search.invite;

if (inviteId) {
if (storedInviteId) {
localStorage.removeItem('invite.pending_code');
}
navigate({
to: '/invite/$inviteId',
params: { inviteId: search.invite },
params: { inviteId },
});
} else {
navigate({
Expand Down
Loading