Skip to content

Commit

Permalink
feat(admin): allow auto arrange only when submittion is closed
Browse files Browse the repository at this point in the history
Signed-off-by: ZTL-UwU <zhangtianli2006@163.com>
  • Loading branch information
ZTL-UwU committed Dec 19, 2024
1 parent 4ed5459 commit 38ce1c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/pages/admin/arrange.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ const { data: reviewAll, suspense: reviewAllSuspense } = useQuery({
});
await reviewAllSuspense();
const { data: timeCurrently, suspense: timeSuspense } = useQuery({
queryFn: () => $trpc.time.currently.query(),
queryKey: ['time.currently'],
});
await timeSuspense();
const { copy: useCopy } = useClipboard({ legacy: true });
async function copySongInfo(day: RouterOutput['arrangements']['list'][0]) {
if (!day.songs.length) {
Expand Down Expand Up @@ -143,6 +149,10 @@ const requirementList = computed<{
label: '审核全部歌曲',
value: reviewAll.value ?? true,
},
{
label: '投稿截止',
value: timeCurrently.value ?? true,
},
];
});
Expand Down
4 changes: 4 additions & 0 deletions server/trpc/routers/arrangements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { arrangements, songs } from '~~/server/db/schema';
import { desc, eq, sql } from 'drizzle-orm';
import { z } from 'zod';
import { adminProcedure, protectedProcedure, requirePermission, router } from '../trpc';
import { fitsInTime } from './time';

async function reviewAll() {
return (await db.query.songs.findMany({
Expand Down Expand Up @@ -79,6 +80,9 @@ export const arrangementsRouter = router({
if (!(await reviewAll()))
throw new TRPCError({ code: 'FORBIDDEN', message: '请审核全部歌曲' });

if (!(await fitsInTime(new Date())))
throw new TRPCError({ code: 'FORBIDDEN', message: '请在投稿截止后排歌' });

const start = parseDate(input.start);
const end = parseDate(input.end);

Expand Down

0 comments on commit 38ce1c0

Please sign in to comment.