feat: 예약 명령 처리 로직 개선 및 완료 콜백 추가

This commit is contained in:
2026-08-28 15:55:39 +00:00
parent e6873f813a
commit fa9fe71539
7 changed files with 58 additions and 34 deletions
@@ -11,6 +11,8 @@ import { formatOfficerLevelText } from '../utils/nationFormat';
import { formatReservedCommandBrief } from '../components/command/reservedCommandBrief';
import type { CommandMapData, CommandMapLayout, CommandPatternEntry, CommandTable } from '../components/command/types';
type ReservationCompletion = (success: boolean) => void;
type ChiefTurn = {
index: number;
action: string;
@@ -284,8 +286,11 @@ const shiftTurns = async (amount: number) => {
}
};
const reserveTurns = async (entries: CommandPatternEntry[]) => {
if (!data.value || !isEditingAllowed.value) return;
const reserveTurns = async (entries: CommandPatternEntry[], complete?: ReservationCompletion) => {
if (!data.value || !isEditingAllowed.value) {
complete?.(false);
return;
}
try {
const result = await trpc.turns.reserved.setNationBulk.mutate({
generalId: data.value.me.id,
@@ -293,9 +298,11 @@ const reserveTurns = async (entries: CommandPatternEntry[]) => {
expectedRevision: selectedChief.value?.revision ?? 0,
});
updateMyTurns(result.turns, result.revision);
complete?.(true);
} catch (err) {
await loadChiefCenter();
error.value = resolveErrorMessage(err);
complete?.(false);
}
};
+6 -2
View File
@@ -183,8 +183,12 @@ const shiftGeneralTurns = (amount: number) => {
void dashboard.shiftGeneralTurns(amount);
};
const reserveGeneralTurns = (entries: CommandPatternEntry[]) => {
void dashboard.setGeneralTurns(entries);
const reserveGeneralTurns = async (
entries: CommandPatternEntry[],
complete?: (success: boolean) => void
) => {
const success = await dashboard.setGeneralTurns(entries);
complete?.(success);
};
const repeatGeneralTurns = (amount: number) => {