- pipeline funnel: count active interests by current stage (drop created_at window) — backfill had collapsed it to early stages (UAT 2026-06-03) - pipeline value tile: render current-state (don't thread the date range) - deal pulse chip: gate on the pulse_enabled master toggle (default ON) — was rendering even when admin turned it off; useFeatureFlag gains a default arg + the feature-flag endpoint a ?default= param (default-ON safe) - contact phone display: show international format + country flag (E164), not the bare national format that hid the country - berths: remove the dead row-density toggle; widen "Under offer to" chip on desktop so client names aren't truncated Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { and, eq } from 'drizzle-orm';
|
|
|
|
import { withAuth } from '@/lib/api/helpers';
|
|
import { db } from '@/lib/db';
|
|
import { systemSettings } from '@/lib/db/schema/system';
|
|
import { errorResponse, ValidationError } from '@/lib/errors';
|
|
|
|
export const GET = withAuth(async (req, ctx) => {
|
|
try {
|
|
const key = req.nextUrl.searchParams.get('key');
|
|
if (!key) throw new ValidationError('key query parameter is required');
|
|
|
|
const setting = await db.query.systemSettings.findFirst({
|
|
where: and(eq(systemSettings.key, key), eq(systemSettings.portId, ctx.portId)),
|
|
});
|
|
|
|
// `default` applies ONLY when the setting was never written for this
|
|
// port (row absent). An explicit stored `false` always disables. Lets
|
|
// default-ON settings (e.g. pulse_enabled) gate correctly via
|
|
// ?default=true while default-OFF flags keep the old behaviour.
|
|
const def = req.nextUrl.searchParams.get('default') === 'true';
|
|
const enabled = setting ? setting.value === true : def;
|
|
return NextResponse.json({ enabled });
|
|
} catch (error) {
|
|
return errorResponse(error);
|
|
}
|
|
});
|