add report draft editing warn popup
All checks were successful
deploy / build-and-deploy (push) Successful in 30s
All checks were successful
deploy / build-and-deploy (push) Successful in 30s
This commit is contained in:
@@ -197,12 +197,13 @@ export const report = {
|
||||
if (input.status === 'closed') preReportStrike = await db.getStrikeByReportId({ reportId: input.reportId });
|
||||
|
||||
await db.transaction(async (tx) => {
|
||||
if (reportCreatedAt) await tx.editReport({ id: input.reportId, createdAt: reportCreatedAt });
|
||||
|
||||
await tx.editReportStatus(input);
|
||||
|
||||
if (input.strikeReasonId) {
|
||||
await db.editStrike({
|
||||
reportId: input.reportId,
|
||||
at: reportCreatedAt,
|
||||
strikeReasonId: input.strikeReasonId
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -59,9 +59,15 @@
|
||||
|
||||
// callbacks
|
||||
async function onSaveButtonClick() {
|
||||
let popupMessage;
|
||||
if (report!.createdAt) popupMessage = 'Sollen die Änderungen am Report gespeichert werden?';
|
||||
else
|
||||
popupMessage = `Der Report ist aktuell noch ein Entwurf. Mit den Änderungen wird der Report kein Entwurf mehr sein, und der Ersteller kann ihn nicht mehr bearbeiten.\n
|
||||
Sollen die Änderungen am Report trotzdem gespeichert werden?`;
|
||||
|
||||
$confirmPopupState = {
|
||||
title: 'Änderungen speichern?',
|
||||
message: 'Sollen die Änderungen am Report gespeichert werden?',
|
||||
message: popupMessage,
|
||||
onConfirm: async () => {
|
||||
if (reportedUser?.id != report?.reported?.id) {
|
||||
report!.reported = reportedUser;
|
||||
|
||||
@@ -30,7 +30,8 @@ export type AddReportReq = {
|
||||
|
||||
export type EditReportReq = {
|
||||
id: number;
|
||||
reportedId: number | null;
|
||||
reportedId?: number | null;
|
||||
createdAt?: Date | null;
|
||||
};
|
||||
|
||||
export type SubmitReportReq = {
|
||||
@@ -76,7 +77,8 @@ export async function editReport(db: Database, values: EditReportReq) {
|
||||
return db
|
||||
.update(report)
|
||||
.set({
|
||||
reportedId: values.reportedId
|
||||
reportedId: values.reportedId,
|
||||
createdAt: values.createdAt ?? undefined
|
||||
})
|
||||
.where(eq(report.id, values.id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user