sendou.ink/app/features/user-page/loaders/u.$identifier.index.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

28 lines
675 B
TypeScript

import type { LoaderFunctionArgs } from "react-router";
import * as UserRepository from "~/features/user-page/UserRepository.server";
import { notFoundIfFalsy } from "~/utils/remix.server";
export const loader = async ({ params }: LoaderFunctionArgs) => {
const widgetsEnabled = await UserRepository.widgetsEnabledByIdentifier(
params.identifier!,
);
if (widgetsEnabled) {
return {
type: "new" as const,
widgets: notFoundIfFalsy(
await UserRepository.widgetsByUserId(params.identifier!),
),
};
}
const user = notFoundIfFalsy(
await UserRepository.findProfileByIdentifier(params.identifier!),
);
return {
type: "old" as const,
user,
};
};