Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 next release #181

Merged
merged 12 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ Check out the getting started guide if this is the first time you've used Pepper
version: "3.1"

services:
postgres:
peppermint_postgres:
container_name: peppermint_postgres
profiles:
- prod
- dev
- test
container_name: postgres
image: postgres:latest
restart: always
ports:
- 5432:5432
volumes:
- pgdata:/var/lib/postgresql/data
environment:
Expand All @@ -60,13 +62,16 @@ services:
POSTGRES_DB: peppermint

peppermint:
profiles:
- prod
container_name: peppermint
image: pepperlabs/peppermint:latest
ports:
- 5001:5001
- 3000:3000
- 5003:5003
restart: always
depends_on:
- peppermint_postgres
profiles:
- prod
depends_on:
- postgres
healthcheck:
Expand All @@ -75,20 +80,19 @@ services:
timeout: 10s
retries: 3
environment:
PORT: 5001
DB_USERNAME: peppermint
DB_PASSWORD: 1234
DB_HOST: postgres
DB_USERNAME: "peppermint"
DB_PASSWORD: "1234"
DB_HOST: "peppermint_postgres"
SECRET: 'peppermint4life'


volumes:
pgdata:
```

Once this is completed then you can go to your base_url which was added to the compose file and login.

The default login credentials are

```
[email protected]
1234
Expand Down Expand Up @@ -123,11 +127,8 @@ Give a ⭐️ if this project helped you!

## Star History


