sendou.ink/app/features/user-page/loaders/u.$identifier.server.ts
Kalle 77978c450f
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
New user page (#2812)
Co-authored-by: hfcRed <hfcred@gmx.net>
2026-02-16 19:26:57 +02:00

32 lines
845 B
TypeScript

import type { LoaderFunctionArgs } from "react-router";
import { getUser } from "~/features/auth/core/user.server";
import * as UserRepository from "~/features/user-page/UserRepository.server";
import type { SerializeFrom } from "~/utils/remix";
import { notFoundIfFalsy } from "~/utils/remix.server";
export type UserPageLoaderData = SerializeFrom<typeof loader>;
export const loader = async ({ params }: LoaderFunctionArgs) => {
const loggedInUser = getUser();
const user = notFoundIfFalsy(
await UserRepository.findLayoutDataByIdentifier(
params.identifier!,
loggedInUser?.id,
),
);
const widgetsEnabled = await UserRepository.widgetsEnabledByIdentifier(
params.identifier!,
);
return {
user: {
...user,
css: undefined,
},
css: user.css,
type: widgetsEnabled ? ("new" as const) : ("old" as const),
};
};