feat: aggiunta possiblità di modificare il cliente

This commit is contained in:
2026-07-07 08:14:07 +02:00
parent 0f012816ea
commit b3570d6757
3 changed files with 124 additions and 27 deletions
+6 -2
View File
@@ -483,6 +483,8 @@ router.patch('/:id', async (req, res) => {
if (updates.type_id !== undefined) ticketFields.TypeID = updates.type_id;
if (updates.title !== undefined) ticketFields.Title = updates.title;
if (updates.ticket_lock_id !== undefined) ticketFields.LockID = updates.ticket_lock_id;
if (updates.customer_id !== undefined) ticketFields.CustomerID = updates.customer_id;
if (updates.customer_user_id !== undefined) ticketFields.CustomerUser = updates.customer_user_id;
// Auto sblocco check
if (updates.ticket_state_id) {
@@ -525,7 +527,7 @@ router.patch('/:id', async (req, res) => {
// Fetch current ticket for history comparison
const currentResult = await client.query(
`SELECT ticket_state_id, ticket_priority_id, queue_id, user_id, type_id, title, ticket_lock_id
`SELECT ticket_state_id, ticket_priority_id, queue_id, user_id, type_id, title, ticket_lock_id, customer_id, customer_user_id
FROM ticket WHERE id = $1`,
[id]
);
@@ -557,7 +559,7 @@ router.patch('/:id', async (req, res) => {
const setParams = [];
let pIdx = 1;
const allowedFields = ['ticket_state_id', 'ticket_priority_id', 'queue_id', 'user_id', 'type_id', 'title', 'ticket_lock_id'];
const allowedFields = ['ticket_state_id', 'ticket_priority_id', 'queue_id', 'user_id', 'type_id', 'title', 'ticket_lock_id', 'customer_id', 'customer_user_id'];
for (const field of allowedFields) {
if (updates[field] !== undefined && updates[field] !== current[field]) {
setClauses.push(`${field} = $${pIdx++}`);
@@ -589,6 +591,8 @@ router.patch('/:id', async (req, res) => {
user_id: 'OwnerUpdate',
type_id: 'TypeUpdate',
ticket_lock_id: 'Lock',
customer_id: 'CustomerUpdate',
customer_user_id: 'CustomerUpdate',
};
for (const field of allowedFields) {