f8947c0bc7
DB - Added user pref columns; vibration is per-channel (vibrationEnabledOrder + vibrationEnabledMeeting). Defaults: ding/chime sounds, vibration on, mute off. Volume uses the device system level — no persisted volume field. API - PATCH /auth/me/notification-preferences (requireAuth, whitelisted partial update, integer guard for volume). buildAuthUser exposes all new fields. - OpenAPI spec updated; orval client + zod regenerated. Frontend - Static sound library: 8 short WAV assets under public/sounds/ + manifest (notification-sound-manifest.ts) mapping id -> labelKey -> URL. - HTMLAudio-based player (notification-sounds.ts) with throttle, unlock, cache, and AUTOPLAY_BLOCKED_EVENT dispatch when play is denied pre-gesture. - Settings popover: global mute + slot tabs (orders/meetings) with per-channel sound + per-channel vibration + per-channel toggle, sound list with one-tap previews. Concurrency-safe optimistic updates (monotonic seq counter). RTL-correct toggle knob transforms. - QuickMuteButton: one-tap topbar mute control (Volume2/VolumeX) with confirmation toast. - useAudioUnlock: unlocks audio on first interaction. - useAutoplayHint: toasts a localized "click anywhere to enable" hint when the player reports a blocked play attempt. - Socket hook plays the right per-channel sound + vibration on notification_created (orders, executive_meeting) when the tab is hidden. - UpcomingMeetingAlert: plays meeting reminder once per new eligible meeting (deduped by meetingId, survives 30s polling refetches). Skipped when the tab is currently visible — sound only fires when backgrounded. - AR/EN translations added. Pre-existing TS errors in executive-meetings.ts (font_settings) and pre-existing test workflow failures are unrelated.
31 lines
1.9 KiB
TypeScript
31 lines
1.9 KiB
TypeScript
import { pgTable, text, serial, timestamp, varchar, boolean, integer } from "drizzle-orm/pg-core";
|
|
import { createInsertSchema } from "drizzle-zod";
|
|
import { z } from "zod/v4";
|
|
|
|
export const usersTable = pgTable("users", {
|
|
id: serial("id").primaryKey(),
|
|
username: varchar("username", { length: 100 }).notNull().unique(),
|
|
email: varchar("email", { length: 255 }).notNull().unique(),
|
|
passwordHash: text("password_hash").notNull(),
|
|
displayNameAr: varchar("display_name_ar", { length: 200 }),
|
|
displayNameEn: varchar("display_name_en", { length: 200 }),
|
|
preferredLanguage: varchar("preferred_language", { length: 10 }).notNull().default("ar"),
|
|
clockStyle: varchar("clock_style", { length: 30 }),
|
|
clockHour12: boolean("clock_hour12"),
|
|
avatarUrl: text("avatar_url"),
|
|
isActive: boolean("is_active").notNull().default(true),
|
|
notificationSoundOrder: varchar("notification_sound_order", { length: 30 }).notNull().default("ding"),
|
|
notificationSoundMeeting: varchar("notification_sound_meeting", { length: 30 }).notNull().default("chime"),
|
|
notifyOrdersEnabled: boolean("notify_orders_enabled").notNull().default(true),
|
|
notifyMeetingsEnabled: boolean("notify_meetings_enabled").notNull().default(true),
|
|
vibrationEnabledOrder: boolean("vibration_enabled_order").notNull().default(true),
|
|
vibrationEnabledMeeting: boolean("vibration_enabled_meeting").notNull().default(true),
|
|
notificationsMuted: boolean("notifications_muted").notNull().default(false),
|
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow().$onUpdate(() => new Date()),
|
|
});
|
|
|
|
export const insertUserSchema = createInsertSchema(usersTable).omit({ id: true, createdAt: true, updatedAt: true });
|
|
export type InsertUser = z.infer<typeof insertUserSchema>;
|
|
export type User = typeof usersTable.$inferSelect;
|