diff --git a/apps/start/src/routes/_app.tsx b/apps/start/src/routes/_app.tsx index 2c4139d7..678f1cea 100644 --- a/apps/start/src/routes/_app.tsx +++ b/apps/start/src/routes/_app.tsx @@ -1,14 +1,14 @@ +import { createFileRoute, Outlet, redirect } from '@tanstack/react-router'; +import { ConstructionIcon } from 'lucide-react'; import { FullPageEmptyState } from '@/components/full-page-empty-state'; import { Sidebar } from '@/components/sidebar'; -import { Button, LinkButton, buttonVariants } from '@/components/ui/button'; +import { buttonVariants } from '@/components/ui/button'; import { useAppContext } from '@/hooks/use-app-context'; import { cn } from '@/utils/cn'; -import { Outlet, createFileRoute, redirect } from '@tanstack/react-router'; -import { ConstructionIcon } from 'lucide-react'; export const Route = createFileRoute('/_app')({ beforeLoad: async ({ context }) => { - if (!context.session.session) { + if (!context.session?.session) { throw redirect({ to: '/login' }); } }, @@ -21,16 +21,16 @@ function AppLayout() { if (isMaintenance) { return ( Check out our status page @@ -41,9 +41,9 @@ function AppLayout() { return (
-
-
-
+
+
+
diff --git a/apps/start/src/routes/_login.tsx b/apps/start/src/routes/_login.tsx index e5add47a..f4fc47a1 100644 --- a/apps/start/src/routes/_login.tsx +++ b/apps/start/src/routes/_login.tsx @@ -1,11 +1,10 @@ +import { createFileRoute, Outlet, redirect } from '@tanstack/react-router'; import { LoginLeftPanel } from '@/components/login-left-panel'; import { LoginNavbar } from '@/components/login-navbar'; -import { SkeletonDashboard } from '@/components/skeleton-dashboard'; -import { Outlet, createFileRoute, redirect } from '@tanstack/react-router'; export const Route = createFileRoute('/_login')({ beforeLoad: async ({ context }) => { - if (context.session.session) { + if (context.session?.session) { throw redirect({ to: '/' }); } }, @@ -14,12 +13,12 @@ export const Route = createFileRoute('/_login')({ function AuthLayout() { return ( -
+
-
+
diff --git a/apps/start/src/routes/_public.onboarding.tsx b/apps/start/src/routes/_public.onboarding.tsx index 653d98bb..8fdfb54c 100644 --- a/apps/start/src/routes/_public.onboarding.tsx +++ b/apps/start/src/routes/_public.onboarding.tsx @@ -1,16 +1,15 @@ +import { useQuery } from '@tanstack/react-query'; +import { createFileRoute, redirect } from '@tanstack/react-router'; +import { MailIcon } from 'lucide-react'; +import { z } from 'zod'; import { Or } from '@/components/auth/or'; import { SignInGithub } from '@/components/auth/sign-in-github'; import { SignInGoogle } from '@/components/auth/sign-in-google'; import { SignUpEmailForm } from '@/components/auth/sign-up-email-form'; import FullPageLoadingState from '@/components/full-page-loading-state'; -import { LogoSquare } from '@/components/logo'; import { useTRPC } from '@/integrations/trpc/react'; -import { PAGE_TITLES, createEntityTitle } from '@/utils/title'; -import { useQuery } from '@tanstack/react-query'; -import { createFileRoute, redirect } from '@tanstack/react-router'; -import { motion } from 'framer-motion'; -import { MailIcon } from 'lucide-react'; -import { z } from 'zod'; +import { createEntityTitle, PAGE_TITLES } from '@/utils/title'; + const validateSearch = z.object({ inviteId: z.string().optional(), }); @@ -22,7 +21,7 @@ export const Route = createFileRoute('/_public/onboarding')({ ], }), beforeLoad: async ({ context }) => { - if (context.session.session) { + if (context.session?.session) { throw redirect({ to: '/' }); } }, @@ -34,7 +33,7 @@ export const Route = createFileRoute('/_public/onboarding')({ await context.queryClient.prefetchQuery( context.trpc.organization.getInvite.queryOptions({ inviteId: search.data.inviteId, - }), + }) ); } }, @@ -47,36 +46,36 @@ function Component() { const { data: invite } = useQuery( trpc.organization.getInvite.queryOptions( { - inviteId: inviteId, + inviteId, }, { enabled: !!inviteId, - }, - ), + } + ) ); return ( -
+
-

+

Create an account

Let's start with creating your account. By creating an account you accept the{' '} Terms of Service {' '} and{' '} Privacy Policy @@ -85,8 +84,8 @@ function Component() {

{invite && !invite.isExpired && ( -
-

+
+

Invitation to {invite.organization?.name}

@@ -96,8 +95,8 @@ function Component() {

)} {invite?.isExpired && ( -
-

+
+

Invitation to {invite.organization?.name} has expired

@@ -108,14 +107,14 @@ function Component() { )}

-
- - +
+ +
-
+
Sign up with email
diff --git a/apps/start/src/routes/_steps.onboarding.$projectId.connect.tsx b/apps/start/src/routes/_steps.onboarding.$projectId.connect.tsx index 9ab2dace..1c9803e8 100644 --- a/apps/start/src/routes/_steps.onboarding.$projectId.connect.tsx +++ b/apps/start/src/routes/_steps.onboarding.$projectId.connect.tsx @@ -1,3 +1,6 @@ +import { useQuery } from '@tanstack/react-query'; +import { createFileRoute, redirect } from '@tanstack/react-router'; +import { LockIcon, XIcon } from 'lucide-react'; import { ButtonContainer } from '@/components/button-container'; import CopyInput from '@/components/forms/copy-input'; import { FullPageEmptyState } from '@/components/full-page-empty-state'; @@ -8,10 +11,7 @@ import ConnectWeb from '@/components/onboarding/connect-web'; import { LinkButton } from '@/components/ui/button'; import { useClientSecret } from '@/hooks/use-client-secret'; import { useTRPC } from '@/integrations/trpc/react'; -import { PAGE_TITLES, createEntityTitle } from '@/utils/title'; -import { useQuery } from '@tanstack/react-query'; -import { createFileRoute, redirect } from '@tanstack/react-router'; -import { LockIcon, XIcon } from 'lucide-react'; +import { createEntityTitle, PAGE_TITLES } from '@/utils/title'; export const Route = createFileRoute('/_steps/onboarding/$projectId/connect')({ head: () => ({ @@ -20,7 +20,7 @@ export const Route = createFileRoute('/_steps/onboarding/$projectId/connect')({ ], }), beforeLoad: async ({ context }) => { - if (!context.session.session) { + if (!context.session?.session) { throw redirect({ to: '/onboarding' }); } }, @@ -29,7 +29,7 @@ export const Route = createFileRoute('/_steps/onboarding/$projectId/connect')({ await context.queryClient.prefetchQuery( context.trpc.project.getProjectWithClients.queryOptions({ projectId: params.projectId, - }), + }) ); }, pendingComponent: FullPageLoadingState, @@ -39,7 +39,7 @@ function Component() { const { projectId } = Route.useParams(); const trpc = useTRPC(); const { data: project } = useQuery( - trpc.project.getProjectWithClients.queryOptions({ projectId }), + trpc.project.getProjectWithClients.queryOptions({ projectId }) ); const client = project?.clients[0]; const [secret] = useClientSecret(); @@ -47,24 +47,24 @@ function Component() { if (!client) { return ( ); } return ( -
+
-
+
Credentials
-
+
{project?.types?.map((type) => { const Component = { website: ConnectWeb, @@ -72,15 +72,15 @@ function Component() { backend: ConnectBackend, }[type]; - return ; + return ; })}
Next diff --git a/apps/start/src/routes/_steps.onboarding.$projectId.verify.tsx b/apps/start/src/routes/_steps.onboarding.$projectId.verify.tsx index 8f87c997..f6669576 100644 --- a/apps/start/src/routes/_steps.onboarding.$projectId.verify.tsx +++ b/apps/start/src/routes/_steps.onboarding.$projectId.verify.tsx @@ -1,3 +1,7 @@ +import { useQuery } from '@tanstack/react-query'; +import { createFileRoute, Link, redirect } from '@tanstack/react-router'; +import { BoxSelectIcon } from 'lucide-react'; +import { useEffect, useState } from 'react'; import { ButtonContainer } from '@/components/button-container'; import { FullPageEmptyState } from '@/components/full-page-empty-state'; import FullPageLoadingState from '@/components/full-page-loading-state'; @@ -6,18 +10,14 @@ import VerifyListener from '@/components/onboarding/onboarding-verify-listener'; import { LinkButton } from '@/components/ui/button'; import { useTRPC } from '@/integrations/trpc/react'; import { cn } from '@/lib/utils'; -import { PAGE_TITLES, createEntityTitle } from '@/utils/title'; -import { useQuery } from '@tanstack/react-query'; -import { Link, createFileRoute, redirect } from '@tanstack/react-router'; -import { BoxSelectIcon } from 'lucide-react'; -import { useEffect, useState } from 'react'; +import { createEntityTitle, PAGE_TITLES } from '@/utils/title'; export const Route = createFileRoute('/_steps/onboarding/$projectId/verify')({ head: () => ({ meta: [{ title: createEntityTitle('Verify', PAGE_TITLES.ONBOARDING) }], }), beforeLoad: async ({ context }) => { - if (!context.session.session) { + if (!context.session?.session) { throw redirect({ to: '/onboarding' }); } }, @@ -26,7 +26,7 @@ export const Route = createFileRoute('/_steps/onboarding/$projectId/verify')({ await context.queryClient.prefetchQuery( context.trpc.project.getProjectWithClients.queryOptions({ projectId: params.projectId, - }), + }) ); }, pendingComponent: FullPageLoadingState, @@ -37,10 +37,10 @@ function Component() { const { projectId } = Route.useParams(); const trpc = useTRPC(); const { data: events, refetch } = useQuery( - trpc.event.events.queryOptions({ projectId }), + trpc.event.events.queryOptions({ projectId }) ); const { data: project } = useQuery( - trpc.project.getProjectWithClients.queryOptions({ projectId }), + trpc.project.getProjectWithClients.queryOptions({ projectId }) ); useEffect(() => { @@ -51,34 +51,34 @@ function Component() { if (!project) { return ( - + ); } const client = project.clients[0]; if (!client) { - return ; + return ; } return ( -
+
{ refetch(); setIsVerified(true); }} + project={project} /> Back @@ -87,28 +87,28 @@ function Component() {
{!isVerified && ( Skip for now )} Your dashboard diff --git a/apps/start/src/routes/_steps.onboarding.project.tsx b/apps/start/src/routes/_steps.onboarding.project.tsx index 94044da7..1e223c39 100644 --- a/apps/start/src/routes/_steps.onboarding.project.tsx +++ b/apps/start/src/routes/_steps.onboarding.project.tsx @@ -1,14 +1,3 @@ -import AnimateHeight from '@/components/animate-height'; -import { ButtonContainer } from '@/components/button-container'; -import { CheckboxItem } from '@/components/forms/checkbox-item'; -import { InputWithLabel, WithLabel } from '@/components/forms/input-with-label'; -import TagInput from '@/components/forms/tag-input'; -import FullPageLoadingState from '@/components/full-page-loading-state'; -import { Button } from '@/components/ui/button'; -import { Combobox } from '@/components/ui/combobox'; -import { Label } from '@/components/ui/label'; -import { useClientSecret } from '@/hooks/use-client-secret'; -import { handleError, useTRPC } from '@/integrations/trpc/react'; import { zodResolver } from '@hookform/resolvers/zod'; import { zOnboardingProject } from '@openpanel/validation'; import { useMutation, useQuery } from '@tanstack/react-query'; @@ -27,6 +16,17 @@ import { useWatch, } from 'react-hook-form'; import { z } from 'zod'; +import AnimateHeight from '@/components/animate-height'; +import { ButtonContainer } from '@/components/button-container'; +import { CheckboxItem } from '@/components/forms/checkbox-item'; +import { InputWithLabel, WithLabel } from '@/components/forms/input-with-label'; +import TagInput from '@/components/forms/tag-input'; +import FullPageLoadingState from '@/components/full-page-loading-state'; +import { Button } from '@/components/ui/button'; +import { Combobox } from '@/components/ui/combobox'; +import { Label } from '@/components/ui/label'; +import { useClientSecret } from '@/hooks/use-client-secret'; +import { handleError, useTRPC } from '@/integrations/trpc/react'; const validateSearch = z.object({ inviteId: z.string().optional(), @@ -35,7 +35,7 @@ export const Route = createFileRoute('/_steps/onboarding/project')({ component: Component, validateSearch, beforeLoad: async ({ context }) => { - if (!context.session.session) { + if (!context.session?.session) { throw redirect({ to: '/onboarding' }); } }, @@ -45,7 +45,7 @@ export const Route = createFileRoute('/_steps/onboarding/project')({ await context.queryClient.prefetchQuery( context.trpc.organization.getInvite.queryOptions({ inviteId: search.data.inviteId, - }), + }) ); } }, @@ -57,7 +57,7 @@ type IForm = z.infer; function Component() { const trpc = useTRPC(); const { data: organizations } = useQuery( - trpc.organization.list.queryOptions(undefined, { initialData: [] }), + trpc.organization.list.queryOptions(undefined, { initialData: [] }) ); const [, setSecret] = useClientSecret(); const navigate = useNavigate(); @@ -73,7 +73,7 @@ function Component() { }, }); }, - }), + }) ); const form = useForm({ @@ -134,10 +134,8 @@ function Component() { item.id) @@ -147,6 +145,8 @@ function Component() { })) ?? [] } onChange={field.onChange} + placeholder="Select workspace" + value={field.value} />
); @@ -155,26 +155,26 @@ function Component() { ) : ( <> ( ({ value: item, label: item, }))} - value={field.value} onChange={field.onChange} - className="w-full" + placeholder="Select timezone" + value={field.value} /> )} @@ -182,24 +182,24 @@ function Component() { )}
-
+
( @@ -223,20 +223,13 @@ function Component() { /> ( - tag === '*' - ? 'Accept events from any domains' - : tag - } onChange={(newValue) => { field.onChange( newValue.map((item) => { @@ -249,9 +242,16 @@ function Component() { return trimmed; } return `https://${trimmed}`; - }), + }) ); }} + placeholder="Accept events from these domains" + renderTag={(tag) => + tag === '*' + ? 'Accept events from any domains' + : tag + } + value={field.value ?? []} /> )} @@ -262,28 +262,28 @@ function Component() { )} /> ( )} /> ( )} @@ -291,13 +291,13 @@ function Component() {
- +
diff --git a/apps/start/src/routes/index.tsx b/apps/start/src/routes/index.tsx index e040477f..8f5c8a3d 100644 --- a/apps/start/src/routes/index.tsx +++ b/apps/start/src/routes/index.tsx @@ -11,7 +11,7 @@ import { createTitle } from '@/utils/title'; export const Route = createFileRoute('/')({ beforeLoad: ({ context }) => { - if (!context.session.session) { + if (!context.session?.session) { throw redirect({ to: '/login' }); } }, diff --git a/packages/auth/src/cookie.ts b/packages/auth/src/cookie.ts index dcbf4a68..09fab968 100644 --- a/packages/auth/src/cookie.ts +++ b/packages/auth/src/cookie.ts @@ -4,10 +4,10 @@ import { COOKIE_OPTIONS } from '../constants'; export function setSessionTokenCookie( setCookie: ISetCookie, token: string, - expiresAt: Date, + expiresAt: Date ): void { setCookie('session', token, { - maxAge: expiresAt.getTime() - new Date().getTime(), + maxAge: Math.floor((expiresAt.getTime() - new Date().getTime()) / 1000), ...COOKIE_OPTIONS, }); }