feat: add deals, tasks, and organizations pages with CRUD functionality
- Implemented DealsPage with deal creation, updating, and filtering features. - Added OrganizationsPage to manage and switch between organizations. - Created TasksPage for task management, including task creation and filtering. - Updated router to include new pages for navigation.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { apiClient } from '@/lib/api-client'
|
||||
import type { Deal, DealStage, DealStatus } from '@/types/crm'
|
||||
|
||||
export interface DealFilters {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
status?: DealStatus[]
|
||||
stage?: DealStage | null
|
||||
ownerId?: number
|
||||
minAmount?: number | null
|
||||
maxAmount?: number | null
|
||||
orderBy?: 'created_at' | 'amount' | 'updated_at'
|
||||
order?: 'asc' | 'desc'
|
||||
}
|
||||
|
||||
export interface DealPayload {
|
||||
contact_id: number
|
||||
title: string
|
||||
amount?: number | string | null
|
||||
currency?: string | null
|
||||
owner_id?: number | null
|
||||
}
|
||||
|
||||
export interface DealUpdatePayload {
|
||||
status?: DealStatus
|
||||
stage?: DealStage
|
||||
amount?: number | string | null
|
||||
currency?: string | null
|
||||
}
|
||||
|
||||
const mapFilters = (filters?: DealFilters) => ({
|
||||
page: filters?.page,
|
||||
page_size: filters?.pageSize,
|
||||
status: filters?.status,
|
||||
stage: filters?.stage ?? undefined,
|
||||
owner_id: filters?.ownerId,
|
||||
min_amount: filters?.minAmount ?? undefined,
|
||||
max_amount: filters?.maxAmount ?? undefined,
|
||||
order_by: filters?.orderBy,
|
||||
order: filters?.order,
|
||||
})
|
||||
|
||||
export const listDeals = (filters?: DealFilters) => apiClient.get<Deal[]>('/deals/', { params: mapFilters(filters) })
|
||||
|
||||
export const createDeal = (payload: DealPayload) => apiClient.post<Deal, DealPayload>('/deals/', payload)
|
||||
|
||||
export const updateDeal = (dealId: number, payload: DealUpdatePayload) =>
|
||||
apiClient.patch<Deal, DealUpdatePayload>(`/deals/${dealId}`, payload)
|
||||
Reference in New Issue
Block a user