PWA Settings

Fixed webmanifest generation and pwa icon.

Made nav bar text optional.
This commit is contained in:
Stefan Lazic committed 2026-08-07 13:38:11 +01:00
1 parent a702320d4e
commit 769d3f9ebc
23 files changed
+1065 -91

No files matched your search

+71
View File
@@ -1,8 +1,10 @@
import { Prisma } from "@/generated/prisma/client";
import type { PrismaClient } from "@/generated/prisma/client";
import { Weekday } from "@/generated/prisma/enums";
import { calendarDateOf, minutesFromMidnight, weekdayOf } from "@/lib/time/business-time";
import { fail, ok } from "@/lib/validation-result";
import type { ValidationResult } from "@/lib/validation-result";
import type { SplashScreenEntry } from "@/lib/business/branding";
/**
* The business's own profile, address, policies, and opening hours —
@@ -141,6 +143,75 @@ export async function updateBusinessSettings(
return { success: true };
}
/**
* The subset of Business fields that actually drive "Add to Home Screen"
* — manifest short_name/theme_color/background_color/icons (see
* src/app/manifest.ts) and the iOS apple touch icon/splash screens (see
* layout.tsx) — split out from BusinessProfileInput/updateBusinessProfile
* so this one focused screen doesn't also have to carry a
* BusinessLocationInput through its save (that pair always transacts
* together for the main Business Details form, which this isn't part
* of). Restricted to Super Administrators only — see
* updateAppIconSettingsAction.
*/
export interface AppIconSettingsInput {
/** The name shown under the icon once installed — distinct from the full business `name` (manifest's short_name). */
shortName?: string | null;
/** Apple touch icon (iOS "Add to Home Screen") — distinct from the manifest icon fields below. */
appIconUrl?: string | null;
themeColor?: string | null;
backgroundColor?: string | null;
/** PWA manifest `icons` array (Android/Chrome) — see src/app/manifest.ts. */
icon192Url?: string | null;
icon512Url?: string | null;
maskableIcon192Url?: string | null;
maskableIcon512Url?: string | null;
/** iOS splash screens — see src/app/layout.tsx. Replaces the whole set on every save; there's no per-entry add/remove, only a wholesale re-import or clear. */
splashScreens?: SplashScreenEntry[] | null;
}
export async function updateAppIconSettings(
prisma: PrismaClient,
params: { businessId: string; settings: AppIconSettingsInput },
): Promise<{ success: boolean }> {
const { splashScreens, ...rest } = params.settings;
await prisma.business.update({
where: { id: params.businessId },
data: {
...rest,
...(splashScreens !== undefined && {
splashScreens:
splashScreens === null ? Prisma.JsonNull : (splashScreens as unknown as Prisma.InputJsonValue),
}),
},
});
return { success: true };
}
/**
* Business-wide app-display toggles that aren't PWA-icon-specific enough
* to belong in AppIconSettingsInput above, but are still Super
* Administrator only (same rendering-affects-everyone-instantly reason —
* see updateNavigationSettingsAction). Kept as its own input/function
* rather than folded into AppIconSettingsInput so that interface's own
* "drives Add to Home Screen" doc comment stays accurate.
*/
export interface NavigationSettingsInput {
/** Icon+label vs icon-only bottom navigation — see components/navigation/bottom-nav.tsx. */
bottomNavShowLabels: boolean;
}
export async function updateNavigationSettings(
prisma: PrismaClient,
params: { businessId: string; settings: NavigationSettingsInput },
): Promise<{ success: boolean }> {
await prisma.business.update({
where: { id: params.businessId },
data: { ...params.settings },
});
return { success: true };
}
// ── Opening hours ──────────────────────────────────────────────────────
export interface OpeningHoursDayInput {