ultisuite-client/lib/stores/mail-search-store.ts
R3D347HR4Y 6ec95262af Add OnlyOffice integration and update project configurations
- Updated .env.example to include configuration for OnlyOffice Document Server.
- Modified the workspace configuration to remove the drive-suite path.
- Adjusted TypeScript environment imports for consistency.
- Enhanced Next.js configuration to disable canvas in Webpack.
- Updated package.json to include new dependencies for OnlyOffice and PDF.js.
- Added global styles for OnlyOffice theme integration in the CSS.
- Created new layout and page components for the Drive feature, including public sharing and editing functionalities.
- Updated metadata handling across various layouts to reflect the new app structure.
2026-06-07 15:49:21 +02:00

82 lines
2.1 KiB
TypeScript

"use client"
import { create } from "zustand"
interface MailSearchState {
inputValue: string
dropdownOpen: boolean
selectedIndex: number
advancedOpen: boolean
/** Filter chips active in the dropdown (before submitting to URL). */
chipAttachment: boolean
chipLast7Days: boolean
chipFromMe: boolean
}
interface MailSearchActions {
setInputValue: (value: string) => void
setDropdownOpen: (open: boolean) => void
setSelectedIndex: (index: number) => void
setAdvancedOpen: (open: boolean) => void
toggleChipAttachment: () => void
toggleChipLast7Days: () => void
toggleChipFromMe: () => void
resetChips: () => void
syncChipsFromParams: (
params: { has?: string[]; within?: string; from?: string },
accountEmail?: string
) => void
reset: () => void
}
const INITIAL: MailSearchState = {
inputValue: "",
dropdownOpen: false,
selectedIndex: -1,
advancedOpen: false,
chipAttachment: false,
chipLast7Days: false,
chipFromMe: false,
}
export const useMailSearchStore = create<MailSearchState & MailSearchActions>()(
(set) => ({
...INITIAL,
setInputValue: (value) =>
set({ inputValue: value, dropdownOpen: value.length > 0, selectedIndex: -1 }),
setDropdownOpen: (open) => set({ dropdownOpen: open }),
setSelectedIndex: (index) => set({ selectedIndex: index }),
setAdvancedOpen: (open) =>
set({ advancedOpen: open, dropdownOpen: false }),
toggleChipAttachment: () =>
set((s) => ({ chipAttachment: !s.chipAttachment })),
toggleChipLast7Days: () =>
set((s) => ({ chipLast7Days: !s.chipLast7Days })),
toggleChipFromMe: () =>
set((s) => ({ chipFromMe: !s.chipFromMe })),
resetChips: () =>
set({ chipAttachment: false, chipLast7Days: false, chipFromMe: false }),
syncChipsFromParams: (params, accountEmail) =>
set({
chipAttachment: params.has?.includes("attachment") ?? false,
chipLast7Days: params.within === "1w",
chipFromMe: !!(
accountEmail &&
params.from &&
params.from.toLowerCase() === accountEmail.toLowerCase()
),
}),
reset: () => set(INITIAL),
})
)