import React from 'react'; import { getAssetCheck } from '@/api/buster_rest/assets/requests'; import { useSupabaseServerContext } from '@/context/Supabase/useSupabaseContext'; import { ShareAssetType } from '@/api/asset_interfaces'; import { ClientSideAnonCheck } from './ClientSideAnonCheck'; import { redirect } from 'next/navigation'; import { BusterRoutes, createBusterRoute } from '@/routes'; import { AppPasswordAccess } from '@controllers/AppPasswordAccess'; import { AppNoPageAccess } from '@controllers/AppNoPageAccess'; import { signInWithAnonymousUser } from '@/server_context/supabaseAuthMethods'; export type AppAssetCheckLayoutProps = { metricId?: string; dashboardId?: string; type: 'metric' | 'dashboard'; }; export const AppAssetCheckLayout: React.FC< { children: React.ReactNode; } & AppAssetCheckLayoutProps > = async ({ children, type, ...props }) => { const { accessToken, user } = await useSupabaseServerContext(); const isMetric = type === 'metric'; let jwtToken = accessToken; if (!user || !accessToken) { const { session } = await signInWithAnonymousUser(); jwtToken = session?.access_token! || accessToken; } if (!jwtToken) { return