Skip to content
Open
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
6 changes: 4 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ DATABASE_URL=postgresql://${DB_USER}:${DB_PASSWORD}@localhost:5432/${DB_NAME}

EMAIL_DOMAIN=

INTERNAL_API_SECRET=
INTERNAL_API_URL=
INTERNAL_API_SECRET=secret
# NOTE(laith): In local dev "web" runs on the host (next dev) while ws/scheduler run as containers
# so they reach web via host.docker.internal rather than a compose service name
INTERNAL_API_URL=http://host.docker.internal:3000
9 changes: 9 additions & 0 deletions .github/workflows/publish-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ jobs:
tags: |
ghcr.io/${{ github.repository_owner }}/sarge-ws:latest
ghcr.io/${{ github.repository_owner }}/sarge-ws:${{ github.sha }}
- name: Build and push scheduler image
uses: docker/build-push-action@v5
with:
context: src/scheduler
file: src/scheduler/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/sarge-scheduler:latest
ghcr.io/${{ github.repository_owner }}/sarge-scheduler:${{ github.sha }}
10 changes: 10 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ services:
volumes:
- ./src/ws:/src/ws
- /src/ws/node_modules
scheduler:
container_name: sarge_dev_scheduler
build:
context: ./src/scheduler/
dockerfile: Dockerfile
env_file:
- .env
volumes:
- ./src/scheduler:/src/scheduler
- /src/scheduler/node_modules

volumes:
postgres_data:
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"cmdk": "^1.1.1",
"jose": "^6.2.2",
"lucide-react": "^0.548.0",
"luxon": "^3.7.2",
"next": "15.5.7",
"prisma": "6.14.0",
"react": "19.1.2",
Expand All @@ -77,6 +78,7 @@
"devDependencies": {
"@eslint/eslintrc": "^3",
"@tailwindcss/postcss": "^4",
"@types/luxon": "^3.7.1",
"@types/node": "^22",
"@types/react": "^19",
"@types/react-dom": "^19",
Expand Down
17 changes: 17 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions prisma/seed-data/assessment.seed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AssessmentStatus } from '@/generated/prisma';
import { getDateToEOD } from '@/lib/utils/date.utils';

