taks-d.2.1
This commit is contained in:
@@ -25,12 +25,20 @@ async function invalidateEnquiryDetail(id: string) {
|
||||
await getQueryClient().invalidateQueries({ queryKey: enquiryKeys.detail(id) });
|
||||
}
|
||||
|
||||
async function invalidateEnquiryProjectParties(id: string) {
|
||||
await getQueryClient().invalidateQueries({ queryKey: enquiryKeys.projectParties(id) });
|
||||
}
|
||||
|
||||
async function invalidateEnquiryFollowups(id: string) {
|
||||
await getQueryClient().invalidateQueries({ queryKey: enquiryKeys.followups(id) });
|
||||
}
|
||||
|
||||
export async function invalidateEnquiryMutationQueries(id: string) {
|
||||
await Promise.all([invalidateEnquiryLists(), invalidateEnquiryDetail(id)]);
|
||||
await Promise.all([
|
||||
invalidateEnquiryLists(),
|
||||
invalidateEnquiryDetail(id),
|
||||
invalidateEnquiryProjectParties(id)
|
||||
]);
|
||||
}
|
||||
|
||||
export async function invalidateEnquiryFollowupMutationQueries(enquiryId: string) {
|
||||
@@ -65,6 +73,7 @@ export const deleteEnquiryMutation = mutationOptions({
|
||||
onSettled: async (_data, error, id) => {
|
||||
if (!error) {
|
||||
getQueryClient().removeQueries({ queryKey: enquiryKeys.detail(id) });
|
||||
getQueryClient().removeQueries({ queryKey: enquiryKeys.projectParties(id) });
|
||||
getQueryClient().removeQueries({ queryKey: enquiryKeys.followups(id) });
|
||||
await invalidateEnquiryLists();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { queryOptions } from '@tanstack/react-query';
|
||||
import { getEnquiries, getEnquiryById, getEnquiryFollowups } from './service';
|
||||
import {
|
||||
getEnquiries,
|
||||
getEnquiryById,
|
||||
getEnquiryFollowups,
|
||||
getEnquiryProjectParties
|
||||
} from './service';
|
||||
import type { EnquiryFilters } from './types';
|
||||
|
||||
export const enquiryKeys = {
|
||||
@@ -8,6 +13,8 @@ export const enquiryKeys = {
|
||||
list: (filters: EnquiryFilters) => [...enquiryKeys.lists(), filters] as const,
|
||||
details: () => [...enquiryKeys.all, 'detail'] as const,
|
||||
detail: (id: string) => [...enquiryKeys.details(), id] as const,
|
||||
projectPartiesRoot: () => [...enquiryKeys.all, 'project-parties'] as const,
|
||||
projectParties: (id: string) => [...enquiryKeys.projectPartiesRoot(), id] as const,
|
||||
followupsRoot: () => [...enquiryKeys.all, 'followups'] as const,
|
||||
followups: (id: string) => [...enquiryKeys.followupsRoot(), id] as const
|
||||
};
|
||||
@@ -24,6 +31,12 @@ export const enquiryByIdOptions = (id: string) =>
|
||||
queryFn: () => getEnquiryById(id)
|
||||
});
|
||||
|
||||
export const enquiryProjectPartiesOptions = (id: string) =>
|
||||
queryOptions({
|
||||
queryKey: enquiryKeys.projectParties(id),
|
||||
queryFn: () => getEnquiryProjectParties(id)
|
||||
});
|
||||
|
||||
export const enquiryFollowupsOptions = (id: string) =>
|
||||
queryOptions({
|
||||
queryKey: enquiryKeys.followups(id),
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
EnquiryFollowupsResponse,
|
||||
EnquiryListResponse,
|
||||
EnquiryMutationPayload,
|
||||
EnquiryProjectPartiesResponse,
|
||||
MutationSuccessResponse
|
||||
} from './types';
|
||||
|
||||
@@ -32,6 +33,10 @@ export async function getEnquiryById(id: string): Promise<EnquiryDetailResponse>
|
||||
return apiClient<EnquiryDetailResponse>(`/crm/enquiries/${id}`);
|
||||
}
|
||||
|
||||
export async function getEnquiryProjectParties(id: string): Promise<EnquiryProjectPartiesResponse> {
|
||||
return apiClient<EnquiryProjectPartiesResponse>(`/crm/enquiries/${id}/customers`);
|
||||
}
|
||||
|
||||
export async function createEnquiry(data: EnquiryMutationPayload) {
|
||||
return apiClient<MutationSuccessResponse>('/crm/enquiries', {
|
||||
method: 'POST',
|
||||
|
||||
@@ -5,6 +5,25 @@ export interface EnquiryOption {
|
||||
value: string | null;
|
||||
}
|
||||
|
||||
export interface EnquiryProjectPartyRecord {
|
||||
id: string;
|
||||
organizationId: string;
|
||||
enquiryId: string;
|
||||
customerId: string;
|
||||
role: string;
|
||||
roleCode: string;
|
||||
roleLabel: string | null;
|
||||
remark: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
}
|
||||
|
||||
export interface EnquiryProjectPartyListItem extends EnquiryProjectPartyRecord {
|
||||
customerName: string;
|
||||
customerCode: string;
|
||||
}
|
||||
|
||||
export interface EnquiryBranchOption {
|
||||
id: string;
|
||||
code: string;
|
||||
@@ -113,6 +132,7 @@ export interface EnquiryReferenceData {
|
||||
priorities: EnquiryOption[];
|
||||
leadChannels: EnquiryOption[];
|
||||
followupTypes: EnquiryOption[];
|
||||
projectPartyRoles: EnquiryOption[];
|
||||
customers: EnquiryCustomerLookup[];
|
||||
contacts: EnquiryContactLookup[];
|
||||
assignableUsers: EnquiryAssignableUserLookup[];
|
||||
@@ -148,6 +168,13 @@ export interface EnquiryDetailResponse {
|
||||
activity: EnquiryActivityRecord[];
|
||||
}
|
||||
|
||||
export interface EnquiryProjectPartiesResponse {
|
||||
success: boolean;
|
||||
time: string;
|
||||
message: string;
|
||||
items: EnquiryProjectPartyListItem[];
|
||||
}
|
||||
|
||||
export interface EnquiryFollowupsResponse {
|
||||
success: boolean;
|
||||
time: string;
|
||||
@@ -155,6 +182,12 @@ export interface EnquiryFollowupsResponse {
|
||||
items: EnquiryFollowupRecord[];
|
||||
}
|
||||
|
||||
export interface EnquiryProjectPartyMutationPayload {
|
||||
customerId: string;
|
||||
role: string;
|
||||
remark?: string | null;
|
||||
}
|
||||
|
||||
export interface EnquiryMutationPayload {
|
||||
customerId: string;
|
||||
contactId?: string | null;
|
||||
@@ -176,6 +209,7 @@ export interface EnquiryMutationPayload {
|
||||
isHotProject?: boolean;
|
||||
notes?: string;
|
||||
isActive?: boolean;
|
||||
projectParties?: EnquiryProjectPartyMutationPayload[];
|
||||
}
|
||||
|
||||
export interface EnquiryFollowupMutationPayload {
|
||||
|
||||
Reference in New Issue
Block a user