import apiService from './api.service' export interface WorkflowConditionDto { column: string operator: string compareValue: number } export interface CompareOutcomeDto { label: string targetId?: string | null conditions: WorkflowConditionDto[] } export interface WorkflowItemDto { id: string listFormCode: string orderNo: number title: string sorumlu: string tarih: string status: string durum: string amount: number currentNodeId: string assignedApprover: string informedPerson: string history: Array<{ time: string action: string note: string }> } export interface WorkflowCriteriaDto { id: string listFormCode: string workflowItemId: string nodeId: string kind: string title: string column: string operator: string compareValue: number approver: string informPerson: string nextOnStart?: string | null nextOnTrue?: string | null nextOnFalse?: string | null nextOnApprove?: string | null nextOnReject?: string | null positionX: number positionY: number compareOutcomes: CompareOutcomeDto[] } export interface WorkflowStateDto { workflowItems: WorkflowItemDto[] criteria: WorkflowCriteriaDto[] } export type CreateUpdateWorkflowInput = Partial & { listFormCode?: string sorumlu: string amount: number tarih?: string } export type SaveCriteriaInput = Omit, 'id'> & { id?: string | null workflowItemId: string } const baseUrl = '/api/app/list-form-workflow' export const workflowService = { async getState(listFormCode?: string) { const response = await apiService.fetchData({ method: 'GET', url: `${baseUrl}/state`, params: { listFormCode }, }) return response.data }, async createWorkflow(payload: CreateUpdateWorkflowInput) { const response = await apiService.fetchData({ method: 'POST', url: `${baseUrl}/workflows`, data: payload, }) return response.data }, async updateWorkflow(id: string, payload: CreateUpdateWorkflowInput) { const response = await apiService.fetchData({ method: 'PUT', url: `${baseUrl}/workflows/${id}`, data: payload, }) return response.data }, async startWorkflow(id: string) { const response = await apiService.fetchData({ method: 'POST', url: `${baseUrl}/workflows/${id}/start`, }) return response.data }, async decideWorkflow(id: string, payload: { approved: boolean; note?: string }) { const response = await apiService.fetchData({ method: 'POST', url: `${baseUrl}/workflows/${id}/decision`, data: payload, }) return response.data }, async saveCriteria(payload: SaveCriteriaInput) { const response = await apiService.fetchData({ method: 'POST', url: `${baseUrl}/criteria`, data: payload, }) return response.data }, async deleteCriteria(id: string) { await apiService.fetchData({ method: 'DELETE', url: `${baseUrl}/criteria/${id}`, }) }, async resetDemo(listFormCode?: string) { const response = await apiService.fetchData({ method: 'POST', url: `${baseUrl}/reset-demo`, params: { listFormCode }, }) return response.data }, }