sendou.ink/app/features/team/loaders/t.$customUrl.edit.server.ts
Kalle 739e6f440b Add moderation note and autoValidate to image form field
Show a note under non-autoValidate image fields that uploads are
moderated before going public. Move autoValidate to a per-field schema
property (org logo only) driving both the action logic and the note.
Preview pending images on the team edit page while keeping them hidden
on the public page.
2026-06-06 10:56:52 +03:00

30 lines
996 B
TypeScript

import type { LoaderFunctionArgs } from "react-router";
import { redirect } from "react-router";
import { requireUser } from "~/features/auth/core/user.server";
import { notFoundIfFalsy } from "~/utils/remix.server";
import { teamPage } from "~/utils/urls";
import * as TeamRepository from "../TeamRepository.server";
import { teamParamsSchema } from "../team-schemas.server";
import { canAddCustomizedColors, isTeamManager } from "../team-utils";
export const loader = async ({ params }: LoaderFunctionArgs) => {
const user = requireUser();
const { customUrl } = teamParamsSchema.parse(params);
const team = notFoundIfFalsy(
await TeamRepository.findByCustomUrl(customUrl, {
includeUnvalidatedImages: true,
}),
);
if (!isTeamManager({ team, user }) && !user.roles.includes("ADMIN")) {
throw redirect(teamPage(customUrl));
}
return {
team,
customTheme: canAddCustomizedColors(team) ? team.customTheme : null,
canAddCustomizedColors: canAddCustomizedColors(team),
};
};