fix admin ui strike submit
All checks were successful
deploy / build-and-deploy (/testvaro, /opt/website-test, website-test) (push) Successful in 23s
deploy / build-and-deploy (/varo, /opt/website, website) (push) Successful in 13s

This commit is contained in:
2025-06-21 22:08:44 +02:00
parent 94e9e83e93
commit 54a780d999
2 changed files with 12 additions and 7 deletions

View File

@ -154,7 +154,7 @@ export const report = {
}
});
if (input.status === 'closed' && preReportStrike?.strikeReasonId != input.strikeReasonId) {
if (input.status === 'closed' && preReportStrike?.strikeReason?.id != input.strikeReasonId) {
const report = await db.getReportById({ id: input.reportId });
if (report.reported) {
const strikes = await db.getStrikesByTeamId({ teamId: report.reported.id });

View File

@ -3,6 +3,7 @@ import { strikeReason } from '@db/schema/strikeReason.ts';
import type { MySql2Database } from 'drizzle-orm/mysql2';
import { eq } from 'drizzle-orm';
import { report } from '@db/schema/report.ts';
import { strikeReasons } from '@app/admin/strikeReasons/strikeReasons.ts';
type Database = MySql2Database<{ strike: typeof strike }>;
@ -47,12 +48,16 @@ export async function editStrike(db: Database, values: EditStrikeReq) {
}
export async function getStrikeByReportId(db: Database, values: GetStrikeByReportIdReq) {
return db.query.strike.findFirst({
with: {
strikeReason: true
},
where: eq(strike.reportId, values.reportId)
});
const strikes = await db
.select({
strike,
strikeReason
})
.from(strike)
.where(eq(strike.reportId, values.reportId))
.leftJoin(strikeReason, eq(strike.strikeReasonId, strikeReason.id));
return strikes[0] ?? null;
}
export async function getStrikesByTeamId(db: Database, values: GetStrikesByTeamIdReq) {