feat(ui) : add DTOs and services for calendar fields, recurrence, and Zimbra settings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
22
frontend/services/dto/task-recurrence.ts
Normal file
22
frontend/services/dto/task-recurrence.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
export type TaskRecurrence = {
|
||||||
|
id: number
|
||||||
|
'@id'?: string
|
||||||
|
type: 'daily' | 'weekly' | 'monthly' | 'yearly'
|
||||||
|
interval: number
|
||||||
|
daysOfWeek: string[] | null
|
||||||
|
dayOfMonth: number | null
|
||||||
|
weekOfMonth: number | null
|
||||||
|
endDate: string | null
|
||||||
|
maxOccurrences: number | null
|
||||||
|
occurrenceCount: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TaskRecurrenceWrite = {
|
||||||
|
type: 'daily' | 'weekly' | 'monthly' | 'yearly'
|
||||||
|
interval: number
|
||||||
|
daysOfWeek?: string[] | null
|
||||||
|
dayOfMonth?: number | null
|
||||||
|
weekOfMonth?: number | null
|
||||||
|
endDate?: string | null
|
||||||
|
maxOccurrences?: number | null
|
||||||
|
}
|
||||||
@@ -29,6 +29,23 @@ export type Task = {
|
|||||||
status: string
|
status: string
|
||||||
title: string
|
title: string
|
||||||
} | null
|
} | null
|
||||||
|
scheduledStart: string | null
|
||||||
|
scheduledEnd: string | null
|
||||||
|
deadline: string | null
|
||||||
|
syncToCalendar: boolean
|
||||||
|
calendarSyncError: string | null
|
||||||
|
recurrence: {
|
||||||
|
id: number
|
||||||
|
'@id'?: string
|
||||||
|
type: 'daily' | 'weekly' | 'monthly' | 'yearly'
|
||||||
|
interval: number
|
||||||
|
daysOfWeek: string[] | null
|
||||||
|
dayOfMonth: number | null
|
||||||
|
weekOfMonth: number | null
|
||||||
|
endDate: string | null
|
||||||
|
maxOccurrences: number | null
|
||||||
|
occurrenceCount: number
|
||||||
|
} | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TaskWrite = {
|
export type TaskWrite = {
|
||||||
@@ -43,4 +60,9 @@ export type TaskWrite = {
|
|||||||
tags: string[]
|
tags: string[]
|
||||||
archived?: boolean
|
archived?: boolean
|
||||||
clientTicket?: string | null
|
clientTicket?: string | null
|
||||||
|
scheduledStart?: string | null
|
||||||
|
scheduledEnd?: string | null
|
||||||
|
deadline?: string | null
|
||||||
|
syncToCalendar?: boolean
|
||||||
|
recurrence?: string | null
|
||||||
}
|
}
|
||||||
|
|||||||
19
frontend/services/dto/zimbra.ts
Normal file
19
frontend/services/dto/zimbra.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
export type ZimbraSettings = {
|
||||||
|
serverUrl: string | null
|
||||||
|
username: string | null
|
||||||
|
calendarPath: string | null
|
||||||
|
enabled: boolean
|
||||||
|
hasPassword: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ZimbraSettingsWrite = {
|
||||||
|
serverUrl: string | null
|
||||||
|
username: string | null
|
||||||
|
calendarPath: string | null
|
||||||
|
password?: string | null
|
||||||
|
enabled: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ZimbraTestResult = {
|
||||||
|
success: boolean
|
||||||
|
}
|
||||||
25
frontend/services/task-recurrences.ts
Normal file
25
frontend/services/task-recurrences.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import type { TaskRecurrence, TaskRecurrenceWrite } from './dto/task-recurrence'
|
||||||
|
|
||||||
|
export function useTaskRecurrenceService() {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
async function create(payload: TaskRecurrenceWrite): Promise<TaskRecurrence> {
|
||||||
|
return api.post<TaskRecurrence>('/task_recurrences', payload as Record<string, unknown>, {
|
||||||
|
toastSuccessKey: 'taskRecurrence.created',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function update(id: number, payload: Partial<TaskRecurrenceWrite>): Promise<TaskRecurrence> {
|
||||||
|
return api.patch<TaskRecurrence>(`/task_recurrences/${id}`, payload as Record<string, unknown>, {
|
||||||
|
toastSuccessKey: 'taskRecurrence.updated',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function remove(id: number): Promise<void> {
|
||||||
|
await api.delete(`/task_recurrences/${id}`, {}, {
|
||||||
|
toastSuccessKey: 'taskRecurrence.deleted',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return { create, update, remove }
|
||||||
|
}
|
||||||
21
frontend/services/zimbra.ts
Normal file
21
frontend/services/zimbra.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import type { ZimbraSettings, ZimbraSettingsWrite, ZimbraTestResult } from './dto/zimbra'
|
||||||
|
|
||||||
|
export function useZimbraService() {
|
||||||
|
const api = useApi()
|
||||||
|
|
||||||
|
async function getSettings(): Promise<ZimbraSettings> {
|
||||||
|
return api.get<ZimbraSettings>('/settings/zimbra')
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveSettings(payload: ZimbraSettingsWrite): Promise<ZimbraSettings> {
|
||||||
|
return api.put<ZimbraSettings>('/settings/zimbra', payload as Record<string, unknown>, {
|
||||||
|
toastSuccessKey: 'zimbra.settings.saved',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testConnection(): Promise<ZimbraTestResult> {
|
||||||
|
return api.post<ZimbraTestResult>('/settings/zimbra/test', {})
|
||||||
|
}
|
||||||
|
|
||||||
|
return { getSettings, saveSettings, testConnection }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user