Skip to content

Commit

Permalink
fix: bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Paribesh01 committed Oct 19, 2024
1 parent 2fc59d7 commit a5680bb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
6 changes: 4 additions & 2 deletions src/components/company-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const CompanyForm = ({ setIsDialogOpen }: any) => {
};

const handleFileChange = async (e: any) => {
const selectedFile = e.target.files[0];
const selectedFile = e.target.files?.[0];
if (!selectedFile) return;

// Basic file validation
Expand All @@ -88,15 +88,17 @@ export const CompanyForm = ({ setIsDialogOpen }: any) => {
});
}

setFile(selectedFile);

const reader = new FileReader();
reader.onload = () => {
if (companyLogoImg.current) {
companyLogoImg.current.src = reader.result as string;
}
setPreviewImg(reader.result as string);
};

reader.readAsDataURL(selectedFile);
setFile(selectedFile);
};

const handleDescriptionChange = (fieldName: any, value: string) => {
Expand Down
45 changes: 29 additions & 16 deletions src/components/job-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -626,22 +626,35 @@ const PostJobForm = () => {
<h2 className="text-lg font-semibold mb-4 dark:text-gray-300">
Company
</h2>
<FormControl>
<Select>
<SelectTrigger className="bg-gray-800 border-none text-white">
<SelectValue placeholder="Select a company that you have already posted job for" />
</SelectTrigger>
<SelectContent>
{companies.map((company, index) => {
return (
<SelectItem key={index} value={company.id}>
{company.name}
</SelectItem>
);
})}
</SelectContent>
</Select>
</FormControl>
<FormField
control={form.control}
name="companyId"
render={({ field }) => (
<FormItem>
<FormLabel className="font-medium">
Select a Company*
</FormLabel>
<FormControl>
<Select
onValueChange={field.onChange}
value={field.value}
>
<SelectTrigger className="bg-gray-800 border-none text-white">
<SelectValue placeholder="Select a company that you have already posted a job for" />
</SelectTrigger>
<SelectContent>
{companies.map((company, index) => (
<SelectItem key={index} value={company.id}>
{company.name}
</SelectItem>
))}
</SelectContent>
</Select>
</FormControl>
</FormItem>
)}
/>

<div className="flex gap-3 w-full p-6 mx-auto justify-center items-center">
<Separator className="w-1/2" /> OR{' '}
<Separator className="w-1/2" />
Expand Down
6 changes: 0 additions & 6 deletions src/lib/validators/jobs.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { SortByEnums } from '../constant/jobs.constant';
export const JobPostSchema = z
.object({
companyId: z.string().min(1, 'Company id is required'),
company: z.object({
id: z.string().min(1, 'Company id is required'),
name: z.string().min(1, 'Company name is required'),
bio: z.string().min(1, 'Company bio is required'),
logo: z.string().min(1, 'Company logo is required'),
}),
title: z.string().min(1, 'Title is required'),
description: z.string().min(1, 'Description is required'),
city: z.string().min(1, 'City Name is required'),
Expand Down

0 comments on commit a5680bb

Please sign in to comment.