feat(timeline): add pulse animation for in-flight drag mutations
Allocation bars that have active optimistic overrides (post-drag, awaiting server confirmation) now pulse subtly via animate-pulse. The pending set is derived from the existing optimisticAllocations map keys, requiring no additional state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
} from "@capakraken/shared";
|
||||
import { z } from "zod";
|
||||
import { findUniqueOrThrow } from "../db/helpers.js";
|
||||
import { createAuditEntry } from "../lib/audit.js";
|
||||
import { makeAuditLogger } from "../lib/audit-helpers.js";
|
||||
import type { TRPCContext } from "../trpc.js";
|
||||
import { asHolidayCalendarDb } from "./holiday-calendar-shared.js";
|
||||
import {
|
||||
@@ -26,10 +26,6 @@ import {
|
||||
|
||||
type HolidayCalendarProcedureContext = Pick<TRPCContext, "db" | "dbUser">;
|
||||
|
||||
function withAuditUser(userId: string | undefined) {
|
||||
return userId ? { userId } : {};
|
||||
}
|
||||
|
||||
export const holidayCalendarIdInputSchema = z.object({
|
||||
id: z.string(),
|
||||
});
|
||||
@@ -54,6 +50,7 @@ export async function createHolidayCalendar(
|
||||
ctx: HolidayCalendarProcedureContext,
|
||||
input: HolidayCalendarCreateInput,
|
||||
) {
|
||||
const audit = makeAuditLogger(ctx.db, ctx.dbUser?.id);
|
||||
const db = asHolidayCalendarDb(ctx.db);
|
||||
|
||||
await findUniqueOrThrow(
|
||||
@@ -83,15 +80,12 @@ export async function createHolidayCalendar(
|
||||
include: holidayCalendarDetailInclude,
|
||||
});
|
||||
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
audit({
|
||||
entityType: "HolidayCalendar",
|
||||
entityId: created.id,
|
||||
entityName: created.name,
|
||||
action: "CREATE",
|
||||
...withAuditUser(ctx.dbUser?.id),
|
||||
after: created as unknown as Record<string, unknown>,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return created;
|
||||
@@ -101,6 +95,7 @@ export async function updateHolidayCalendar(
|
||||
ctx: HolidayCalendarProcedureContext,
|
||||
input: HolidayCalendarUpdateInput,
|
||||
) {
|
||||
const audit = makeAuditLogger(ctx.db, ctx.dbUser?.id);
|
||||
const db = asHolidayCalendarDb(ctx.db);
|
||||
const existing = await findUniqueOrThrow<any>(
|
||||
db.holidayCalendar.findUnique({ where: { id: input.id } }),
|
||||
@@ -131,16 +126,13 @@ export async function updateHolidayCalendar(
|
||||
include: holidayCalendarDetailInclude,
|
||||
});
|
||||
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
audit({
|
||||
entityType: "HolidayCalendar",
|
||||
entityId: updated.id,
|
||||
entityName: updated.name,
|
||||
action: "UPDATE",
|
||||
...withAuditUser(ctx.dbUser?.id),
|
||||
before: existing as unknown as Record<string, unknown>,
|
||||
after: updated as unknown as Record<string, unknown>,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return updated;
|
||||
@@ -150,6 +142,7 @@ export async function deleteHolidayCalendar(
|
||||
ctx: HolidayCalendarProcedureContext,
|
||||
input: HolidayCalendarIdInput,
|
||||
) {
|
||||
const audit = makeAuditLogger(ctx.db, ctx.dbUser?.id);
|
||||
const db = asHolidayCalendarDb(ctx.db);
|
||||
const existing = await findUniqueOrThrow<any>(
|
||||
db.holidayCalendar.findUnique({
|
||||
@@ -161,15 +154,12 @@ export async function deleteHolidayCalendar(
|
||||
|
||||
await db.holidayCalendar.delete({ where: { id: input.id } });
|
||||
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
audit({
|
||||
entityType: "HolidayCalendar",
|
||||
entityId: existing.id,
|
||||
entityName: existing.name,
|
||||
action: "DELETE",
|
||||
...withAuditUser(ctx.dbUser?.id),
|
||||
before: existing as unknown as Record<string, unknown>,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return { success: true, id: existing.id, name: existing.name };
|
||||
@@ -179,6 +169,7 @@ export async function createHolidayCalendarEntry(
|
||||
ctx: HolidayCalendarProcedureContext,
|
||||
input: HolidayCalendarEntryCreateInput,
|
||||
) {
|
||||
const audit = makeAuditLogger(ctx.db, ctx.dbUser?.id);
|
||||
const db = asHolidayCalendarDb(ctx.db);
|
||||
|
||||
await findUniqueOrThrow(
|
||||
@@ -201,15 +192,12 @@ export async function createHolidayCalendarEntry(
|
||||
}),
|
||||
});
|
||||
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
audit({
|
||||
entityType: "HolidayCalendarEntry",
|
||||
entityId: created.id,
|
||||
entityName: created.name,
|
||||
action: "CREATE",
|
||||
...withAuditUser(ctx.dbUser?.id),
|
||||
after: created as unknown as Record<string, unknown>,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return created;
|
||||
@@ -219,6 +207,7 @@ export async function updateHolidayCalendarEntry(
|
||||
ctx: HolidayCalendarProcedureContext,
|
||||
input: HolidayCalendarEntryUpdateInput,
|
||||
) {
|
||||
const audit = makeAuditLogger(ctx.db, ctx.dbUser?.id);
|
||||
const db = asHolidayCalendarDb(ctx.db);
|
||||
const existing = await findUniqueOrThrow<any>(
|
||||
db.holidayCalendarEntry.findUnique({ where: { id: input.id } }),
|
||||
@@ -241,16 +230,13 @@ export async function updateHolidayCalendarEntry(
|
||||
}),
|
||||
});
|
||||
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
audit({
|
||||
entityType: "HolidayCalendarEntry",
|
||||
entityId: updated.id,
|
||||
entityName: updated.name,
|
||||
action: "UPDATE",
|
||||
...withAuditUser(ctx.dbUser?.id),
|
||||
before: existing as unknown as Record<string, unknown>,
|
||||
after: updated as unknown as Record<string, unknown>,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return updated;
|
||||
@@ -260,6 +246,7 @@ export async function deleteHolidayCalendarEntry(
|
||||
ctx: HolidayCalendarProcedureContext,
|
||||
input: HolidayCalendarIdInput,
|
||||
) {
|
||||
const audit = makeAuditLogger(ctx.db, ctx.dbUser?.id);
|
||||
const db = asHolidayCalendarDb(ctx.db);
|
||||
const existing = await findUniqueOrThrow<any>(
|
||||
db.holidayCalendarEntry.findUnique({ where: { id: input.id } }),
|
||||
@@ -268,15 +255,12 @@ export async function deleteHolidayCalendarEntry(
|
||||
|
||||
await db.holidayCalendarEntry.delete({ where: { id: input.id } });
|
||||
|
||||
void createAuditEntry({
|
||||
db: ctx.db,
|
||||
audit({
|
||||
entityType: "HolidayCalendarEntry",
|
||||
entityId: existing.id,
|
||||
entityName: existing.name,
|
||||
action: "DELETE",
|
||||
...withAuditUser(ctx.dbUser?.id),
|
||||
before: existing as unknown as Record<string, unknown>,
|
||||
source: "ui",
|
||||
});
|
||||
|
||||
return { success: true, id: existing.id, name: existing.name };
|
||||
|
||||
Reference in New Issue
Block a user