Compare commits
No commits in common. "6ec2ad272015536a1fab592c20cefe56fccd3ce9" and "41bd4ffd5fdcf5d9e8148f6c6c42d81a920ed2bd" have entirely different histories.
6ec2ad2720
...
41bd4ffd5f
19
API.md
19
API.md
@ -48,7 +48,7 @@ Output
|
|||||||
{"ok":true}
|
{"ok":true}
|
||||||
```
|
```
|
||||||
|
|
||||||
### - Post a ticket
|
### - Post the complaint request
|
||||||
|
|
||||||
POST http://localhost:3000/api/ticket
|
POST http://localhost:3000/api/ticket
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ Output :
|
|||||||
"message": "Ticket No:2 created successfully"
|
"message": "Ticket No:2 created successfully"
|
||||||
```
|
```
|
||||||
|
|
||||||
### - Get the list of ticket raised by the user
|
### - Get the request By the user
|
||||||
|
|
||||||
GET http://localhost:3000/api/ticket
|
GET http://localhost:3000/api/ticket
|
||||||
|
|
||||||
@ -107,19 +107,4 @@ Output :
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
### - Get the details ticket for particular ticket raised by the user
|
|
||||||
|
|
||||||
GET http://localhost:3000/api/ticket/[ticket_id]
|
|
||||||
|
|
||||||
```
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"ticket_id": 1,
|
|
||||||
"category_of_request": "ATM Related",
|
|
||||||
"nature_of_request": "Transaction Issue",
|
|
||||||
"additional_info": "ATM ID: PNB23567WE456, Debit Card: 34567895434567, Transaction Amount: 15000, Transaction Reference Number : 345678987654323, Transaction Date: 2025-02-11",
|
|
||||||
"message": "Money got debited but money not receive. ",
|
|
||||||
"created_date": "12/2/2025, 12:31:13 pm"
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
160
Docs/CRM.postman_collection.json
Normal file
160
Docs/CRM.postman_collection.json
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
{
|
||||||
|
"info": {
|
||||||
|
"_postman_id": "c0971b0e-8469-4ffd-a95e-090b1ba552da",
|
||||||
|
"name": "CRM",
|
||||||
|
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
|
||||||
|
"_exporter_id": "39926215"
|
||||||
|
},
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "Login",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\r\n \"AccNo\" :\"30022497138\"\r\n}",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "http://localhost:3000/api/auth/login/account_no"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get account details",
|
||||||
|
"request": {
|
||||||
|
"auth": {
|
||||||
|
"type": "inherit",
|
||||||
|
"inherit": {}
|
||||||
|
},
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "http://localhost:3000/api/user"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Validate OTP",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\"OTP\": 77208}",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "text"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "http://localhost:3000/api/otp"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "logout",
|
||||||
|
"request": {
|
||||||
|
"auth": {
|
||||||
|
"type": "inherit",
|
||||||
|
"inherit": {}
|
||||||
|
},
|
||||||
|
"method": "POST",
|
||||||
|
"header": [],
|
||||||
|
"url": "http://localhost:3000/api/auth/logout"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "generate OTP",
|
||||||
|
"protocolProfileBehavior": {
|
||||||
|
"disableBodyPruning": true
|
||||||
|
},
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "http://localhost:3000/api/otp"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Fetch Mobile Number",
|
||||||
|
"request": {
|
||||||
|
"auth": {
|
||||||
|
"type": "inherit",
|
||||||
|
"inherit": {}
|
||||||
|
},
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "http://localhost:3000/api/mobile_no/by/30022497139"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Get User",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "http://localhost:3000/api/user"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Create Ticket",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\r\n \"summary\":\" Login issue Related\", \r\n \"description\":\"Login related\", \r\n \r\n\t\"steps_to_reproduce\" :\"Money got debited from account\",\r\n\t\"category\": {\r\n \"name\": \"General\"\r\n\t},\r\n\t\"project\": {\r\n \"id\": 1\r\n }\r\n}",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "http://localhost:3000/api/ticket"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Add column",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "http://localhost:3000/api/addColumn"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Dev populate",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "http://localhost:3000/api/dev/populate"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "View Ticket",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": "http://localhost:3000/api/ticket"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
172
Docs/MantisBT.postman_collection.json
Normal file
172
Docs/MantisBT.postman_collection.json
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
{
|
||||||
|
"info": {
|
||||||
|
"_postman_id": "62121509-c7ee-4d92-9684-337a1d96a6ac",
|
||||||
|
"name": "MantisBT",
|
||||||
|
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json",
|
||||||
|
"_exporter_id": "39926215"
|
||||||
|
},
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "Create Token",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "beHEFeDe-eE0YdTIK098naY0-iirvISx",
|
||||||
|
"type": "text",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "YdTsu-wuBfc4ekVDZpfk0K4dvjmoH6Z-",
|
||||||
|
"type": "text",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "DBSC0FHDatcHiScox5vm2GPuNnNrezqM",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost/mantisBT/api/rest/users/:user_id/token",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"mantisBT",
|
||||||
|
"api",
|
||||||
|
"rest",
|
||||||
|
"users",
|
||||||
|
":user_id",
|
||||||
|
"token"
|
||||||
|
],
|
||||||
|
"variable": [
|
||||||
|
{
|
||||||
|
"key": "user_id",
|
||||||
|
"value": "5",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Create issue",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "beHEFeDe-eE0YdTIK098naY0-iirvISx",
|
||||||
|
"type": "text",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "YdTsu-wuBfc4ekVDZpfk0K4dvjmoH6Z-",
|
||||||
|
"type": "text",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "GefLBxeHyHDL9DXkGqX4qQ7Cayquqdaj",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\r\n \"summary\": \"ATM Fault\",\r\n \"description\": \"ATM Fault\",\r\n \"additional_information\": \"{ATM ID : 678UCBA00988, debit_card : 600226543567}\",\r\n \"steps_to_reproduce\" :\"Money got debited from account\",\r\n \"project\": {\r\n \"id\": 1\r\n }\r\n}\r\n",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": "http://localhost/mantisBT/api/rest/issues/"
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get a issue by issue id",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "GefLBxeHyHDL9DXkGqX4qQ7Cayquqdaj",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost/mantisBT/api/rest/issues/:issue_id",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"mantisBT",
|
||||||
|
"api",
|
||||||
|
"rest",
|
||||||
|
"issues",
|
||||||
|
":issue_id"
|
||||||
|
],
|
||||||
|
"variable": [
|
||||||
|
{
|
||||||
|
"key": "issue_id",
|
||||||
|
"value": "43"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "post note",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "Authorization",
|
||||||
|
"value": "DBSC0FHDatcHiScox5vm2GPuNnNrezqM",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\r\n \"text\": \"test note\",\r\n \"view_state\": {\r\n \t\"name\": \"public\"\r\n }\r\n}",
|
||||||
|
"options": {
|
||||||
|
"raw": {
|
||||||
|
"language": "json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"raw": "http://localhost/mantisBT/api/rest/issues/:issue_id/notes",
|
||||||
|
"protocol": "http",
|
||||||
|
"host": [
|
||||||
|
"localhost"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"mantisBT",
|
||||||
|
"api",
|
||||||
|
"rest",
|
||||||
|
"issues",
|
||||||
|
":issue_id",
|
||||||
|
"notes"
|
||||||
|
],
|
||||||
|
"variable": [
|
||||||
|
{
|
||||||
|
"key": "issue_id",
|
||||||
|
"value": "43"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,35 +1,83 @@
|
|||||||
import { getIronSession } from "iron-session";
|
import { getIronSession } from "iron-session";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import getSessionOptions from "@/app/api/auth/session/options";
|
|
||||||
import SessionPayload from "@/app/api/auth/session/payload";
|
|
||||||
import AppDataSource from "@/app/_data/source/app-data-source";
|
import AppDataSource from "@/app/_data/source/app-data-source";
|
||||||
import { Ticket } from "@/app/_data/entities/Ticket";
|
import { User } from "@/app/_data/entities/User";
|
||||||
|
import SessionPayload from "../../auth/session/payload";
|
||||||
|
import getSessionOptions from "../../auth/session/options";
|
||||||
|
|
||||||
|
export async function GET(req: Request, { params }: { params: { ticket_id: number }})
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
const session = await getIronSession<SessionPayload>(cookies(), getSessionOptions());
|
||||||
|
console.log("Session :",session);
|
||||||
|
if (!session.TwoStepAuthentication) {
|
||||||
|
return Response.json(null);
|
||||||
|
}
|
||||||
|
|
||||||
export async function GET(request: Request, { params }: { params: { ticket_id: number }}) {
|
if (!session.accountNo) {
|
||||||
try {
|
return Response.json({ message: `Please sign in before raise a ticket` })
|
||||||
const { ticket_id } = params;
|
}
|
||||||
const session = await getIronSession<SessionPayload>(cookies(), getSessionOptions());
|
|
||||||
if (!session.TwoStepAuthentication) {
|
|
||||||
return Response.json(null);
|
|
||||||
}
|
|
||||||
if (!session.accountNo) {
|
|
||||||
return Response.json({ message: `Please sign in before raise a ticket` })
|
|
||||||
}
|
|
||||||
|
|
||||||
const connection_crm = await AppDataSource.getConnection();
|
const connection_crm = await AppDataSource.getConnection();
|
||||||
const ticketRepo = connection_crm.getRepository(Ticket);
|
//const connection_mantis = await AppDataSource.getMantisConnection();
|
||||||
// Get list of ticket raised by the user
|
const userRepo = connection_crm.getRepository(User);
|
||||||
const ticket_list = await ticketRepo.createQueryBuilder('ticket')
|
const user_table = await userRepo.createQueryBuilder('user')
|
||||||
.select(['id','ticket_id', 'category_of_request', 'nature_of_request', 'additional_info','message','created_date'])
|
.select(['first_name', 'middle_name', 'last_name'])
|
||||||
.where("ticket.ticket_id = :ticket_id" , { ticket_id: ticket_id })
|
.where("user.bank_account_no = :AccountNo", { AccountNo: session.accountNo })
|
||||||
.andWhere("ticket.customer_account_no = :customer_account_no" ,{customer_account_no:session.accountNo })
|
.getRawOne();
|
||||||
.getRawOne();
|
|
||||||
if(!ticket_list){return Response.json("No Ticket is Present.");}
|
const user_name = (user_table.first_name ? user_table.first_name + ' ' : '') +
|
||||||
return Response.json(ticket_list)
|
(user_table.middle_name ? user_table.middle_name + ' ' : '') +
|
||||||
}
|
(user_table.last_name ? user_table.last_name + ' ' : '');
|
||||||
catch (error) {
|
|
||||||
return Response.json(null, { status: 500 });
|
const ticketRepo = connection_crm.getRepository(Ticket);
|
||||||
}
|
const ticket_list = await ticketRepo.createQueryBuilder('ticket')
|
||||||
|
.select(['id', 'category_of_request', 'nature_of_request', 'created_date','additional_info'])
|
||||||
|
.where("ticket.created_by = :created_by", { created_by: user_name }).getRawMany();
|
||||||
|
|
||||||
|
if(!ticket_list){return Response.json('No Details Found')}
|
||||||
|
const ticket_ids = ticket_list.map(ticket => ticket.id);
|
||||||
|
// Mantis-database fetching for "status" & "message"
|
||||||
|
const queryRunner = connection_mantis.createQueryRunner();
|
||||||
|
await queryRunner.connect();
|
||||||
|
let ticketResolution: { [key: number]: string } = {};
|
||||||
|
let ticketMessage: { [key: number]: string[] } = {};
|
||||||
|
|
||||||
|
for (const id of ticket_ids) {
|
||||||
|
// For status of ticket
|
||||||
|
const ticket_resolution = await queryRunner.query('SELECT resolution,handler_id FROM "kccb_bug" WHERE id = $1', [id]);
|
||||||
|
const ticket_status =ticket_resolution[0]?.resolution
|
||||||
|
const ticket_handler =ticket_resolution[0]?.handler_id
|
||||||
|
let status :string ='';
|
||||||
|
if(ticket_status === 10 && ticket_handler === 0){status = 'Open'}
|
||||||
|
if(ticket_handler > 0){status = 'In Progress'}
|
||||||
|
if(ticket_status === 20){status='Resolved'}
|
||||||
|
if(ticket_status === 30){status='Reopen'}
|
||||||
|
ticketResolution[id] = status
|
||||||
|
|
||||||
|
// For Message of ticket
|
||||||
|
const ticket_note = await queryRunner.query('SELECT id FROM "kccb_bugnote" WHERE bug_id = $1', [id]);
|
||||||
|
const ticket_note_ids =ticket_note.map((item:{id:number}) =>item.id)
|
||||||
|
|
||||||
|
for(const note_id of ticket_note_ids ){
|
||||||
|
const ticket_note_text = await queryRunner.query('SELECT note FROM "kccb_bugnote_text" WHERE id = $1', [note_id]);
|
||||||
|
if (!ticketMessage[id]) {
|
||||||
|
ticketMessage[id] = [];
|
||||||
|
}
|
||||||
|
ticketMessage[id].push(...ticket_note_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const result = ticket_list.map(item =>
|
||||||
|
(
|
||||||
|
{
|
||||||
|
...item,status:ticketResolution[item.id]||null,message: ticketMessage[item.id]||null
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
queryRunner.release();
|
||||||
|
return Response.json(result)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
return Response.json(null, { status: 500 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ export async function POST(request: Request) {
|
|||||||
if (!session.TwoStepAuthentication) {
|
if (!session.TwoStepAuthentication) {
|
||||||
return Response.json(null);
|
return Response.json(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const mantisBT_Token =process.env.MantisBT_Token || ""; //MantisBT Token
|
const mantisBT_Token =process.env.MantisBT_Token || ""; //MantisBT Token
|
||||||
|
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { IconEye, IconMessage, IconSearch, IconTrash } from "@tabler/icons-react";
|
import { IconEye, IconMessage, IconSearch } from "@tabler/icons-react";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
@ -30,41 +30,13 @@ interface Ticket {
|
|||||||
status: string;
|
status: string;
|
||||||
message: Message[];
|
message: Message[];
|
||||||
}
|
}
|
||||||
interface TicketDetails {
|
|
||||||
ticket_id: string;
|
|
||||||
category_of_request: string;
|
|
||||||
nature_of_request: string;
|
|
||||||
additional_info: string;
|
|
||||||
message : string;
|
|
||||||
created_date: string;
|
|
||||||
|
|
||||||
}
|
|
||||||
export default function Page() {
|
export default function Page() {
|
||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [tickets, setTickets] = useState<Ticket[]>([]);
|
const [tickets, setTickets] = useState<Ticket[]>([]);
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [filteredTickets, setFilteredTickets] = useState<Ticket[]>([]);
|
const [filteredTickets, setFilteredTickets] = useState<Ticket[]>([]);
|
||||||
const [activeMessages, setActiveMessages] = useState<Message[] | null>(null);
|
const [activeMessages, setActiveMessages] = useState<Message[] | null>(null);
|
||||||
const [ticketDetails, setTicketDetails] = useState<TicketDetails| null>(null);
|
|
||||||
const [detailsOpened, { open: openDetails, close: closeDetails }] = useDisclosure(false);
|
|
||||||
|
|
||||||
const handleOpenDetails = async (ticketId: string) => {
|
|
||||||
try {
|
|
||||||
const response = await axios.get<TicketDetails>(`/api/ticket/${ticketId}`); // Assuming API provides details
|
|
||||||
setTicketDetails(response.data);
|
|
||||||
openDetails();
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.error("Failed to fetch ticket details:", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// For parsing additional_info
|
|
||||||
const parseAdditionalInfo = (info: string) => {
|
|
||||||
return info.split(", ").map((item) => {
|
|
||||||
const [key, value] = item.split(": ");
|
|
||||||
return { key: key.trim(), value: value?.trim() || "" };
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Sort and filter tickets based on the time
|
// Sort and filter tickets based on the time
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -121,7 +93,7 @@ export default function Page() {
|
|||||||
onClick={() => handleOpenMessage(ticket.message)}
|
onClick={() => handleOpenMessage(ticket.message)}
|
||||||
>
|
>
|
||||||
<Tooltip label="Message">
|
<Tooltip label="Message">
|
||||||
<IconMessage />
|
<IconMessage/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Group>
|
</Group>
|
||||||
@ -129,21 +101,9 @@ export default function Page() {
|
|||||||
|
|
||||||
<Table.Td>
|
<Table.Td>
|
||||||
<Group>
|
<Group>
|
||||||
<ActionIcon variant="subtle"
|
<ActionIcon variant="subtle">
|
||||||
onClick={() => handleOpenDetails(ticket.ticket_id)}
|
|
||||||
>
|
|
||||||
<Tooltip label="Details of the Ticket">
|
<Tooltip label="Details of the Ticket">
|
||||||
<IconEye />
|
<IconEye/>
|
||||||
</Tooltip>
|
|
||||||
</ActionIcon>
|
|
||||||
</Group>
|
|
||||||
</Table.Td>
|
|
||||||
<Table.Td>
|
|
||||||
<Group>
|
|
||||||
<ActionIcon variant="subtle"
|
|
||||||
>
|
|
||||||
<Tooltip label="Delete the Ticket">
|
|
||||||
<IconTrash/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Group>
|
</Group>
|
||||||
@ -193,7 +153,7 @@ export default function Page() {
|
|||||||
</Table>
|
</Table>
|
||||||
|
|
||||||
<Modal opened={opened} onClose={close} title="Message">
|
<Modal opened={opened} onClose={close} title="Message">
|
||||||
<Flex direction="column" gap="md">
|
<Flex direction="column" gap="sm">
|
||||||
{activeMessages?.map((msg, index) => (
|
{activeMessages?.map((msg, index) => (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
@ -212,33 +172,6 @@ export default function Page() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal opened={detailsOpened} onClose={closeDetails}>
|
|
||||||
{ticketDetails ? (
|
|
||||||
<Flex direction="column" gap="md">
|
|
||||||
<div><strong>Ticket ID:</strong> {ticketDetails.ticket_id}</div>
|
|
||||||
<div><strong>Category of Complaint:</strong> {ticketDetails.category_of_request}</div>
|
|
||||||
<div><strong>Description:</strong> {ticketDetails.nature_of_request}</div>
|
|
||||||
{/* <div><strong>Additional Information:</strong> {ticketDetails.additional_info}</div> */}
|
|
||||||
{/* Additional Info Table */}
|
|
||||||
<div><strong>Additional Info:</strong></div>
|
|
||||||
<Table withTableBorder withColumnBorders highlightOnHover>
|
|
||||||
<Table.Tbody>
|
|
||||||
{parseAdditionalInfo(ticketDetails.additional_info).map((item, index) => (
|
|
||||||
<Table.Tr key={index}>
|
|
||||||
<Table.Td>{item.key}</Table.Td>
|
|
||||||
<Table.Td>{item.value}</Table.Td>
|
|
||||||
</Table.Tr>
|
|
||||||
))}
|
|
||||||
</Table.Tbody>
|
|
||||||
</Table>
|
|
||||||
<div><strong>Message:</strong> {ticketDetails.message}</div>
|
|
||||||
<div><strong>Created Date:</strong> {ticketDetails.created_date}</div>
|
|
||||||
<Button onClick={closeDetails} mt="sm">Close</Button>
|
|
||||||
</Flex>
|
|
||||||
) : (
|
|
||||||
<p>Loading details...</p>
|
|
||||||
)}
|
|
||||||
</Modal>
|
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user