Skip to content

Commit

Permalink
resolved-conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutoshpadhi629 committed Sep 23, 2024
2 parents 3c3a487 + 00176e5 commit 38a5138
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 99 deletions.
42 changes: 42 additions & 0 deletions src/actions/upload-to-cdn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use server';

import { v4 as uuidv4 } from 'uuid';

export async function uploadFileAction(formData: FormData) {
const CDN_BASE_UPLOAD_URL = process.env.CDN_BASE_UPLOAD_URL!;
const CDN_BASE_ACCESS_URL = process.env.CDN_BASE_ACCESS_URL!;
const CDN_API_KEY = process.env.CDN_API_KEY!;

try {
const file = formData.get('file') as File;
const uniqueFileName = formData.get('uniqueFileName') || uuidv4(); // Generate unique key if not provided

if (!file) {
return { error: 'File is required', status: 400 };
}

const uploadUrl = `${CDN_BASE_UPLOAD_URL}/${uniqueFileName}`;
const fileBuffer = Buffer.from(await file.arrayBuffer());

const response = await fetch(uploadUrl, {
method: 'PUT',
headers: {
AccessKey: CDN_API_KEY,
'Content-Type': 'application/octet-stream',
},
body: fileBuffer,
});

if (response.ok) {
return {
message: 'File uploaded successfully',
url: `${CDN_BASE_ACCESS_URL}/${uniqueFileName}`,
};
} else {
return { error: 'Failed to upload file', status: response.status };
}
} catch (error) {
console.error('Error uploading file:', error);
return { error: 'Internal server error', status: 500 };
}
}
50 changes: 0 additions & 50 deletions src/app/api/upload-to-cdn/route.ts

This file was deleted.

95 changes: 49 additions & 46 deletions src/layouts/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,58 +45,61 @@ const Header = () => {
}, []);

return (
<nav className="sticky w-full z-50">
<div className="flex h-[72px] w-full items-center justify-between dark:bg-[#020817] bg-[#FFFFFF] lg:px-20 px-3 shadow-sm">
<Link href="/" className="p-2.5">
<CompanyLogo />
</Link>
<div className="flex items-center">
<ul className="md:flex items-center gap-4 text-sm lg:gap-6 hidden mx-4">
{session.status === 'loading'
? nonUserNavbar.map((_, index) => (
<Skeleton className="h-4 w-[60px]" key={index} />
))
: session.data?.user
? session.data?.user.role === ADMIN_ROLE
? adminNavbar.map((item) => (
<NavItem {...item} key={item.id} />
))
: userNavbar.map((item) => (
<NavItem {...item} key={item.id} />
))
: nonUserNavbar.map((item) => (
<NavItem {...item} key={item.id} />
))}
</ul>
<>
<nav className="fixed w-full z-50 backdrop-blur-md">
<div className="flex h-[72px] w-full items-center justify-between lg:px-20 px-3 shadow-sm">
<Link href="/" className="p-2.5">
<CompanyLogo />
</Link>
<div className="flex items-center">
{mounted && (
<button
className="border p-2.5 rounded-lg text-foreground/60 hover:dark:bg-[#191919] hover:bg-gray-100 md:mx-4 outline-none"
onClick={toggleTheme}
>
{theme === 'dark' ? (
<Moon className="w-4 h-4" />
) : (
<Sun className="w-4 h-4" />
)}
</button>
)}

{session.status !== 'loading' && !session.data?.user && (
<Link href={'/create'}>
<button className="rounded-lg p-2 bg-[#3259E8] hover:bg-[#3e63e9] text-white font-medium max-sm:hidden">
Post a job
<ul className="md:flex items-center gap-4 text-sm lg:gap-6 hidden mx-4">
{session.status === 'loading'
? nonUserNavbar.map((_, index) => (
<Skeleton className="h-4 w-[60px]" key={index} />
))
: session.data?.user
? session.data?.user.role === ADMIN_ROLE
? adminNavbar.map((item) => (
<NavItem {...item} key={item.id} />
))
: userNavbar.map((item) => (
<NavItem {...item} key={item.id} />
))
: nonUserNavbar.map((item) => (
<NavItem {...item} key={item.id} />
))}
</ul>
<div className="flex items-center">
{mounted && (
<button
className="border p-2.5 rounded-lg text-foreground/60 hover:dark:bg-[#191919] hover:bg-gray-100 md:mx-4 outline-none"
onClick={toggleTheme}
>
{theme === 'dark' ? (
<Moon className="w-4 h-4" />
) : (
<Sun className="w-4 h-4" />
)}
</button>
</Link>
)}
)}

{session.status !== 'loading' && !session.data?.user && (
<Link href={'/create'}>
<button className="rounded-lg p-2 bg-[#3259E8] hover:bg-[#3e63e9] text-white font-medium max-sm:hidden">
Post a job
</button>
</Link>
)}

<div className="md:hidden flex justify-center ml-3">
<MobileNav />
<div className="md:hidden flex justify-center ml-3">
<MobileNav />
</div>
</div>
</div>
</div>
</div>
</nav>
</nav>
<div className="h-[72px] print:hidden"></div>
</>
);
};

Expand Down
6 changes: 3 additions & 3 deletions src/lib/validators/jobs.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const JobPostSchema = z
companyName: z.string().min(1, 'Company Name is required'),
city: z.string().min(1, 'City Name is required'),
address: z.string().min(1, 'Address is required'),
application: z.string(),
application: z.string().min(1, 'Application link is required'),
type: z.nativeEnum(EmployementType, {
message: 'Employment Type is Required',
}),
Expand Down Expand Up @@ -43,14 +43,14 @@ export const JobPostSchema = z
if (data.hasSalaryRange) {
if (!data.minSalary) {
return ctx.addIssue({
message: 'minSalary is required when hasSalaryRange is true',
message: 'minSalary is required ',
path: ['minSalary'],
code: z.ZodIssueCode.custom,
});
}
if (!data.maxSalary) {
return ctx.addIssue({
message: 'maxSalary is required when hasSalaryRange is true',
message: 'maxSalary is required ',
path: ['maxSalary'],
code: z.ZodIssueCode.custom,
});
Expand Down

0 comments on commit 38a5138

Please sign in to comment.