Skip to content

Commit

Permalink
feat: modify helpdesk api to manage offline
Browse files Browse the repository at this point in the history
  • Loading branch information
vhu-axelor committed Jul 10, 2024
1 parent c4da7ed commit 972b84c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
3 changes: 3 additions & 0 deletions packages/apps/helpdesk/src/api/customer-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export async function searchCustomer({searchValue, page = 0}) {
fieldKey: 'helpdesk_customer',
sortKey: 'helpdesk_customer',
page: page,
provider: 'model',
});
}

Expand All @@ -54,6 +55,7 @@ export async function searchCustomerContact({searchValue, page = 0}) {
fieldKey: 'helpdesk_customerContact',
sortKey: 'helpdesk_customerContact',
page: page,
provider: 'model',
});
}

Expand All @@ -66,5 +68,6 @@ export async function getCustomer({customerId}) {
model: 'com.axelor.apps.base.db.Partner',
id: customerId,
fieldKey: 'helpdesk_customer',
provider: 'model',
});
}
1 change: 1 addition & 0 deletions packages/apps/helpdesk/src/api/project-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ export async function searchProject({searchValue, page = 0}) {
fieldKey: 'helpdesk_project',
sortKey: 'helpdesk_project',
page: page,
provider: 'model',
});
}
47 changes: 37 additions & 10 deletions packages/apps/helpdesk/src/api/ticket-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import {
createStandardSearch,
getActionApi,
getSearchCriterias,
createStandardFetch,
axiosApiProvider,
} from '@axelor/aos-mobile-core';

const createTicketCriteria = (searchValue, userId, userTeam) => {
Expand Down Expand Up @@ -57,6 +57,7 @@ export async function searchTickets({searchValue, userId, page = 0, userTeam}) {
fieldKey: 'helpdesk_ticket',
sortKey: 'helpdesk_ticket',
page,
provider: 'model',
});
}

Expand All @@ -65,6 +66,7 @@ export async function getTicket({ticketId}) {
model: 'com.axelor.apps.helpdesk.db.Ticket',
id: ticketId,
fieldKey: 'helpdesk_ticket',
provider: 'model',
});
}

Expand All @@ -74,6 +76,7 @@ export async function getTicketType() {
fieldKey: 'helpdesk_ticketType',
numberElementsByPage: null,
page: 0,
provider: 'model',
});
}

Expand All @@ -83,6 +86,7 @@ export async function getTicketStatus() {
fieldKey: 'helpdesk_ticketStatus',
numberElementsByPage: null,
page: 0,
provider: 'model',
});
}

Expand All @@ -93,6 +97,7 @@ export async function searchTicketType({searchValue, page = 0}) {
fieldKey: 'helpdesk_ticketType',
sortKey: 'helpdesk_ticketType',
page: page,
provider: 'model',
});
}

Expand All @@ -103,6 +108,7 @@ export async function searchTicketStatus({searchValue, page = 0}) {
fieldKey: 'helpdesk_ticketStatus',
sortKey: 'helpdesk_ticketStatus',
page: page,
provider: 'model',
});
}

Expand All @@ -112,30 +118,51 @@ export async function updateStatusTicket({
targetStatus,
ticketId,
}) {
return axiosApiProvider.put({
return getActionApi().send({
url: `ws/aos/ticket/${ticketId}`,
data: {
version: version,
dateTime: dateTime,
targetStatus: targetStatus,
method: 'put',
body: {
version,
dateTime,
targetStatus,
},
description: 'update status ticket',
matchers: {
id: ticketId,
modelName: 'com.axelor.apps.helpdesk.db.Ticket',
fields: {},
},
});
}

export async function updateTicket({ticket}) {
return axiosApiProvider.post({
return getActionApi().send({
url: '/ws/rest/com.axelor.apps.helpdesk.db.Ticket',
data: {
method: 'post',
body: {
data: ticket,
},
description: 'update ticket',
matchers: {
id: ticket?.id,
modelName: 'com.axelor.apps.helpdesk.db.Ticket',
fields: {},
},
});
}

export async function createTicket({ticket}) {
return axiosApiProvider.put({
return getActionApi().send({
url: '/ws/rest/com.axelor.apps.helpdesk.db.Ticket',
data: {
method: 'put',
body: {
data: ticket,
},
description: 'create ticket',
matchers: {
id: Date.now(),
modelName: 'com.axelor.apps.helpdesk.db.Ticket',
fields: {},
},
});
}
2 changes: 2 additions & 0 deletions packages/apps/helpdesk/src/api/timer-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function getTimer({timerId}) {
model: 'com.axelor.apps.base.db.Timer',
id: timerId,
fieldKey: 'helpdesk_timer',
provider: 'model',
});
}

Expand All @@ -46,5 +47,6 @@ export async function searchTimerHistoryWithId({idTimer}) {
fieldKey: 'helpdesk_timerHistory',
numberElementsByPage: null,
page: 0,
provider: 'model',
});
}

0 comments on commit 972b84c

Please sign in to comment.