- Trasporti- Passo 2

This commit is contained in:
Surya Paolo
2025-12-22 23:39:42 +01:00
parent c9fc1a83d0
commit 11e946bfc6
34 changed files with 1682 additions and 1029 deletions

View File

@@ -367,7 +367,7 @@ export default defineComponent({
const endpoint = responseAction.value === 'accept'
? `/api/trasporti/richieste/${selectedRequest.value._id}/accept`
: `/api/trasporti/richieste/${selectedRequest.value._id}/reject`;
const response = await Api.SendReq(endpoint, 'PUT', { message: responseMessage.value });
const response = await Api.SendReqWithData(endpoint, 'PUT', { message: responseMessage.value });
if (response.success) {
const index = receivedRequests.value.findIndex(r => r._id === selectedRequest.value?._id);
if (index !== -1) {
@@ -390,7 +390,7 @@ export default defineComponent({
const cancelRequest = async (request: RideRequest) => {
$q.dialog({ title: 'Annulla richiesta', message: 'Sei sicuro?', cancel: true }).onOk(async () => {
try {
const response = await Api.SendReq(`/api/trasporti/richieste/${request._id}/cancel`, 'PUT');
const response = await Api.SendReqWithData(`/api/trasporti/richieste/${request._id}/cancel`, 'PUT');
if (response.success) {
const index = sentRequests.value.findIndex(r => r._id === request._id);
if (index !== -1) sentRequests.value[index].status = 'cancelled';
@@ -406,9 +406,9 @@ export default defineComponent({
loading.value = true;
try {
const [statsRes, receivedRes, sentRes] = await Promise.all([
Api.SendReq('/api/trasporti/richieste/stats', 'GET'),
Api.SendReq('/api/trasporti/richieste/received', 'GET'),
Api.SendReq('/api/trasporti/richieste/sent', 'GET')
Api.SendReqWithData('/api/trasporti/richieste/stats', 'GET'),
Api.SendReqWithData('/api/trasporti/richieste/received', 'GET'),
Api.SendReqWithData('/api/trasporti/richieste/sent', 'GET')
]);
if (statsRes.success) stats.value = statsRes.data;
if (receivedRes.success) {
@@ -428,7 +428,7 @@ export default defineComponent({
currentPage.value++;
try {
const endpoint = activeTab.value === 'received' ? '/api/trasporti/richieste/received' : '/api/trasporti/richieste/sent';
const response = await Api.SendReq(`${endpoint}?page=${currentPage.value}`, 'GET');
const response = await Api.SendReqWithData(`${endpoint}?page=${currentPage.value}`, 'GET');
if (response.success) {
const newRequests = response.data.requests || [];
if (activeTab.value === 'received') receivedRequests.value.push(...newRequests);