mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-02 11:16:24 -05:00
28 lines
675 B
TypeScript
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,
|
|
};
|
|
};
|