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,35 @@
|
||||
import { apiClient } from '@/lib/api-client'
|
||||
import type { Contact } from '@/types/crm'
|
||||
|
||||
export interface ContactFilters {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
search?: string
|
||||
ownerId?: number
|
||||
}
|
||||
|
||||
export interface ContactPayload {
|
||||
name: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
owner_id?: number | null
|
||||
}
|
||||
|
||||
export type ContactUpdatePayload = Partial<Omit<ContactPayload, 'owner_id'>>
|
||||
|
||||
const mapFilters = (filters?: ContactFilters) => ({
|
||||
page: filters?.page,
|
||||
page_size: filters?.pageSize,
|
||||
search: filters?.search,
|
||||
owner_id: filters?.ownerId,
|
||||
})
|
||||
|
||||
export const listContacts = (filters?: ContactFilters) =>
|
||||
apiClient.get<Contact[]>('/contacts/', { params: mapFilters(filters) })
|
||||
|
||||
export const createContact = (payload: ContactPayload) => apiClient.post<Contact, ContactPayload>('/contacts/', payload)
|
||||
|
||||
export const updateContact = (contactId: number, payload: ContactUpdatePayload) =>
|
||||
apiClient.patch<Contact, ContactUpdatePayload>(`/contacts/${contactId}`, payload)
|
||||
|
||||
export const deleteContact = (contactId: number) => apiClient.delete<void>(`/contacts/${contactId}`)
|
||||
Reference in New Issue
Block a user