mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Generate unique ticket numbers for service requests
Add server-side generation of unique ticket numbers for SAV tickets, omitting `ticketNumber` from client-side schema validation in `insertSavTicketSchema` and including it in the ticket data sent to `storage.createSavTicket`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 31f9bd88-0285-4787-81b3-31ceeea5a08b Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/31f9bd88-0285-4787-81b3-31ceeea5a08b/kCBjAsQ
This commit is contained in:
1 parent
f81637867b
commit
18ec91e4ff
4 files changed
+216
-1
No files matched your search
+11
-1
@@ -2504,6 +2504,10 @@ RÉSUMÉ DU SCAN
|
||||
return res.status(400).json({ message: "No groups available for ticket creation" });
|
||||
}
|
||||
|
||||
// Generate unique ticket number
|
||||
const now = new Date();
|
||||
const ticketNumber = `SAV-${now.getFullYear()}${(now.getMonth() + 1).toString().padStart(2, '0')}${now.getDate().toString().padStart(2, '0')}-${Date.now().toString().slice(-6)}`;
|
||||
|
||||
// Parse and validate request body
|
||||
const ticketData = insertSavTicketSchema.parse({
|
||||
...req.body,
|
||||
@@ -2511,12 +2515,18 @@ RÉSUMÉ DU SCAN
|
||||
createdBy: user.id,
|
||||
});
|
||||
|
||||
// Add the generated ticket number
|
||||
const ticketDataWithNumber = {
|
||||
...ticketData,
|
||||
ticketNumber,
|
||||
};
|
||||
|
||||
// Validate that the specified group is accessible to the user
|
||||
if (!availableGroupIds.includes(ticketData.groupId)) {
|
||||
return res.status(403).json({ message: "Access denied to the specified group" });
|
||||
}
|
||||
|
||||
const ticket = await storage.createSavTicket(ticketData);
|
||||
const ticket = await storage.createSavTicket(ticketDataWithNumber);
|
||||
res.status(201).json(ticket);
|
||||
} catch (error) {
|
||||
console.error("Error creating SAV ticket:", error);
|
||||
|
||||
Reference in new issue
Block a user