Skip to content

shirinmjr/nextjs-ticketing-system

Repository files navigation

Ticketing Project logo

Ticket Management App


This is a full CRUD NextJs App
ticket-app repository

📝 Table of Contents

🧐 About

This is a Next.js project bootstrapped with create-next-app. A Full CRUD NextJS app uses mongoDB (atlas connection) to create and manage help desk tickets. This app uses tailwind for styling.

HOMEPAGE view

CREATE NEW TICKET view

UPDATE TICKET view

🏁 Getting Started

Prerequisites: What things you need to install the software and how to install them.

⛏️ Tools

🚀 Start Here

Installing

You can run this application locally by running npm i

Running

in the main folder where you have package.json run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

make sure you have the compatible version of the NodeJS if not run

nvn use 18.7.3

You can start editing the page by modifying app/page.js. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Database

To run this app you need create an account on Atlas. You can create a free cluster and collection(Database) to store and retrieve your data. Make sure your cluster is accessible via any ip address(not secure only recommended fot experimental projects):

Store this in your env.local and use it to connect with your cluster. Replace admin with your username created for the cluster and password with your password. Do not check in or share your credentials!

mongodb+srv://admin:<password>@cluster0.x9eegis.mongodb.net/?retryWrites=true&w=majority

you can manage data in the Atlas platform if you need to.

🔧 Under the Hood

In the Ticket Page user can:

  • Create/record a new ticket including title, description, category priority, progress and status
    • "Title" is a text field and "Description" is a text area
    • Category and Status are dropdowns
    • Progress bar is made of 2 div(s)showing the progress with the help of CSS
    style={{ width: `${progress}%` }}>

Nav Bar added tp layout.js, so it's available/visible on all the pages

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body className={inter.className}>
        <div>
          <Nav />
            {children}
        </div>
      </body>
    </html>
  );
}

HomePage

Homepage or Dashboard displays all the tickets based on unique categories

  const { tickets } = await getTickets();

  const uniqueCategories = [
    ...new Set(tickets?.map(({ category }) => category)),
  ];

getTickets() is a GET call getting all the tickets from Atlas. Dashboard displays them by filtering them based on their unique category and generates <TicketCard/> component for each ticket

{tickets
    .filter((ticket) => ticket.category === uniqueCategory)
    .map((filteredTicket, _index) => (
    <TicketCard
        id={_index}
        key={_index}
        ticket={filteredTicket}
    />
    ))}

(models) holds the Schema for Ticket Database

import mongoose, { Schema } from "mongoose";

mongoose.connect(process.env.MONGODB_URI);
mongoose.Promise = global.Promise;

const ticketSchema = new Schema(
    {
        title: String,
        description: String,
        category: String,
        priority: Number,
        progress: Number,
        status: String,
        active: Boolean,
    },
    {
        timestamps: true,
    }
);

const Ticket = mongoose.models.Ticket || mongoose.model("Ticket", ticketSchema);

export default Ticket;

API calls

All API Calls are happening in /api directory in route.js.

To run CRUD for each Ticket we can create a dynamic route under api folder. ex:api/Tickets/[id]

✍️ Authors

  • @shirinmjr - Built this as an experimental project

🎉 Acknowledgements

Releases

No releases published

Packages

No packages published