export const assessmentsData: Array<{
id: string;
Expand All @@ -16,7 +17,7 @@ export const assessmentsData: Array<{
assessmentTemplateId: 'assessment_template_general_001',
assignedAt: new Date('2026-04-06T14:00:00Z'),
submittedAt: new Date('2026-04-12T17:30:00Z'),
deadline: new Date('2026-04-13T03:59:59Z'),
deadline: new Date(getDateToEOD('2026-04-12')),
reviewerIds: ['user_laith_taher_001', 'user_brad_derby_001'],
applicationStatus: 'GRADED',
},
Expand All @@ -26,8 +27,18 @@ export const assessmentsData: Array<{
assessmentTemplateId: 'assessment_template_general_001',
assignedAt: new Date('2026-04-06T14:00:00Z'),
submittedAt: null,
deadline: new Date('2026-04-13T03:59:59Z'),
deadline: new Date(getDateToEOD('2026-04-12')),
reviewerIds: [],
applicationStatus: 'NOT_STARTED',
},
{
id: 'assessment_anzhuo_001',
candidateId: 'cand_anzhuo_wang_001',
assessmentTemplateId: 'assessment_template_general_001',
assignedAt: new Date('2026-04-06T14:00:00Z'),
submittedAt: null,
deadline: new Date(getDateToEOD('2026-04-12')),
reviewerIds: [],
applicationStatus: 'EXPIRED',
},
];
15 changes: 13 additions & 2 deletions src/app/(web)/(oa)/assessment/[assessmentId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { use, useEffect, useState } from 'react';
import useAssessment from '@/lib/hooks/useAssessment';
import AssessmentIntro from '@/lib/components/assessment-flow/AssessmentIntro';
import AssessmentOutro from '@/lib/components/assessment-flow/AssessmentOutro';
import AssessmentExpired from '@/lib/components/assessment-flow/AssessmentExpired';
import AssessmentSidebar from '@/lib/components/assessment-flow/AssessmentSidebar';
import AssessmentNavbar from '@/lib/components/assessment-flow/AssessmentNavbar';
import AssessmentContent from '@/lib/components/assessment-flow/AssessmentContent';
Expand All @@ -30,8 +31,7 @@ export default function AssessmentPage({ params }: { params: Promise<{ assessmen
!assessment.isLoading &&
!assessment.error &&
isConnected &&
assessment.phase !== 'intro' &&
assessment.phase !== 'outro';
assessment.phase === 'assessment';

useEffect(() => {
if (isExamActive && isWindowUnfocused) {
Expand All @@ -52,6 +52,17 @@ export default function AssessmentPage({ params }: { params: Promise<{ assessmen
</div>
);

if (assessment.phase === 'expired' && assessment.assessment) {
return (
<div className="flex h-screen w-full flex-col overflow-hidden">
<AssessmentNavbar candidateName={assessment.candidateName} />
<div className="flex-1 overflow-y-auto">
<AssessmentExpired assessment={assessment.assessment} />
</div>
</div>
);
}

if (assessment.phase === 'intro' && assessment.assessment) {
return (
<div className="flex h-screen w-full flex-col overflow-hidden">
Expand Down
32 changes: 21 additions & 11 deletions src/app/(web)/crm/positions/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ import { Button } from '@/lib/components/ui/Button';
import { CandidateTable } from '@/lib/components/core/CandidateTable';
import CreateCandidateModal from '@/lib/components/modal/CreateCandidateModal';
import UploadCSVModal from '@/lib/components/modal/UploadCSVModal';
import SendAssessmentModal from '@/lib/components/modal/SendAssessmentModal';
import useCandidates from '@/lib/hooks/useCandidates';
import { Search } from '@/lib/components/core/Search';
import { Tabs, TabsContent, TabsList, UnderlineTabsTrigger } from '@/lib/components/ui/Tabs';
import { Plus, ArrowUpDown, SlidersHorizontal, Mail } from 'lucide-react';
import { use, useState } from 'react';
import { use } from 'react';
import useSearch from '@/lib/hooks/useSearch';
import Breadcrumbs from '@/lib/components/core/Breadcrumbs';

export default function CandidatesPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = use(params);
const [isModalManualOpen, setIsModalManualOpen] = useState(false);
const [isCSVModalOpen, setIsCSVModalOpen] = useState(false);
const {
candidates,
loading,
Expand All @@ -25,7 +24,15 @@ export default function CandidatesPage({ params }: { params: Promise<{ id: strin
batchCreateCandidates,
isSendingAssessments,
handleSendAssessments,
isManualModalOpen,
setIsManualModalOpen,
isCSVModalOpen,
setIsCSVModalOpen,
isSendModalOpen,
setIsSendModalOpen,
switchToCSVModal,
} = useCandidates(id);

const { value: searchValue, onChange: onSearchChange } = useSearch('applications');

const displayedCandidates = searchValue.trim().length
Expand Down Expand Up @@ -69,7 +76,7 @@ export default function CandidatesPage({ params }: { params: Promise<{ id: strin
<Button
variant="secondary"
className="px-4 py-2"
onClick={() => setIsModalManualOpen(true)}
onClick={() => setIsManualModalOpen(true)}
>
<Plus className="size-5" />
Manual Add
Expand Down Expand Up @@ -103,7 +110,7 @@ export default function CandidatesPage({ params }: { params: Promise<{ id: strin
<div className="flex w-full justify-end">
<Button
className="px-4 py-3"
onClick={handleSendAssessments}
onClick={() => setIsSendModalOpen(true)}
disabled={isSendingAssessments}
>
<Mail className="size-5" />
Expand All @@ -116,20 +123,23 @@ export default function CandidatesPage({ params }: { params: Promise<{ id: strin
</div>

<CreateCandidateModal
open={isModalManualOpen}
onOpenChange={setIsModalManualOpen}
open={isManualModalOpen}
onOpenChange={setIsManualModalOpen}
onCreate={createCandidate}
onSwitchModal={() => {
setIsModalManualOpen(false);
setIsCSVModalOpen(true);
}}
onSwitchModal={switchToCSVModal}
/>
<UploadCSVModal
open={isCSVModalOpen}
positionId={id}
onOpenChange={setIsCSVModalOpen}
onCreate={batchCreateCandidates}
/>
<SendAssessmentModal
open={isSendModalOpen}
onOpenChange={setIsSendModalOpen}
isSending={isSendingAssessments}
onConfirm={handleSendAssessments}
/>
</>
);
}
6 changes: 4 additions & 2 deletions src/app/api/assessments/send-invitation/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import { handleError } from '@/lib/utils/errors.utils';
import { getSession } from '@/lib/utils/auth.utils';
import { assertRecruiterOrAbove } from '@/lib/utils/permissions.utils';
import AssessmentService from '@/lib/services/assessment.service';
import { sendAssessmentInvitationSchema } from '@/lib/schemas/assessment.schema';

export async function POST(request: NextRequest) {
try {
const session = await getSession();
await assertRecruiterOrAbove(request.headers);

const body = await request.json();
const { positionId } = body as { positionId: string };
const { positionId, deadline } = sendAssessmentInvitationSchema.parse(body);

const result = await AssessmentService.sendAssessmentInvitationsToPosition(
positionId,
session.activeOrganizationId
session.activeOrganizationId,
deadline
);

return Response.json({ data: result }, { status: 200 });
Expand Down
18 changes: 18 additions & 0 deletions src/app/api/internal/expire/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type NextRequest } from 'next/server';
import AssessmentService from '@/lib/services/assessment.service';
import { handleError, UnauthorizedException } from '@/lib/utils/errors.utils';

export async function POST(request: NextRequest) {
try {
const expected = process.env.INTERNAL_API_SECRET;
const provided = request.headers.get('X-SARGE-INTERNAL-SECRET');
if (!expected || provided !== expected) {
throw new UnauthorizedException('Invalid internal secret');
}

const expired = await AssessmentService.expireOverdueAssessments();
return Response.json({ data: { expired } }, { status: 200 });
} catch (err) {
return handleError(err);
}
}
10 changes: 3 additions & 7 deletions src/app/api/internal/snapshot/route.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import snapshotService from '@/lib/services/snapshot.service';
import { handleError, UnauthorizedException } from '@/lib/utils/errors.utils';
import { z } from 'zod';
import { CreateDisconnectSnapshotSchema } from '@/lib/schemas/snapshot.schema';
import { type NextRequest } from 'next/server';

const BodySchema = z.object({
candidateEmail: z.email(),
});

export async function POST(request: NextRequest) {
try {
const expected = process.env.INTERNAL_API_SECRET;
const provided = request.headers.get('X-SARGE-INTERAL-SECRET');
const provided = request.headers.get('X-SARGE-INTERNAL-SECRET');
if (!expected || provided !== expected) {
throw new UnauthorizedException('Invalid internal secret');
}

const body = await request.json();
const { candidateEmail } = BodySchema.parse(body);
const { candidateEmail } = CreateDisconnectSnapshotSchema.parse(body);
const snapshot = await snapshotService.createDisconnectSnapshot(candidateEmail);
return Response.json({ data: snapshot }, { status: 201 });
} catch (err) {
Expand Down
6 changes: 1 addition & 5 deletions src/app/api/organizations/[id]/transfer-ownership/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { type NextRequest } from 'next/server';
import { z } from 'zod';
import { auth } from '@/lib/auth/auth';
import { prisma } from '@/lib/prisma';
import OrganizationService from '@/lib/services/organization.service';
import { ForbiddenException, handleError } from '@/lib/utils/errors.utils';
import { assertOwner } from '@/lib/utils/permissions.utils';

const transferOwnershipSchema = z.object({
targetMemberId: z.string().min(1),
});
import { transferOwnershipSchema } from '@/lib/schemas/organization.schema';

export async function POST(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
Expand Down
14 changes: 1 addition & 13 deletions src/app/api/task-templates/[id]/[languageId]/stub/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@ import { handleError } from '@/lib/utils/errors.utils';
import { generateCodeStub } from '@/lib/utils/language.utils';
import { assertRecruiterOrAbove } from '@/lib/utils/permissions.utils';
import { type NextRequest } from 'next/server';
import { z } from 'zod';

const generateStubSchema = z.object({
functionName: z.string().trim().min(1),
returnType: z.string().trim().min(1),
parameters: z.array(
z.object({
name: z.string().trim().min(1),
type: z.string().trim().min(1),
})
),
language: z.string().trim().min(1),
});
import { generateStubSchema } from '@/lib/schemas/task-template-language.schema';

export async function POST(
request: NextRequest,
Expand Down
Loading
Loading