mirror of https://github.com/buster-so/buster.git
add better warning handler
This commit is contained in:
parent
e5ad359a36
commit
dbf1a6ef2f
|
@ -67,6 +67,13 @@ export const useIsUserRegistered = () => {
|
|||
const userBasicInfo = useGetUserBasicInfo();
|
||||
const isAnonymousUser = useIsAnonymousUser();
|
||||
const isUserRegistered = !!userOrganization?.id && !!userBasicInfo?.name && !isAnonymousUser;
|
||||
console.log(
|
||||
'isUserRegistered',
|
||||
userOrganization?.id,
|
||||
userBasicInfo?.name,
|
||||
isAnonymousUser,
|
||||
userBasicInfo
|
||||
);
|
||||
return isUserRegistered;
|
||||
};
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ const ContactAdminCard = ({ userRole }: ContactAdminCardProps) => {
|
|||
const roleLabel = userRole ? translateRole(userRole) : 'User';
|
||||
|
||||
return (
|
||||
<div className="flex flex-col rounded-xl border border-gray-200 bg-white p-6 shadow-sm">
|
||||
<div className="flex flex-col rounded border border-gray-200 bg-white p-6">
|
||||
<div className="mb-4 flex items-center justify-between">
|
||||
<Text className="text-xl font-medium text-gray-800">Contact Admin Required</Text>
|
||||
<div className="rounded-full bg-blue-100 px-3 py-1">
|
||||
|
|
|
@ -31,10 +31,6 @@ export const Route = createFileRoute('/app')({
|
|||
throw redirect({ href: BUSTER_SIGN_UP_URL, replace: true, statusCode: 307 });
|
||||
}
|
||||
|
||||
if (user && !user.user.name) {
|
||||
throw redirect({ to: '/app/new-user', replace: true, statusCode: 307 });
|
||||
}
|
||||
|
||||
return {
|
||||
supabaseSession,
|
||||
};
|
||||
|
|
|
@ -1,16 +1,24 @@
|
|||
import { createFileRoute, Outlet } from '@tanstack/react-router';
|
||||
import { createFileRoute, Outlet, redirect } from '@tanstack/react-router';
|
||||
import { prefetchListDatasources } from '@/api/buster_rest/data_source';
|
||||
import { prefetchGetDatasets } from '@/api/buster_rest/datasets';
|
||||
import { prefetchGetMyUserInfo } from '@/api/buster_rest/users';
|
||||
import { prefetchGetUserFavorites } from '@/api/buster_rest/users/favorites';
|
||||
import { getAppLayout } from '@/api/server-functions/getAppLayout';
|
||||
import type { LayoutSize } from '@/components/ui/layouts/AppLayout';
|
||||
import { PrimaryAppLayout } from '../../layouts/PrimaryAppLayout';
|
||||
import { Route as NewUserRoute } from './_app/new-user';
|
||||
|
||||
const PRIMARY_APP_LAYOUT_ID = 'primary-sidebar';
|
||||
const DEFAULT_LAYOUT: LayoutSize = ['230px', 'auto'];
|
||||
|
||||
export const Route = createFileRoute('/app/_app')({
|
||||
ssr: false,
|
||||
beforeLoad: async ({ context }) => {
|
||||
const user = await prefetchGetMyUserInfo(context.queryClient);
|
||||
if (user && !user?.user.name && location.pathname !== NewUserRoute.to) {
|
||||
throw redirect({ to: '/app/new-user', replace: true, reloadDocument: true, statusCode: 307 });
|
||||
}
|
||||
},
|
||||
loader: async ({ context }) => {
|
||||
const { queryClient } = context;
|
||||
const [initialLayout] = await Promise.all([
|
||||
|
|
Loading…
Reference in New Issue