From f26027f00a915a94e874674692117e3b0bcdbbef Mon Sep 17 00:00:00 2001 From: Ikki Date: Sun, 10 Nov 2024 11:03:20 +0530 Subject: [PATCH] ticket-feature --- .../components/Pages/ConfirmationMessage.jsx | 25 +++++ .../components/Pages/TicketDetailModal.jsx | 46 ++++++++ .../components/Pages/TicketFilters.jsx | 42 +++++++ .../components/Pages/TicketForm.jsx | 104 ++++++++++++++++++ .../components/Pages/TicketList.jsx | 60 ++++++++++ .../components/Pages/TicketUser.jsx | 95 ++++++++++++++++ .../components/Pages/Ticketbanner.jsx | 22 ++++ frontend/src/MainContent.jsx | 3 +- 8 files changed, 396 insertions(+), 1 deletion(-) create mode 100644 frontend/src/AgroShopAI/components/Pages/ConfirmationMessage.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/TicketDetailModal.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/TicketFilters.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/TicketForm.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/TicketList.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/TicketUser.jsx create mode 100644 frontend/src/AgroShopAI/components/Pages/Ticketbanner.jsx diff --git a/frontend/src/AgroShopAI/components/Pages/ConfirmationMessage.jsx b/frontend/src/AgroShopAI/components/Pages/ConfirmationMessage.jsx new file mode 100644 index 00000000..4eb785dc --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/ConfirmationMessage.jsx @@ -0,0 +1,25 @@ +import React from "react"; + +export default function ConfirmationMessage({ + showConfirmation, + newTicketId, + setShowConfirmation, +}) { + return ( + showConfirmation && ( +
+

Ticket Submitted Successfully!

+

Your ticket ID is: {newTicketId}

+ +
+ ) + ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/TicketDetailModal.jsx b/frontend/src/AgroShopAI/components/Pages/TicketDetailModal.jsx new file mode 100644 index 00000000..de963499 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/TicketDetailModal.jsx @@ -0,0 +1,46 @@ +import React from "react"; + +export default function TicketDetailModal({ + selectedTicket, + setSelectedTicket, +}) { + return ( + selectedTicket && ( +
+
+
+

+ Ticket Details +

+
+

+ ID: {selectedTicket.id} +
+ Subject: {selectedTicket.subject} +
+ Status: {selectedTicket.status} +
+ Priority: {selectedTicket.priority} +
+ Description: {selectedTicket.description} +
+ Created At: {selectedTicket.createdAt} +
+ Agent: {selectedTicket.agent} +

+
+ +
+
+
+ ) + ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/TicketFilters.jsx b/frontend/src/AgroShopAI/components/Pages/TicketFilters.jsx new file mode 100644 index 00000000..c9440fca --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/TicketFilters.jsx @@ -0,0 +1,42 @@ +import React from "react"; + +export default function TicketFilters({ + filterStatus, + setFilterStatus, + filterPriority, + setFilterPriority, + searchTerm, + setSearchTerm, +}) { + return ( +
+ + + setSearchTerm(e.target.value)} + className="rounded-md border-gray-300 shadow-sm focus:border-green-500 focus:ring-green-500" + /> +
+ ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/TicketForm.jsx b/frontend/src/AgroShopAI/components/Pages/TicketForm.jsx new file mode 100644 index 00000000..434e10f6 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/TicketForm.jsx @@ -0,0 +1,104 @@ +import React, { useState } from "react"; + +export default function TicketForm({ + newTicket, + handleInputChange, + handleSubmit, +}) { + const [selectedFile, setSelectedFile] = useState(null); // To store the selected file + + const handleFileChange = (e) => { + const file = e.target.files[0]; // Get the first file selected by the user + if (file) { + setSelectedFile(file); // Store the file in state + } + }; + + return ( +
+

+ Create New Support Ticket +

+
+
+ + +
+
+ + +
+
+ + +
+
+ + + {selectedFile && ( +
+ Selected File: {selectedFile.name} +
+ )} +
+ +
+
+ ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/TicketList.jsx b/frontend/src/AgroShopAI/components/Pages/TicketList.jsx new file mode 100644 index 00000000..bf084ca7 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/TicketList.jsx @@ -0,0 +1,60 @@ +import React from "react"; + +export default function TicketList({ filteredTickets, setSelectedTicket }) { + return ( +
+ + + + + + + + + + + + + {filteredTickets.map((ticket) => ( + setSelectedTicket(ticket)} + className="cursor-pointer hover:bg-gray-50" + > + + + + + + + + ))} + +
+ ID + + Subject + + Status + + Priority + + Agent + + Created At +
+ {ticket.id} + + {ticket.subject} + + {ticket.status} + + {ticket.priority} + + {ticket.agent} + + {ticket.createdAt} +
+
+ ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/TicketUser.jsx b/frontend/src/AgroShopAI/components/Pages/TicketUser.jsx new file mode 100644 index 00000000..6a239a47 --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/TicketUser.jsx @@ -0,0 +1,95 @@ +import React, { useState, useEffect } from "react"; +import TicketForm from "./TicketForm"; +import ConfirmationMessage from "./ConfirmationMessage"; +import TicketFilters from "./TicketFilters"; +import TicketList from "./TicketList"; +import TicketDetailModal from "./TicketDetailModal"; +import HeaderBanner from "./Ticketbanner"; +// Dummy ticket data +const dummyTickets = [ + { id: 'T001', subject: 'Order Delay', status: 'Open', priority: 'High', agent: 'John Doe', createdAt: '2023-05-10 09:30' }, + { id: 'T002', subject: 'Product Inquiry', status: 'In-Progress', priority: 'Medium', agent: 'Jane Smith', createdAt: '2023-05-09 14:15' }, + { id: 'T003', subject: 'Refund Request', status: 'Resolved', priority: 'Low', agent: 'Mike Johnson', createdAt: '2023-05-08 11:45' }, +]; + +export default function SupportPage() { + const [newTicket, setNewTicket] = useState({ + subject: "", + description: "", + priority: "Low", + }); + const [showConfirmation, setShowConfirmation] = useState(false); + const [newTicketId, setNewTicketId] = useState(null); + const [filterStatus, setFilterStatus] = useState("All"); + const [filterPriority, setFilterPriority] = useState("All"); + const [searchTerm, setSearchTerm] = useState(""); + const [tickets, setTickets] = useState(dummyTickets); // Set initial tickets from dummyTickets + const [selectedTicket, setSelectedTicket] = useState(null); + const [selectedFile, setSelectedFile] = useState(null); // To store the selected file + + const handleInputChange = (e) => { + setNewTicket({ ...newTicket, [e.target.name]: e.target.value }); + }; + + const handleFileChange = (e) => { + const file = e.target.files[0]; + if (file) { + setSelectedFile(file); // Store the selected file in state + } + }; + + const handleSubmit = (e) => { + e.preventDefault(); + const newTicketData = { + ...newTicket, + id: `T${String(tickets.length + 1).padStart(3, '0')}`, // Generate a readable ticket ID + status: "Open", // Default status + agent: "Unassigned", // Placeholder for agent + createdAt: new Date().toLocaleString(), // Current date and time + file: selectedFile, // Attach the file to the new ticket + }; + setTickets([newTicketData, ...tickets]); + setNewTicketId(newTicketData.id); + setShowConfirmation(true); + setNewTicket({ subject: "", description: "", priority: "Low" }); + setSelectedFile(null); // Clear the file after submission + }; + + const filteredTickets = tickets.filter((ticket) => { + const statusMatch = + filterStatus === "All" || ticket.status === filterStatus; + const priorityMatch = + filterPriority === "All" || ticket.priority === filterPriority; + const searchMatch = + ticket.subject.toLowerCase().includes(searchTerm.toLowerCase()) || + ticket.id.toString().includes(searchTerm); + return statusMatch && priorityMatch && searchMatch; + }); + + return ( +
+ + + + + + +
+ ); +} diff --git a/frontend/src/AgroShopAI/components/Pages/Ticketbanner.jsx b/frontend/src/AgroShopAI/components/Pages/Ticketbanner.jsx new file mode 100644 index 00000000..607666ab --- /dev/null +++ b/frontend/src/AgroShopAI/components/Pages/Ticketbanner.jsx @@ -0,0 +1,22 @@ +import React from "react"; + +const HeaderBanner = () => { + return ( +
+
+
+

Welcome to Support Center

+

+ We're here to help you. Submit your tickets and get fast support! +

+
+ +
+
+
+ ); +}; + +export default HeaderBanner; diff --git a/frontend/src/MainContent.jsx b/frontend/src/MainContent.jsx index ab665580..8428dfb8 100644 --- a/frontend/src/MainContent.jsx +++ b/frontend/src/MainContent.jsx @@ -98,6 +98,7 @@ import BundledProducts from './AgroShopAI/components/Pages/BulkPage'; import TrendingProductsPage from './AgroShopAI/components/Pages/Trending'; import AffiliateProgramPage from './AgroShopAI/components/Pages/Affiliate'; +import SupportPage from './AgroShopAI/components/Pages/TicketUser'; @@ -219,7 +220,7 @@ const MainContent = () => { } /> - + } /> } />