mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-02 19:26:50 -05:00
26 lines
675 B
TypeScript
26 lines
675 B
TypeScript
import type { LoaderFunctionArgs, SerializeFrom } from "@remix-run/node";
|
|
import { getUserId } from "~/features/auth/core/user.server";
|
|
import * as UserRepository from "~/features/user-page/UserRepository.server";
|
|
import { notFoundIfFalsy } from "~/utils/remix.server";
|
|
|
|
export type UserPageLoaderData = SerializeFrom<typeof loader>;
|
|
|
|
export const loader = async ({ params, request }: LoaderFunctionArgs) => {
|
|
const loggedInUser = await getUserId(request);
|
|
|
|
const user = notFoundIfFalsy(
|
|
await UserRepository.findLayoutDataByIdentifier(
|
|
params.identifier!,
|
|
loggedInUser?.id,
|
|
),
|
|
);
|
|
|
|
return {
|
|
user: {
|
|
...user,
|
|
css: undefined,
|
|
},
|
|
css: user.css,
|
|
};
|
|
};
|