[![Star History Chart](https://api.star-history.com/svg?repos=Peppermint-Lab/peppermint&type=Date)](https://star-history.com/#Peppermint-Lab/peppermint&Date)



## Author

👤 **Jack Andrews**
Expand Down
3 changes: 2 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
"dependencies": {
"@fastify/cookie": "^9.0.4",
"@fastify/cors": "^8.3.0",
"@fastify/rate-limit": "^9.0.0",
"@fastify/session": "^10.4.0",
"@fastify/swagger": "^8.10.0",
"@prisma/client": "^5.2.0",
"@prisma/client": "5.2.0",
"axios": "^1.5.0",
"bcrypt": "^5.0.1",
"dotenv": "^16.0.0",
Expand Down
14 changes: 14 additions & 0 deletions apps/api/src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ export function authRoutes(fastify: FastifyInstance) {
}
);

// Delete a user
fastify.delete(
"/api/v1/auth/user/:id",
async (request: FastifyRequest, reply: FastifyReply) => {
const { id } = request.params as { id: string };

await prisma.user.delete({
where: { id },
});

reply.send({ success: true });
}
);

// User Profile
fastify.get(
"/api/v1/auth/profile",
Expand Down
18 changes: 15 additions & 3 deletions apps/api/src/controllers/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ export function ticketRoutes(fastify: FastifyInstance) {
"/api/v1/ticket/create",

async (request: FastifyRequest, reply: FastifyReply) => {
const { name, company, detail, title, priority, email, engineer }: any =
request.body;
const {
name,
company,
detail,
title,
priority,
email,
engineer,
type,
}: any = request.body;

console.log(request.body);

const ticket: any = await prisma.ticket.create({
data: {
Expand All @@ -21,10 +31,11 @@ export function ticketRoutes(fastify: FastifyInstance) {
detail,
priority: priority ? priority : "low",
email,
type: type ? type.toLowerCase() : "support",
client:
company !== undefined
? {
connect: { id: company.id },
connect: { id: company.id || company },
}
: undefined,
fromImap: false,
Expand Down Expand Up @@ -62,6 +73,7 @@ export function ticketRoutes(fastify: FastifyInstance) {
reply.status(200).send({
message: "Ticket created correctly",
success: true,
id: ticket.id,
});
}
);
Expand Down
7 changes: 6 additions & 1 deletion apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ server.register(require("@fastify/swagger"), {
},
});

server.register(import("@fastify/rate-limit"), {
max: 20,
timeWindow: "1 minute",
});

// register all routes
registerRoutes(server);

Expand Down Expand Up @@ -122,7 +127,7 @@ const start = async () => {

client.capture({
event: "server_started",
distinctId: "api_server",
distinctId: "uuid",
});

await client.shutdownAsync();
Expand Down
5 changes: 5 additions & 0 deletions apps/api/src/prisma/migrations/20231125042344_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- CreateEnum
CREATE TYPE "TicketType" AS ENUM ('bug', 'feature', 'support', 'incident', 'service', 'maintenance', 'access', 'feedback');

-- AlterTable
ALTER TABLE "Ticket" ADD COLUMN "type" "TicketType" NOT NULL DEFAULT 'support';
12 changes: 12 additions & 0 deletions apps/api/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ model Ticket {
fromImap Boolean
Number Int @default(autoincrement())
status TicketStatus @default(needs_support)
type TicketType @default(support)

TicketFile TicketFile[]
Comment Comment[]
Expand Down Expand Up @@ -298,3 +299,14 @@ enum TicketStatus {
in_review
done
}

enum TicketType {
bug
feature
support
incident
service
maintenance
access
feedback
}
55 changes: 23 additions & 32 deletions apps/client/components/TicketViews/assigned.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment from "moment";
import { useRouter } from "next/router";
import React from "react";
import React, { useMemo } from "react";
import { useQuery } from "react-query";
import {
useFilters,
Expand Down Expand Up @@ -221,7 +221,7 @@ export default function AssignedTickets() {
const low = "bg-blue-100 text-blue-800";
const normal = "bg-green-100 text-green-800";

const columns = React.useMemo(
const columns = useMemo(
() => [
{
Header: "Type",
Expand All @@ -236,7 +236,7 @@ export default function AssignedTickets() {
Cell: ({ row, value }: any) => {
return (
<>
<span className="max-w-[240px] truncate">{value}</span>
<span className=" max-w-[240px] truncate">{value}</span>
</>
);
},
Expand All @@ -245,7 +245,19 @@ export default function AssignedTickets() {
Header: "Assignee",
accessor: "assignedTo.name",
id: "assignee",
Cell: ({ row, value }) => {
Cell: ({ row, value }: any) => {
return (
<>
<span className="w-[80px] truncate">{value ? value : "n/a"}</span>
</>
);
},
},
{
Header: "Client",
accessor: "client.name",
id: "client",
Cell: ({ row, value }: any) => {
return (
<>
<span className="w-[80px] truncate">{value ? value : "n/a"}</span>
Expand Down Expand Up @@ -274,7 +286,7 @@ export default function AssignedTickets() {
return (
<>
<span
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${badge}`}
className={`inline-flex items-center rounded-md justify-center w-1/2 px-2 py-1 text-xs font-medium ring-1 ring-inset ${badge}`}
>
{value}
</span>
Expand All @@ -284,28 +296,19 @@ export default function AssignedTickets() {
},
{
Header: "Status",
accessor: "priority",
accessor: "status",
id: "status",
Cell: ({ row, value }) => {
let p = value;
let badge;

if (p === "Low") {
badge = low;
}
if (p === "Normal") {
badge = normal;
}
if (p === "High") {
badge = high;
}

return (
<>
<span
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${badge}`}
>
{value}
<span className="inline-flex items-center rounded-md bg-yellow-50 px-2 py-1 text-xs font-medium text-yellow-700 ring-1 ring-inset ring-red-600/10">
{value === "needs_support" && <span>Needs Support</span>}
{value === "in_progress" && <span>In Progress</span>}
{value === "in_review" && <span>In Review</span>}
{value === "done" && <span>Done</span>}
</span>
</>
);
Expand All @@ -324,18 +327,6 @@ export default function AssignedTickets() {
);
},
},
// {
// Header: "",
// id: "actions",
// Cell: ({ row, value }) => {
// console.log(row)
// return (
// <>
// <Link href={`/tickets/${row.original.id}`}>View</Link>
// </>
// );
// },
// },
],
[]
);
Expand Down
Loading
Loading