Fascicoli+Tassonomia+permessi
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
import apiClient from './client'
|
||||
|
||||
// ─── Tipi ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface FascicoloResponse {
|
||||
id: string
|
||||
tenant_id: string
|
||||
titolo: string
|
||||
numero_pratica: string | null
|
||||
stato: 'aperto' | 'chiuso' | 'archiviato'
|
||||
categoria: string | null
|
||||
responsabile_id: string | null
|
||||
scadenza: string | null
|
||||
note: string | null
|
||||
created_by: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
message_count: number
|
||||
}
|
||||
|
||||
export interface FascicoloCreate {
|
||||
titolo: string
|
||||
numero_pratica?: string | null
|
||||
stato?: 'aperto' | 'chiuso' | 'archiviato'
|
||||
categoria?: string | null
|
||||
responsabile_id?: string | null
|
||||
scadenza?: string | null
|
||||
note?: string | null
|
||||
}
|
||||
|
||||
export interface FascicoloUpdate {
|
||||
titolo?: string
|
||||
numero_pratica?: string | null
|
||||
stato?: 'aperto' | 'chiuso' | 'archiviato'
|
||||
categoria?: string | null
|
||||
responsabile_id?: string | null
|
||||
scadenza?: string | null
|
||||
note?: string | null
|
||||
}
|
||||
|
||||
export interface FascicoloMessageItem {
|
||||
id: string
|
||||
subject: string | null
|
||||
from_address: string | null
|
||||
to_addresses: string[] | null
|
||||
direction: 'inbound' | 'outbound'
|
||||
pec_type: string
|
||||
state: string
|
||||
mailbox_id: string
|
||||
received_at: string | null
|
||||
sent_at: string | null
|
||||
created_at: string
|
||||
added_at: string
|
||||
}
|
||||
|
||||
export interface MessageFascicoloSummary {
|
||||
id: string
|
||||
titolo: string
|
||||
numero_pratica: string | null
|
||||
stato: 'aperto' | 'chiuso' | 'archiviato'
|
||||
categoria: string | null
|
||||
}
|
||||
|
||||
// ─── Client API ───────────────────────────────────────────────────────────────
|
||||
|
||||
export const fascicoliApi = {
|
||||
/** Lista fascicoli con filtri opzionali */
|
||||
list: (params?: {
|
||||
stato?: string
|
||||
responsabile_id?: string
|
||||
search?: string
|
||||
}) =>
|
||||
apiClient
|
||||
.get<FascicoloResponse[]>('/fascicoli', { params })
|
||||
.then((r) => r.data),
|
||||
|
||||
/** Dettaglio fascicolo */
|
||||
get: (id: string) =>
|
||||
apiClient.get<FascicoloResponse>(`/fascicoli/${id}`).then((r) => r.data),
|
||||
|
||||
/** Crea fascicolo */
|
||||
create: (data: FascicoloCreate) =>
|
||||
apiClient.post<FascicoloResponse>('/fascicoli', data).then((r) => r.data),
|
||||
|
||||
/** Modifica fascicolo */
|
||||
update: (id: string, data: FascicoloUpdate) =>
|
||||
apiClient
|
||||
.patch<FascicoloResponse>(`/fascicoli/${id}`, data)
|
||||
.then((r) => r.data),
|
||||
|
||||
/** Elimina fascicolo */
|
||||
delete: (id: string) =>
|
||||
apiClient.delete(`/fascicoli/${id}`).then((r) => r.data),
|
||||
|
||||
/** Messaggi del fascicolo */
|
||||
getMessages: (id: string) =>
|
||||
apiClient
|
||||
.get<FascicoloMessageItem[]>(`/fascicoli/${id}/messages`)
|
||||
.then((r) => r.data),
|
||||
|
||||
/** Aggiungi messaggi al fascicolo */
|
||||
addMessages: (id: string, message_ids: string[]) =>
|
||||
apiClient
|
||||
.post<{ added: number }>(`/fascicoli/${id}/messages`, { message_ids })
|
||||
.then((r) => r.data),
|
||||
|
||||
/** Rimuovi messaggi dal fascicolo */
|
||||
removeMessages: (id: string, message_ids: string[]) =>
|
||||
apiClient
|
||||
.delete<{ removed: number }>(`/fascicoli/${id}/messages`, {
|
||||
data: { message_ids },
|
||||
})
|
||||
.then((r) => r.data),
|
||||
|
||||
/** Fascicoli a cui appartiene un messaggio */
|
||||
getMessageFascicoli: (messageId: string) =>
|
||||
apiClient
|
||||
.get<MessageFascicoloSummary[]>(`/messages/${messageId}/fascicoli`)
|
||||
.then((r) => r.data),
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import apiClient from './client'
|
||||
import type {
|
||||
LabelCreate,
|
||||
LabelResponse,
|
||||
LabelTreeResponse,
|
||||
LabelUpdate,
|
||||
MessageBulkLabelRequest,
|
||||
MessageBulkLabelResponse,
|
||||
@@ -16,6 +17,10 @@ export const labelsApi = {
|
||||
list: () =>
|
||||
apiClient.get<LabelResponse[]>('/labels').then((r) => r.data),
|
||||
|
||||
/** Restituisce la tassonomia come albero annidato (Ambito > Processo > Classificazione). */
|
||||
getTree: () =>
|
||||
apiClient.get<LabelTreeResponse[]>('/labels/tree').then((r) => r.data),
|
||||
|
||||
create: (data: LabelCreate) =>
|
||||
apiClient.post<LabelResponse>('/labels', data).then((r) => r.data),
|
||||
|
||||
|
||||
@@ -39,6 +39,18 @@ export interface MessageBulkUpdatePayload {
|
||||
is_conserved?: boolean
|
||||
}
|
||||
|
||||
export interface MessageUpdatePayload {
|
||||
is_read?: boolean
|
||||
is_starred?: boolean
|
||||
is_archived?: boolean
|
||||
is_trashed?: boolean
|
||||
is_pending_conservation?: boolean
|
||||
is_conserved?: boolean
|
||||
/** Rischio e Riservatezza (N3) — stringa vuota per resettare a null */
|
||||
risk_level?: string
|
||||
confidentiality?: string
|
||||
}
|
||||
|
||||
export interface MessageBulkUpdateResponse {
|
||||
updated: number
|
||||
items: MessageResponse[]
|
||||
@@ -96,6 +108,12 @@ export const messagesApi = {
|
||||
.patch<MessageResponse>(`/messages/${id}`, { is_pending_conservation: false })
|
||||
.then((r) => r.data),
|
||||
|
||||
/** Aggiorna uno o piu' campi del messaggio (PATCH generico) — include risk_level/confidentiality (N3) */
|
||||
update: (id: string, payload: MessageUpdatePayload) =>
|
||||
apiClient
|
||||
.patch<MessageResponse>(`/messages/${id}`, payload)
|
||||
.then((r) => r.data),
|
||||
|
||||
/** Aggiorna in blocco is_starred e/o is_archived e/o is_trashed su più messaggi */
|
||||
bulkUpdate: (payload: MessageBulkUpdatePayload) =>
|
||||
apiClient
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import apiClient from './client'
|
||||
import type {
|
||||
PermissionPresetCreate,
|
||||
PermissionPresetResponse,
|
||||
PermissionPresetUpdate,
|
||||
} from '@/types/api.types'
|
||||
|
||||
export const permissionPresetsApi = {
|
||||
/**
|
||||
* Lista tutti i preset del tenant corrente.
|
||||
*/
|
||||
list: () =>
|
||||
apiClient
|
||||
.get<PermissionPresetResponse[]>('/permission-presets')
|
||||
.then((r) => r.data),
|
||||
|
||||
/**
|
||||
* Crea un nuovo preset.
|
||||
*/
|
||||
create: (data: PermissionPresetCreate) =>
|
||||
apiClient
|
||||
.post<PermissionPresetResponse>('/permission-presets', data)
|
||||
.then((r) => r.data),
|
||||
|
||||
/**
|
||||
* Aggiorna un preset esistente.
|
||||
*/
|
||||
update: (id: string, data: PermissionPresetUpdate) =>
|
||||
apiClient
|
||||
.put<PermissionPresetResponse>(`/permission-presets/${id}`, data)
|
||||
.then((r) => r.data),
|
||||
|
||||
/**
|
||||
* Elimina un preset.
|
||||
*/
|
||||
delete: (id: string) =>
|
||||
apiClient.delete(`/permission-presets/${id}`),
|
||||
}
|
||||
@@ -1,8 +1,30 @@
|
||||
import apiClient from './client'
|
||||
|
||||
export type ConditionField = 'from_address' | 'to_address' | 'subject' | 'mailbox_id' | 'pec_type'
|
||||
export type ConditionField =
|
||||
| 'from_address'
|
||||
| 'to_address'
|
||||
| 'subject'
|
||||
| 'mailbox_id'
|
||||
| 'pec_type'
|
||||
/** Tassonomia (N2): verifica se il messaggio ha gia' una specifica etichetta (UUID come valore) */
|
||||
| 'has_label'
|
||||
/** Rischio e Riservatezza (N3): verifica il livello gia' impostato sul messaggio */
|
||||
| 'risk_level'
|
||||
| 'confidentiality'
|
||||
|
||||
export type ConditionOperator = 'contains' | 'equals' | 'starts_with' | 'ends_with' | 'regex' | 'not_contains'
|
||||
export type ActionType = 'apply_label' | 'assign_vbox' | 'mark_read' | 'mark_starred' | 'notify_webhook'
|
||||
|
||||
export type ActionType =
|
||||
| 'apply_label'
|
||||
| 'assign_vbox'
|
||||
| 'mark_read'
|
||||
| 'mark_starred'
|
||||
| 'notify_webhook'
|
||||
/** Tassonomia (N2): applica un nodo tassonomico (Ambito/Processo/Classificazione) */
|
||||
| 'apply_taxonomy'
|
||||
/** Rischio e Riservatezza (N3): imposta il livello di rischio o riservatezza */
|
||||
| 'set_risk_level'
|
||||
| 'set_confidentiality'
|
||||
|
||||
export interface RoutingRuleCondition {
|
||||
id: string
|
||||
|
||||
Reference in New Issue
Block a user