Some checks are pending
E2E / Playwright e2e (push) Waiting to run
- Introduced turbopack alias for canvas in next.config.mjs. - Updated package.json scripts for development and branding tasks. - Added new dependencies for Tiptap extensions. - Implemented new demo layouts for agenda, contacts, drive, and mail applications. - Enhanced globals.css for improved theming and splash screen animations. - Added OAuth callback handling for drive mounts. - Updated layout components to integrate new demo shells and improve structure.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import {
|
|
buildSearchUrl,
|
|
type SearchParams,
|
|
} from "@/lib/mail-search/search-params"
|
|
|
|
export type MailSearchRouter = {
|
|
push: (url: string, options?: { scroll?: boolean }) => void
|
|
}
|
|
|
|
export type QuickSearchChipState = {
|
|
chipAttachment?: boolean
|
|
chipLast7Days?: boolean
|
|
chipFromMe?: boolean
|
|
fromEmail?: string
|
|
}
|
|
|
|
/** Build params from bar/overlay quick search + filter chips. */
|
|
export function buildQuickSearchParams(
|
|
query: string,
|
|
chips: QuickSearchChipState = {}
|
|
): Partial<SearchParams> {
|
|
const q = query.trim()
|
|
if (!q && !chips.chipAttachment && !chips.chipLast7Days && !chips.chipFromMe) {
|
|
return {}
|
|
}
|
|
const params: Partial<SearchParams> = { q }
|
|
if (chips.chipAttachment) params.has = ["attachment"]
|
|
if (chips.chipLast7Days) params.within = "1w"
|
|
if (chips.chipFromMe && chips.fromEmail) params.from = chips.fromEmail
|
|
return params
|
|
}
|
|
|
|
/** Navigate to `/mail/search` with encoded query params. */
|
|
export function submitMailSearch(
|
|
router: MailSearchRouter,
|
|
params: Partial<SearchParams>,
|
|
options?: { scroll?: boolean; onAfter?: () => void; routeRoot?: string }
|
|
): void {
|
|
router.push(buildSearchUrl(params, options?.routeRoot), {
|
|
scroll: options?.scroll ?? false,
|
|
})
|
|
options?.onAfter?.()
|
|
}
|