This commit is contained in:
David Nguyen
2025-01-31 23:17:50 +11:00
parent aec44b78d0
commit e20cb7e179
79 changed files with 3613 additions and 300 deletions

View File

@ -1,16 +1,16 @@
import { Trans } from '@lingui/macro';
import { BarChart3, FileStack, Settings, Trophy, Users, Wallet2 } from 'lucide-react';
import { Link, Outlet, redirect, useLocation } from 'react-router';
import { getRequiredSessionContext } from 'server/utils/get-required-session-context';
import { getSession } from '@documenso/auth/server/lib/utils/get-session';
import { isAdmin } from '@documenso/lib/next-auth/guards/is-admin';
import { cn } from '@documenso/ui/lib/utils';
import { Button } from '@documenso/ui/primitives/button';
import type { Route } from './+types/_layout';
export async function loader({ request }: Route.LoaderArgs) {
const { user } = await getSession(request);
export function loader({ context }: Route.LoaderArgs) {
const { user } = getRequiredSessionContext(context);
if (!user || !isAdmin(user)) {
return redirect('/documents');

View File

@ -2,7 +2,7 @@ import { Trans, msg } from '@lingui/macro';
import { useLingui } from '@lingui/react';
import { SigningStatus } from '@prisma/client';
import { DateTime } from 'luxon';
import { Link } from 'react-router';
import { Link, redirect } from 'react-router';
import { getEntireDocument } from '@documenso/lib/server-only/admin/get-entire-document';
import { trpc } from '@documenso/trpc/react';
@ -30,10 +30,13 @@ import type { Route } from './+types/documents.$id';
export async function loader({ params }: Route.LoaderArgs) {
const id = Number(params.id);
// Todo: Is it possible for this to return data to the frontend w/out auth layout due to race condition?
// Todo: Is it possible for this to return data to the frontend w/out auth layout due to race condition?
// Todo: Is it possible for this to return data to the frontend w/out auth layout due to race condition?
// if (isNaN(id)) {
// return redirect('/admin/documents');
// }
if (isNaN(id)) {
return redirect('/admin/documents');
}
const document = await getEntireDocument({ id });

View File

@ -29,6 +29,10 @@ import { SettingsHeader } from '~/components/(dashboard)/settings/layout/header'
import type { Route } from './+types/site-settings';
const ZBannerFormSchema = ZSiteSettingsBannerSchema;
type TBannerFormSchema = z.infer<typeof ZBannerFormSchema>;
export async function loader() {
const banner = await getSiteSettings().then((settings) =>
settings.find((setting) => setting.id === SITE_SETTINGS_BANNER_ID),
@ -37,10 +41,6 @@ export async function loader() {
return { banner };
}
const ZBannerFormSchema = ZSiteSettingsBannerSchema;
type TBannerFormSchema = z.infer<typeof ZBannerFormSchema>;
export default function AdminBannerPage({ loaderData }: Route.ComponentProps) {
const { banner } = loaderData;