Skip to content

Commit

Permalink
Merge pull request #178 from Peppermint-Lab/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
potts99 authored Nov 24, 2023
2 parents 1cae9e8 + debf27d commit 09bd85d
Show file tree
Hide file tree
Showing 24 changed files with 7,864 additions and 12,942 deletions.
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Exclude files and directories generated by the build process
node_modules/
dist/

# Exclude development and debugging files
.DS_Store
.vscode/

# # Exclude any sensitive or secret files
# .env
# .env.*

# Exclude any temporary or cache files
*.log
*.tmp
*.swp

lib/
.github
.yarn

apps/api/node_modules
apps/api/dist
apps/client/node_modules
26 changes: 3 additions & 23 deletions apps/api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,15 @@ services:
image: "postgres:11"
restart: unless-stopped
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
- POSTGRES_USER=pepppermint
- POSTGRES_PASSWORD=1234
- POSTGRES_DB=peppermint
container_name: "pg"
ports:
- '5432:5432'
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- internal

api:
build: .
container_name: api
restart: always
depends_on:
- pg
ports:
- "8090:8090"
environment:
- DATABASE_URL=postgres://postgres:postgres@pg:5432/postgres
- JWT_SECRET=secret
- PORT=8090
networks:
- internal

volumes:
postgres_data:

networks:
internal:
driver: bridge
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"imap": "^0.8.19",
"jsonwebtoken": "9.0.2",
"mailparser": "^3.6.5",
"posthog-node": "^3.1.3",
"prisma": "^5.6.0"
},
"prisma": {
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function authRoutes(fastify: FastifyInstance) {
});
}

//@ts-expect-error
const isPasswordValid = await bcrypt.compare(password, user!.password);

if (!isPasswordValid) {
Expand Down
20 changes: 17 additions & 3 deletions apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Fastify, { FastifyInstance } from "fastify";
import { getEmails } from "./lib/imap";

import { exec } from "child_process";
import { PostHog } from "posthog-node";
import { prisma } from "./prisma";
import { registerRoutes } from "./routes";

Expand Down Expand Up @@ -70,15 +71,15 @@ const start = async () => {
try {
// Run prisma generate and migrate commands before starting the server
await new Promise<void>((resolve, reject) => {
exec("npx prisma generate", (err, stdout, stderr) => {
exec("npx prisma migrate deploy", (err, stdout, stderr) => {
if (err) {
console.error(err);
reject(err);
}
console.log(stdout);
console.error(stderr);

exec("npx prisma migrate dev", (err, stdout, stderr) => {
exec("npx prisma generate", (err, stdout, stderr) => {
if (err) {
console.error(err);
reject(err);
Expand Down Expand Up @@ -107,11 +108,24 @@ const start = async () => {

await server.listen(
{ port: Number(port), host: "0.0.0.0" },
(err, address) => {
async (err, address) => {
if (err) {
console.error(err);
process.exit(1);
}

const client = new PostHog(
"phc_2gbpy3JPtDC6hHrQy35yMxMci1NY0fD1sttGTcPjwVf",

{ host: "https://app.posthog.com" }
);

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

await client.shutdownAsync();
console.info(`Server listening on ${address}`);
}
);
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/prisma/migrations/20231124180831_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ALTER COLUMN "password" DROP NOT NULL;
4 changes: 0 additions & 4 deletions apps/api/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ model User {
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
name String
<<<<<<<< HEAD:apps/api/src/prisma/schema.prisma
password String
========
password String?
>>>>>>>> next:packages/database/prisma/schema.prisma
email String @unique
image String?
emailVerified Boolean?
Expand Down
92 changes: 47 additions & 45 deletions apps/client/components/TicketViews/assigned.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,53 +142,55 @@ function Table({ columns, data }: any) {
</tbody>
</table>

<nav
className="bg-white px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6"
aria-label="Pagination"
>
<div className="hidden sm:block">
<div className="flex flex-row items-center flex-nowrap w-full space-x-2">
<span className="block text-sm font-medium text-gray-700 ">
Show
</span>
<div className="pl-4">
<select
id="location"
name="location"
className="block w-full h-10 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
value={pageSize}
onChange={(e) => {
setPageSize(Number(e.target.value));
}}
>
{[10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
{pageSize}
</option>
))}
</select>
{data.length > 10 && (
<nav
className="bg-white px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6"
aria-label="Pagination"
>
<div className="hidden sm:block">
<div className="flex flex-row items-center flex-nowrap w-full space-x-2">
<span className="block text-sm font-medium text-gray-700 ">
Show
</span>
<div className="pl-4">
<select
id="location"
name="location"
className="block w-full h-10 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
value={pageSize}
onChange={(e) => {
setPageSize(Number(e.target.value));
}}
>
{[10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
{pageSize}
</option>
))}
</select>
</div>
</div>
</div>
</div>
<div className="flex-1 flex justify-between sm:justify-end">
<button
className="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
type="button"
onClick={() => previousPage()}
disabled={!canPreviousPage}
>
Previous
</button>
<button
className="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
type="button"
onClick={() => nextPage()}
disabled={!canNextPage}
>
Next
</button>
</div>
</nav>
<div className="flex-1 flex justify-between sm:justify-end">
<button
className="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
type="button"
onClick={() => previousPage()}
disabled={!canPreviousPage}
>
Previous
</button>
<button
className="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
type="button"
onClick={() => nextPage()}
disabled={!canNextPage}
>
Next
</button>
</div>
</nav>
)}
</div>
</div>
</div>
Expand Down
92 changes: 47 additions & 45 deletions apps/client/components/TicketViews/closed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,53 +139,55 @@ function Table({ columns, data }: any) {
</tbody>
</table>

<nav
className="bg-white px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6"
aria-label="Pagination"
>
<div className="hidden sm:block">
<div className="flex flex-row items-center flex-nowrap w-full space-x-2">
<span className="block text-sm font-medium text-gray-700 ">
Show
</span>
<div className="pl-4">
<select
id="location"
name="location"
className="block w-full h-10 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
value={pageSize}
onChange={(e) => {
setPageSize(Number(e.target.value));
}}
>
{[10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
{pageSize}
</option>
))}
</select>
{data.length > 10 && (
<nav
className="bg-white px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6"
aria-label="Pagination"
>
<div className="hidden sm:block">
<div className="flex flex-row items-center flex-nowrap w-full space-x-2">
<span className="block text-sm font-medium text-gray-700 ">
Show
</span>
<div className="pl-4">
<select
id="location"
name="location"
className="block w-full h-10 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
value={pageSize}
onChange={(e) => {
setPageSize(Number(e.target.value));
}}
>
{[10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
{pageSize}
</option>
))}
</select>
</div>
</div>
</div>
</div>
<div className="flex-1 flex justify-between sm:justify-end">
<button
className="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
type="button"
onClick={() => previousPage()}
disabled={!canPreviousPage}
>
Previous
</button>
<button
className="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
type="button"
onClick={() => nextPage()}
disabled={!canNextPage}
>
Next
</button>
</div>
</nav>
<div className="flex-1 flex justify-between sm:justify-end">
<button
className="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
type="button"
onClick={() => previousPage()}
disabled={!canPreviousPage}
>
Previous
</button>
<button
className="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50"
type="button"
onClick={() => nextPage()}
disabled={!canNextPage}
>
Next
</button>
</div>
</nav>
)}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 09bd85d

Please sign in to comment.