From d81b889fef865bf0411f7d1e701e234cc78ee150 Mon Sep 17 00:00:00 2001
From: Aakash Singh <78924853+aakash2330@users.noreply.github.com>
Date: Thu, 26 Sep 2024 02:17:30 +0530
Subject: [PATCH] Job form fix (#406)
* ui-fixes
* reset gmaps input
* fix:ui-fixes+job Form Submission Fix
* removed-unnecessary-allowed-domanin
* removed-unnecessary-overflow
---
next.config.js | 4 ++++
src/components/Jobcard.tsx | 6 ++---
src/components/TestimonialCard.tsx | 4 ++--
src/components/Testimonials.tsx | 2 +-
src/components/gmaps-autosuggest.tsx | 24 ++++++++++++++++++-
src/components/job-form.tsx | 36 ++++++++++++++++++----------
src/layouts/mobile-nav.tsx | 4 +++-
src/lib/validators/jobs.validator.ts | 4 ++--
8 files changed, 61 insertions(+), 23 deletions(-)
diff --git a/next.config.js b/next.config.js
index 3f0b294c..2e772965 100644
--- a/next.config.js
+++ b/next.config.js
@@ -21,6 +21,10 @@ const nextConfig = {
protocol: 'https',
hostname: 'job-board.b-cdn.net', // Change this to your CDN domain
},
+ {
+ protocol: 'https',
+ hostname: 'wwww.example.com',
+ },
],
},
};
diff --git a/src/components/Jobcard.tsx b/src/components/Jobcard.tsx
index f8df21a0..1e4508bf 100644
--- a/src/components/Jobcard.tsx
+++ b/src/components/Jobcard.tsx
@@ -14,12 +14,12 @@ export default function JobCard({ job }: { job: JobType }) {
className="sm:text-sm text-xs text-slate-500 dark:text-slate-400 font-medium flex flex-col border p-6 bg-slate-100 gap-4 dark:bg-slate-900 hover:bg-slate-200 dark:hover:bg-slate-800 rounded-lg "
>
-
+
diff --git a/src/components/TestimonialCard.tsx b/src/components/TestimonialCard.tsx
index e1505fca..b16569ba 100644
--- a/src/components/TestimonialCard.tsx
+++ b/src/components/TestimonialCard.tsx
@@ -12,7 +12,7 @@ export default function TestimonialCard({ testimonial }: testimonialCardProps) {
const { theme } = useTheme();
return (
@@ -27,7 +27,7 @@ export default function TestimonialCard({ testimonial }: testimonialCardProps) {
: '',
}}
>
-
+
diff --git a/src/components/Testimonials.tsx b/src/components/Testimonials.tsx
index 7d022498..8c0adc02 100644
--- a/src/components/Testimonials.tsx
+++ b/src/components/Testimonials.tsx
@@ -13,7 +13,7 @@ export default function Testimonials() {
Real Success Stories from Job Seekers and Employers
-
+
{testimonials.map((testimonial, i) => (
))}
diff --git a/src/components/gmaps-autosuggest.tsx b/src/components/gmaps-autosuggest.tsx
index 25e1e759..edd54bd0 100644
--- a/src/components/gmaps-autosuggest.tsx
+++ b/src/components/gmaps-autosuggest.tsx
@@ -1,10 +1,31 @@
import Script from 'next/script';
import { Input } from './ui/input';
import { clientEnv } from '@/env/client';
+import { useImperativeHandle, useRef } from 'react';
export type TgmapsAddress = { city: string; fullAddress: string };
-export default function GmapsAutocompleteAddress({ form }: { form: any }) {
+export default function GmapsAutocompleteAddress({
+ form,
+ innerRef,
+}: {
+ form: any;
+ innerRef: any;
+}) {
+ const inputRef = useRef
(null);
+
+ useImperativeHandle(innerRef, () => {
+ return {
+ reset: () => {
+ if (inputRef.current) {
+ inputRef.current.value = '';
+ form.setValue('city', '');
+ form.setValue('address', '');
+ }
+ },
+ };
+ });
+
let autocomplete: any = null;
function onPlaceChanged() {
@@ -33,6 +54,7 @@ export default function GmapsAutocompleteAddress({ form }: { form: any }) {
/>
import('./gmaps-autosuggest'),
- {
- ssr: false,
- }
-);
+const DynamicGmapsAutoSuggest = dynamic(() => import('./gmaps-autosuggest'), {
+ ssr: false,
+});
import { EmployementType } from '@prisma/client';
+import _ from 'lodash';
const PostJobForm = () => {
const { toast } = useToast();
@@ -56,6 +54,7 @@ const PostJobForm = () => {
city: '',
address: '',
companyLogo: '',
+ hasExperiencerange: false,
workMode: 'remote',
type: EmployementType.Full_time,
category: 'design',
@@ -66,6 +65,8 @@ const PostJobForm = () => {
},
});
+ const gmapsInputRef = useRef(null);
+
const handleClick = () => {
//@ts-ignore
document.getElementById('fileInput').click();
@@ -132,6 +133,11 @@ const PostJobForm = () => {
variant: 'success',
});
setPreviewImg(null);
+
+ if (gmapsInputRef.current) {
+ gmapsInputRef.current.reset();
+ }
+
form.reset(form.formState.defaultValues);
} catch (_error) {
toast({
@@ -274,10 +280,13 @@ const PostJobForm = () => {
- Full-time
- Part-time
- Contract
- Internship
+ {Object.keys(EmployementType).map((item, index) => {
+ return (
+
+ {_.startCase(item)}
+
+ );
+ })}
@@ -356,9 +365,10 @@ const PostJobForm = () => {
-
+ >
{
diff --git a/src/lib/validators/jobs.validator.ts b/src/lib/validators/jobs.validator.ts
index 4162c949..29ddcd52 100644
--- a/src/lib/validators/jobs.validator.ts
+++ b/src/lib/validators/jobs.validator.ts
@@ -12,12 +12,12 @@ export const JobPostSchema = z
type: z.nativeEnum(EmployementType, {
message: 'Employment Type is Required',
}),
- skills: z.array(z.string()),
+ skills: z.array(z.string()).optional(),
category: z.string(),
companyEmail: z.string().email('Invalid email').min(1, 'Email is required'),
companyBio: z.string().min(1, 'Company Bio is required'),
companyLogo: z.string().url(),
- hasSalaryRange: z.boolean(),
+ hasSalaryRange: z.boolean().optional(),
minSalary: z.coerce
.number({ message: 'Min salary must be a number' })
.nonnegative()