Skip to content

Commit b2322b3

Browse files
authored
[CRM/OA][Fullstack] - Repository Cleanup (#285)
* repo cleanup * prettier * lint
1 parent 23c76a0 commit b2322b3

10 files changed

Lines changed: 41 additions & 32 deletions

File tree

docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ services:
3030
build:
3131
context: ./src/ws/
3232
dockerfile: Dockerfile
33+
env_file:
34+
- .env
3335
ports:
3436
- 8080:8080
3537
volumes:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"dev:migrate": "npx prisma migrate dev",
88
"dev:start": "next dev",
9+
"dev:ws": "node --env-file .env src/ws/index.js",
910
"dev": "npm run dev:migrate && npm run dev:start",
1011
"build": "prisma generate && next build",
1112
"start": "next start",

src/lib/components/core/Sidebar.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { Home, File, Users, Book, Archive, Settings, ChevronDown } from 'lucide-react';
3+
import { Home, File, Users, Settings, ChevronDown } from 'lucide-react';
44
import { useAuth } from '@/lib/auth/auth-context';
55
import Image from 'next/image';
66
import useOnboardingState from '@/lib/hooks/useOnboardingState';
@@ -694,16 +694,6 @@ const sidebarMenuItems = [
694694
url: '/crm/positions',
695695
icon: Users,
696696
},
697-
{
698-
title: 'Live Assessments',
699-
url: '#',
700-
icon: Book,
701-
},
702-
{
703-
title: 'Archived Assessments',
704-
url: '#',
705-
icon: Archive,
706-
},
707697
];
708698

709699
export function Sidebar() {

src/lib/components/modal/LostConnectionModal.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ export type LostConnectionModalProps = {
99
export function LostConnectionModal({ open, onOpenChange }: LostConnectionModalProps) {
1010
return (
1111
<Dialog open={open} onOpenChange={onOpenChange}>
12-
<DialogContent className="h-[180px] w-[340px] gap-4" showCloseButton={false}>
12+
<DialogContent
13+
className="h-[184px] w-[361px] gap-4"
14+
backgroundClassName="backdrop-blur-md"
15+
showCloseButton={false}
16+
>
1317
<VisuallyHidden>
1418
<DialogTitle>Network Disconnected</DialogTitle>
1519
</VisuallyHidden>
Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
import { Button } from '@/lib/components/ui/Button';
2+
import { Dialog, DialogContent, DialogTitle } from '@/lib/components/ui/Modal';
3+
import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
24

35
type WindowUnfocusedModalProps = {
46
open: boolean;
57
onAcknowledge: () => void;
68
};
79

810
export function WindowUnfocusedModal({ open, onAcknowledge }: WindowUnfocusedModalProps) {
9-
if (!open) return null;
10-
1111
return (
12-
<div className="fixed inset-0 z-50 flex items-center justify-center bg-white/25 p-4 backdrop-blur-md">
13-
<div className="bg-sarge-gray-0 border-sarge-gray-200 flex w-full max-w-[380px] flex-col items-center gap-4 rounded-lg border px-8 py-7 text-center shadow-lg">
14-
<div className="space-y-3">
15-
<h2 className="text-sarge-gray-900 text-base leading-snug font-bold">
16-
You can&apos;t unfocus your assessment window during the exam
17-
</h2>
18-
<p className="text-sarge-gray-600 text-sm">The admin has been notified.</p>
12+
<Dialog open={open} onOpenChange={() => {}}>
13+
<DialogContent
14+
className="h-[184px] w-[361px] gap-4"
15+
backgroundClassName="bg-white/25 backdrop-blur-md"
16+
showCloseButton={false}
17+
>
18+
<VisuallyHidden>
19+
<DialogTitle>Window Unfocused</DialogTitle>
20+
</VisuallyHidden>
21+
<div className="flex h-full flex-col items-center justify-center gap-4 px-6 text-center">
22+
<div className="space-y-1">
23+
<p className="text-md font-semibold tracking-wide">
24+
You can&apos;t unfocus your window during the exam
25+
</p>
26+
<p className="text-sm">The admin has been notified.</p>
27+
</div>
28+
<Button className="h-9 min-w-28 px-5" onClick={onAcknowledge}>
29+
I understand
30+
</Button>
1931
</div>
20-
<Button className="h-9 min-w-28 px-5" onClick={onAcknowledge}>
21-
I understand
22-
</Button>
23-
</div>
24-
</div>
32+
</DialogContent>
33+
</Dialog>
2534
);
2635
}

src/lib/components/ui/Modal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ function DialogOverlay({
4040

4141
function DialogContent({
4242
className,
43+
backgroundClassName,
4344
children,
4445
showCloseButton = true,
4546
...props
4647
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
4748
showCloseButton?: boolean;
49+
backgroundClassName?: string;
4850
}) {
4951
return (
5052
<DialogPortal data-slot="dialog-portal">
51-
<DialogOverlay />
53+
<DialogOverlay className={backgroundClassName} />
5254
<DialogPrimitive.Content
5355
data-slot="dialog-content"
5456
className={cn(

src/lib/hooks/useHeartbeat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import useWebSocket from 'react-use-websocket';
22
import { ReadyState } from 'react-use-websocket';
33

4-
const WS_URL = 'ws://localhost:8080';
4+
const WS_URL = process.env.NEXT_PUBLIC_WS_URL ?? 'ws://localhost:8080';
55

66
export function useHeartbeat(token: string | null) {
77
const ws = useWebSocket(token ? `${WS_URL}?token=${token}` : null, {

src/lib/utils/token.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { SignJWT } from 'jose';
22

33
export async function generateToken(email: string) {
4-
const secret = new TextEncoder().encode('SECRET');
4+
const secret = new TextEncoder().encode(process.env.JWT_SECRET);
55

66
const jwt = await new SignJWT({ email })
77
.setProtectedHeader({ alg: 'HS256' })

src/ws/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { WebSocketServer } from 'ws';
22
import { jwtVerify } from 'jose';
33

44
const ws = new WebSocketServer({ port: 8080 });
5-
const secret = new TextEncoder().encode('SECRET');
5+
const secret = new TextEncoder().encode(process.env.JWT_SECRET);
66

77
console.log('Sarge WS server listening on 8080');
88

@@ -46,6 +46,7 @@ ws.on('connection', async (socket, request) => {
4646
clients.set(payload.candidateEmail, socket);
4747
} catch {
4848
socket.close(1008, 'Unauthorized');
49+
console.log(`[${new Date().toISOString()}] Unauthorized connection. Closing.`);
4950
return;
5051
}
5152

src/ws/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"main": "index.js",
66
"type": "module",
77
"scripts": {
8-
"start": "node index.js",
9-
"dev": "nodemon index.js"
8+
"start": "node --env-file ../../.env index.js",
9+
"dev": "nodemon --exec 'node --env-file ../../.env' index.js"
1010
},
1111
"keywords": [],
1212
"author": "",

0 commit comments

Comments
 (0)