Skip to content
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
17 changes: 16 additions & 1 deletion app/api/dsoc/applications/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ export async function GET(request: NextRequest) {
const mentorOnly = searchParams.get('mentor') === 'true';
const menteeOnly = searchParams.get('my') === 'true';
const menteeId = menteeOnly ? await getMenteeFromToken(request) : null;


if (menteeOnly && !menteeId) {
return NextResponse.json(
{ success: false, error: 'Unauthorized' },
{ status: 401 }
);
}

const query: any = {};

if (mentorOnly) {
Expand Down Expand Up @@ -111,6 +118,14 @@ export async function POST(request: NextRequest) {

const body = await request.json();
const { projectId, ...applicationData } = body;

// Drop empty-string optional fields so mongoose doesn't try to cast them
// (empty string into a Date field throws CastError).
Object.keys(applicationData).forEach((key) => {
if (applicationData[key] === '' || applicationData[key] === null) {
delete applicationData[key];
}
});

// Check if project exists and is open
const project = await DSOCProject.findById(projectId);
Expand Down
80 changes: 57 additions & 23 deletions app/dsoc/mentee/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ interface Application {
_id: string;
status: string;
createdAt: string;
mentorNotes?: string;
score?: number;
reviewedAt?: string;
project: {
_id: string;
title: string;
Expand Down Expand Up @@ -201,32 +204,63 @@ export default function MenteeDashboard() {
</Link>
</div>
) : (
applications.map((app) => (
<div key={app._id} className="neo-brutal-card p-6">
<div className="flex items-start justify-between gap-4">
<div className="flex-1">
<div className="flex items-center gap-3 mb-2">
{getStatusIcon(app.status)}
<span className={`neo-brutal-badge text-xs text-white ${getStatusColor(app.status)}`}>
{app.status.replace('-', ' ')}
</span>
applications.map((app) => {
const hasFeedback =
(app.status === 'accepted' ||
app.status === 'rejected' ||
app.status === 'waitlisted' ||
app.status === 'under-review') &&
(app.mentorNotes || typeof app.score === 'number');

return (
<div key={app._id} className="neo-brutal-card p-6">
<div className="flex items-start justify-between gap-4">
<div className="flex-1">
<div className="flex items-center gap-3 mb-2">
{getStatusIcon(app.status)}
<span className={`neo-brutal-badge text-xs text-white ${getStatusColor(app.status)}`}>
{app.status.replace('-', ' ')}
</span>
{typeof app.score === 'number' && (
<span className="neo-brutal-badge text-xs bg-[var(--dsoc-purple)] text-white">
Score: {app.score}/100
</span>
)}
</div>
<h3 className="text-xl font-bold">{app.project.title}</h3>
<p className="text-muted-foreground">{app.project.organization}</p>
<p className="text-sm text-muted-foreground mt-2">
Applied on {new Date(app.createdAt).toLocaleDateString()}
{app.reviewedAt && (
<>
{' • Reviewed '}
{new Date(app.reviewedAt).toLocaleDateString()}
</>
)}
</p>
</div>
<h3 className="text-xl font-bold">{app.project.title}</h3>
<p className="text-muted-foreground">{app.project.organization}</p>
<p className="text-sm text-muted-foreground mt-2">
Applied on {new Date(app.createdAt).toLocaleDateString()}
</p>
<Link
href={`/dsoc/projects/${app.project._id}`}
className="neo-brutal-btn neo-brutal-btn-secondary py-2 px-4 text-sm"
>
<ExternalLink className="w-4 h-4 mr-2" />
View Project
</Link>
</div>
<Link
href={`/dsoc/projects/${app.project._id}`}
className="neo-brutal-btn neo-brutal-btn-secondary py-2 px-4 text-sm"
>
<ExternalLink className="w-4 h-4 mr-2" />
View Project
</Link>

{hasFeedback && app.mentorNotes && (
<div className="mt-4 p-4 bg-[var(--dsoc-light)] border-4 border-[var(--dsoc-dark)]">
<div className="text-xs font-black uppercase tracking-wider text-muted-foreground mb-2">
Mentor Feedback
</div>
<p className="text-sm whitespace-pre-wrap leading-relaxed">
{app.mentorNotes}
</p>
</div>
)}
</div>
</div>
))
);
})
)}
</div>
)}
Expand Down
54 changes: 44 additions & 10 deletions models/DSOCApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ export interface IDSOCApplication extends Document {
discordUsername: string;
proposal: string;
coverLetter?: string;
relevantExperience: string;
whyThisProject: string;
availability: string;
expectedLearnings: string;
motivation?: string;
relevantExperience: string;
technicalSkills?: string;
githubProfile?: string;
portfolioLinks: string[];
previousContributions?: string;
timeline?: string;
expectedLearnings: string;
challenges?: string;
availability: string;
timezone?: string;
startDate?: Date;
status: 'pending' | 'under-review' | 'accepted' | 'rejected' | 'waitlisted' | 'withdrawn';
mentorNotes?: string;
adminNotes?: string;
Expand Down Expand Up @@ -48,34 +55,61 @@ const DSOCApplicationSchema = new Schema<IDSOCApplication>(
type: String,
trim: true,
},
whyThisProject: {
type: String,
required: [true, 'Why this project answer is required'],
trim: true,
},
motivation: {
type: String,
trim: true,
},
relevantExperience: {
type: String,
required: [true, 'Relevant experience is required'],
trim: true,
},
whyThisProject: {
technicalSkills: {
type: String,
required: [true, 'Why this project answer is required'],
trim: true,
},
availability: {
githubProfile: {
type: String,
trim: true,
},
portfolioLinks: [{
type: String,
trim: true,
}],
previousContributions: {
type: String,
trim: true,
},
timeline: {
type: String,
required: [true, 'Availability is required'],
trim: true,
},
expectedLearnings: {
type: String,
required: [true, 'Expected learnings is required'],
trim: true,
},
portfolioLinks: [{
challenges: {
type: String,
trim: true,
}],
previousContributions: {
},
availability: {
type: String,
required: [true, 'Availability is required'],
trim: true,
},
timezone: {
type: String,
trim: true,
},
startDate: {
type: Date,
},
status: {
type: String,
enum: ['pending', 'under-review', 'accepted', 'rejected', 'waitlisted', 'withdrawn'],
Expand Down
Loading