mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-07-15 16:01:34 -05:00
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.
30 lines
996 B
TypeScript
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),
|
|
};
|
|
};
|