Skip to content

Commit 92b752b

Browse files
authored
Merge pull request #391 from CodebilityDev/kris/hire-fixes-NEW
Latest hire fixes
2 parents faf77d7 + aab6d15 commit 92b752b

4 files changed

Lines changed: 257 additions & 190 deletions

File tree

‎apps/codebility/app/home/hire/_components/ApplicationDetailsModal.tsx‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"use client";
22

33
import { useState } from "react";
4-
import {
5-
Mail,
6-
Phone,
7-
Linkedin,
8-
Globe,
9-
FileText,
10-
Calendar,
4+
import {
5+
Mail,
6+
Phone,
7+
Linkedin,
8+
Globe,
9+
FileText,
10+
Calendar,
1111
User,
1212
Briefcase,
1313
Download,
@@ -39,11 +39,11 @@ interface ApplicationDetailsModalProps {
3939
onStatusChange?: (applicationId: string, status: string) => void;
4040
}
4141

42-
export default function ApplicationDetailsModal({
43-
application,
44-
isOpen,
42+
export default function ApplicationDetailsModal({
43+
application,
44+
isOpen,
4545
onClose,
46-
onStatusChange
46+
onStatusChange
4747
}: ApplicationDetailsModalProps) {
4848
const { toast } = useToast();
4949
const [status, setStatus] = useState(application?.status || "pending");
@@ -74,14 +74,14 @@ export default function ApplicationDetailsModal({
7474

7575
return (
7676
<Dialog open={isOpen} onOpenChange={onClose}>
77-
<DialogContent className="max-h-[90vh] max-w-4xl overflow-y-auto bg-gray-900 border-gray-800">
77+
<DialogContent className="max-h-[90vh] max-w-4xl overflow-y-auto overflow-x-hidden bg-gray-900 border-gray-800">
7878
<DialogHeader>
7979
<DialogTitle className="text-2xl font-light text-white">
8080
Application Details
8181
</DialogTitle>
8282
</DialogHeader>
8383

84-
<div className="space-y-6 py-4">
84+
<div className="space-y-6 py-4 min-w-0">
8585
{/* Applicant Header */}
8686
<div className="flex items-start justify-between">
8787
<div>
@@ -197,10 +197,10 @@ export default function ApplicationDetailsModal({
197197
{/* Cover Letter */}
198198
<div className="rounded-lg border border-gray-800 p-4">
199199
<h3 className="mb-3 flex items-center gap-2 text-lg font-medium text-white">
200-
<FileText className="h-5 w-5" />
200+
<FileText className="h-5 w-5 flex-shrink-0" />
201201
Cover Letter
202202
</h3>
203-
<p className="text-gray-300 whitespace-pre-wrap">
203+
<p className="text-gray-300 whitespace-pre-wrap break-words">
204204
{application.cover_letter}
205205
</p>
206206
</div>

‎apps/codebility/app/home/hire/_components/JobListingsTable.tsx‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import { useState, useEffect } from "react";
44
import { useRouter } from "next/navigation";
5-
import {
6-
MoreVertical,
7-
Edit,
8-
Trash2,
9-
Eye,
5+
import {
6+
MoreVertical,
7+
Edit,
8+
Trash2,
9+
Eye,
1010
Users,
1111
Calendar,
1212
MapPin,
@@ -61,7 +61,7 @@ export default function JobListingsTable() {
6161
try {
6262
setLoading(true);
6363
const supabase = createClientClientComponent();
64-
64+
6565
// Fetch job listings with creator details
6666
const { data: jobsData, error: jobsError } = await supabase
6767
.from('job_listings')
@@ -93,7 +93,7 @@ export default function JobListingsTable() {
9393
.from('job_applications')
9494
.select('*', { count: 'exact', head: true })
9595
.eq('job_id', job.id);
96-
96+
9797
return {
9898
...job,
9999
application_count: count || 0,
@@ -123,7 +123,7 @@ export default function JobListingsTable() {
123123
if (confirm("Are you sure you want to delete this job listing? This action cannot be undone.")) {
124124
try {
125125
const supabase = createClientClientComponent();
126-
126+
127127
const { error } = await supabase
128128
.from('job_listings')
129129
.delete()
@@ -132,10 +132,10 @@ export default function JobListingsTable() {
132132
if (error) {
133133
throw error;
134134
}
135-
135+
136136
// Remove from local state
137137
setJobs(prevJobs => prevJobs.filter(job => job.id !== jobId));
138-
138+
139139
toast({
140140
title: "Job Deleted",
141141
description: "The job listing has been permanently removed.",
@@ -164,7 +164,7 @@ export default function JobListingsTable() {
164164
const handleJobUpdated = () => {
165165
// Refetch the jobs from the database
166166
fetchJobListings();
167-
167+
168168
toast({
169169
title: "Job Updated",
170170
description: "The job listing has been updated successfully.",
@@ -312,9 +312,9 @@ export default function JobListingsTable() {
312312
<Button
313313
variant="ghost"
314314
size="icon"
315-
className="h-8 w-8 text-gray-400 hover:text-white"
315+
className="group h-8 w-8 text-gray-400 hover:text-white"
316316
>
317-
<MoreVertical className="h-4 w-4" />
317+
<MoreVertical className="h-4 w-4 flex-shrink-0" />
318318
<span className="sr-only">Open menu</span>
319319
</Button>
320320
</DropdownMenuTrigger>
@@ -341,7 +341,7 @@ export default function JobListingsTable() {
341341
))}
342342
</TableBody>
343343
</Table>
344-
344+
345345
{/* Edit Job Modal */}
346346
<EditJobModal
347347
job={editingJob}

‎apps/codebility/app/home/hire/actions.ts‎

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ interface JobApplication {
3535

3636
export async function createJobListing(jobData: JobListing) {
3737
const supabase = await createClientServerComponent();
38-
38+
3939
try {
4040
// Get current user
4141
const { data: { user } } = await supabase.auth.getUser();
42-
42+
4343
if (!user) {
4444
return { success: false, error: "Unauthorized" };
4545
}
@@ -61,7 +61,7 @@ export async function createJobListing(jobData: JobListing) {
6161

6262
revalidatePath("/home/hire");
6363
revalidatePath("/careers");
64-
64+
6565
return { success: true, data };
6666
} catch (error) {
6767
console.error("Error in createJobListing:", error);
@@ -71,7 +71,7 @@ export async function createJobListing(jobData: JobListing) {
7171

7272
export async function updateJobListing(id: string, jobData: Partial<JobListing>) {
7373
const supabase = await createClientServerComponent();
74-
74+
7575
try {
7676
const { data, error } = await supabase
7777
.from("job_listings")
@@ -90,7 +90,7 @@ export async function updateJobListing(id: string, jobData: Partial<JobListing>)
9090

9191
revalidatePath("/home/hire");
9292
revalidatePath("/careers");
93-
93+
9494
return { success: true, data };
9595
} catch (error) {
9696
console.error("Error in updateJobListing:", error);
@@ -100,7 +100,7 @@ export async function updateJobListing(id: string, jobData: Partial<JobListing>)
100100

101101
export async function deleteJobListing(id: string) {
102102
const supabase = await createClientServerComponent();
103-
103+
104104
try {
105105
const { error } = await supabase
106106
.from("job_listings")
@@ -114,7 +114,7 @@ export async function deleteJobListing(id: string) {
114114

115115
revalidatePath("/home/hire");
116116
revalidatePath("/careers");
117-
117+
118118
return { success: true };
119119
} catch (error) {
120120
console.error("Error in deleteJobListing:", error);
@@ -124,7 +124,7 @@ export async function deleteJobListing(id: string) {
124124

125125
export async function getJobListings(status: 'active' | 'closed' | 'draft' = 'active') {
126126
const supabase = await createClientServerComponent();
127-
127+
128128
try {
129129
const { data, error } = await supabase
130130
.from("job_listings")
@@ -149,7 +149,7 @@ export async function getJobListings(status: 'active' | 'closed' | 'draft' = 'ac
149149

150150
export async function getJobApplications(jobId: string) {
151151
const supabase = await createClientServerComponent();
152-
152+
153153
try {
154154
const { data, error } = await supabase
155155
.from("job_applications")
@@ -169,9 +169,34 @@ export async function getJobApplications(jobId: string) {
169169
}
170170
}
171171

172+
173+
export async function deleteJobApplication(applicationId: string, jobId: string) {
174+
const supabase = await createClientServerComponent();
175+
try {
176+
177+
const { data, error } = await supabase
178+
.from("job_applications")
179+
.delete()
180+
.eq("id", applicationId);
181+
182+
if (error) {
183+
console.error("Error deleting job application:", error);
184+
return { success: false, error: error.message };
185+
}
186+
187+
revalidatePath(`/home/hire/applications/${jobId}`);
188+
return { success: true };
189+
} catch (error) {
190+
console.error("Error in deleteJobApplication:", error);
191+
return { success: false, error: "An unexpected error occurred" };
192+
}
193+
}
194+
195+
196+
172197
export async function submitJobApplication(applicationData: JobApplication) {
173198
const supabase = await createClientServerComponent();
174-
199+
175200
try {
176201
const { data, error } = await supabase
177202
.from("job_applications")
@@ -185,7 +210,7 @@ export async function submitJobApplication(applicationData: JobApplication) {
185210
}
186211

187212
revalidatePath(`/home/hire/applications/${applicationData.job_id}`);
188-
213+
189214
return { success: true, data };
190215
} catch (error) {
191216
console.error("Error in submitJobApplication:", error);
@@ -194,14 +219,14 @@ export async function submitJobApplication(applicationData: JobApplication) {
194219
}
195220

196221
export async function updateApplicationStatus(
197-
applicationId: string,
222+
applicationId: string,
198223
status: 'pending' | 'reviewing' | 'shortlisted' | 'rejected' | 'hired'
199224
) {
200225
const supabase = await createClientServerComponent();
201-
226+
202227
try {
203228
const { data: { user } } = await supabase.auth.getUser();
204-
229+
205230
if (!user) {
206231
return { success: false, error: "Unauthorized" };
207232
}
@@ -224,7 +249,7 @@ export async function updateApplicationStatus(
224249
}
225250

226251
revalidatePath("/home/hire");
227-
252+
228253
return { success: true, data };
229254
} catch (error) {
230255
console.error("Error in updateApplicationStatus:", error);

0 commit comments

Comments
 (0)