-
-
Notifications
You must be signed in to change notification settings - Fork 173
Added some validations to jobs-create page #1142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes in this pull request enhance the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@Nil2000 is attempting to deploy a commit to the Codú Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (10)
schema/job.ts (5)
4-7: Fix typo in error message and LGTM forcompanyNamefield.The validation rules for the
companyNamefield are appropriate. However, there's a minor typo in the error message for the minimum length.Please apply this change:
- .min(1, "Company name should contain atleast 1 character") + .min(1, "Company name should contain at least 1 character")
8-11: Fix typo in error message and LGTM forjobTitlefield.The validation rules for the
jobTitlefield are appropriate. However, there's a minor typo in the error message for the minimum length, similar to thecompanyNamefield.Please apply this change:
- .min(3, "Job title should contain atleast 3 character") + .min(3, "Job title should contain at least 3 characters")
12-15: Consider increasing the maximum length forjobDescription.The
jobDescriptionfield is correctly set as optional, which is appropriate. However, the maximum length of 200 characters seems quite restrictive for a comprehensive job description.Consider increasing the maximum length to allow for more detailed job descriptions. A length between 1000 to 5000 characters is more common for job descriptions. For example:
- .max(200, "Job Description should contain atmost 200 characters") + .max(5000, "Job Description should contain at most 5000 characters")
16-19: Standardize error message format forjobLocationfield.The validation rules for the
jobLocationfield are appropriate. However, there's a minor inconsistency in the error message format compared to other fields.Please apply this change to standardize the error message format:
- .max(40, "Max location length is 40 characters.") + .max(40, "Location should contain at most 40 characters")
28-28: Consider adding "contract" tojobTypeoptions.The
jobTypefield is well-implemented using an enum to restrict job types to specific values. The provided options cover common job types.Consider adding "contract" as an option, as it's a common job type distinct from "freelancer". For example:
- jobType: z.enum(["full-time", "part-time", "freelancer", "other"]), + jobType: z.enum(["full-time", "part-time", "freelancer", "contract", "other"]),app/(app)/jobs/create/_client.tsx (5)
Line range hint
181-194: Register the location checkboxes with react-hook-formThe checkboxes for "Work is remote," "Relocation package given," and "Visa sponsorship provided" are not registered with
react-hook-form. As a result, their values won't be included in the form submission data. To capture these values, register each checkbox using theregistermethod.Apply this diff to register the checkboxes:
<CheckboxGroup className="mt-3"> <CheckboxField> - <Checkbox name="remote" value="is_remote" /> + <Checkbox value="is_remote" {...register("isRemote")} /> <Label>Work is remote</Label> </CheckboxField> <CheckboxField> - <Checkbox name="relocation" value="is_relocation_package" /> + <Checkbox value="is_relocation_package" {...register("isRelocationPackage")} /> <Label>Relocation package given</Label> </CheckboxField> <CheckboxField> - <Checkbox name="visa" value="is_visa_sponsored" /> + <Checkbox value="is_visa_sponsored" {...register("isVisaSponsored")} /> <Label>Visa sponsorship provided</Label> </CheckboxField> </CheckboxGroup>
Line range hint
231-250: Register the Job Type radio buttons with react-hook-formThe
RadioGroupfor "Job Type" is not registered withreact-hook-form, so the selected job type won't be included in the form data upon submission. To fix this, register the radio buttons to ensure the value is captured.Apply this diff to register the
RadioGroup:- <RadioGroup defaultValue="full-time"> + <RadioGroup defaultValue="full-time" {...register("jobType")}>
302-307: Provide visual feedback during form submissionTo enhance user experience, consider showing a loading indicator or disabling the button text when the form is submitting. This provides clear feedback to the user that their submission is being processed.
178-181: Ensure consistent autoComplete attributes for input fieldsThe
Inputfor "Locations" is missing anautoCompleteattribute. Adding it improves form accessibility and user experience.Apply this diff to add the
autoCompleteattribute:<Input placeholder="Dublin (2 days in the office per week)" + autoComplete="address-level2" {...register("jobLocation")} />
48-50: Remove unnecessary TypeScript type annotation fordataThe
onSubmitfunction parameterdataalready infers the typesaveJobsInputfrom theuseFormgeneric parameter. Explicitly annotating the type is redundant.Apply this diff to simplify the code:
- const onSubmit = (data: saveJobsInput) => { + const onSubmit = (data) => {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- app/(app)/jobs/create/_client.tsx (11 hunks)
- schema/job.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (7)
schema/job.ts (7)
1-1: LGTM: Zod import is correct.The import statement for Zod is correct and follows common practices.
20-24: LGTM:applicationUrlfield implementation is correct and flexible.The
applicationUrlfield is well-implemented. It correctly allows for optional valid URLs or empty strings, providing appropriate flexibility for job postings.
25-25: LGTM:remotefield is correctly implemented.The
remotefield is correctly implemented as an optional boolean with a default value of false. This is appropriate for representing remote work options in job postings.
26-26: LGTM:relocationfield is correctly implemented.The
relocationfield is correctly implemented as an optional boolean with a default value of false. This is appropriate for representing relocation options in job postings.
27-27: LGTM:visafield is correctly implemented.The
visafield is correctly implemented as an optional boolean with a default value of false. This is appropriate for representing visa sponsorship options in job postings.
31-31: LGTM: Type alias export is correct.The
saveJobsInputtype alias is correctly exported usingz.TypeOf<typeof saveJobsSchema>. This allows for type-safe usage of the schema in other parts of the application.
1-31: Overall, great implementation of the job posting schema.This schema provides a solid foundation for form validation in the Jobs Create page, directly addressing the objectives outlined in the PR. It covers all necessary fields with appropriate validation rules. The minor suggestions for improvement (typos in error messages, considering longer job descriptions, and adding a "contract" job type) will further enhance its effectiveness.
Great job on implementing this validation schema, which will significantly improve the user experience on the Jobs Create page by preventing incorrect form submissions.
app/(app)/jobs/create/_client.tsx
Outdated
| console.log(data); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid logging sensitive user data in production code
Logging user-submitted data with console.log(data); can lead to security concerns, especially in a production environment. Consider removing this console statement or ensuring it is only used during development.
app/(app)/jobs/create/_client.tsx
Outdated
| if (errors) { | ||
| console.log(errors); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle errors appropriately instead of logging to the console
While logging errors can be helpful during development, directly logging errors to the console in production may expose sensitive information. Consider implementing user-friendly error handling or displaying validation messages within the UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
app/(app)/jobs/create/_client.tsx (2)
34-44: LGTM: Form setup with react-hook-form and Zod validationThe integration of react-hook-form with Zod schema validation is well-implemented and addresses the PR objective of adding validation to the form.
Consider adding default values for other form fields as well, to improve the user experience and ensure consistent initial form state.
116-120: LGTM: Form fields correctly integrated with react-hook-form and error handling addedThe integration of form fields with react-hook-form using the
registerfunction is well-implemented. The addition of error handling for each field ensures that validation errors are displayed to the user, which directly addresses the PR objective.Consider adding aria-invalid attributes to the input fields based on the error state to improve accessibility. For example:
<Input id="company-name" type="text" placeholder="Pixel Pulse Studios" autoComplete="given-company-name" aria-invalid={errors.companyName ? "true" : "false"} {...register("companyName")} />This will help screen readers communicate the validation state of the form fields to users.
Also applies to: 137-141, 157-161, 175-178, 193-195, 212-216
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- app/(app)/jobs/create/_client.tsx (11 hunks)
🧰 Additional context used
🔇 Additional comments (4)
app/(app)/jobs/create/_client.tsx (4)
10-15: LGTM: Necessary imports added for form validationThe new imports for form-related components, Zod schema, and react-hook-form are appropriate for implementing the required form validation. These changes align well with the PR objective of adding validation to the jobs create page.
Also applies to: 25-25, 27-27, 31-31
56-59: LGTM: Form submission correctly integrated with react-hook-formThe addition of
onSubmit={handleSubmit(onSubmit)}to the form element correctly integrates the form submission with react-hook-form. This ensures that form validation occurs before submission, which aligns with the PR objective of adding validation to the jobs create page.
299-304: LGTM: Submit button correctly configuredThe changes to the submit button are well-implemented:
- The
type="submit"attribute ensures that the button triggers form submission.- The
disabled={isSubmitting}prop prevents multiple submissions while the form is being processed.These improvements enhance the user experience and prevent potential issues with duplicate submissions.
Line range hint
1-310: Overall: Good implementation of form validation with some areas for improvementThe changes in this file successfully implement form validation for the jobs create page using react-hook-form and Zod, which meets the main PR objective. The integration is generally well-done, with proper error handling and improved user experience.
Main points for improvement:
- Remove the
console.login theonSubmitfunction and implement proper form submission logic with API calls and user feedback.- Integrate the RadioGroup for job type selection with react-hook-form.
- Consider adding
aria-invalidattributes to input fields for improved accessibility.- Add default values for more form fields to ensure a consistent initial form state.
Once these points are addressed, the implementation will be more robust and provide a better user experience.
app/(app)/jobs/create/_client.tsx
Outdated
| const onSubmit = (data: saveJobsInput) => { | ||
| console.log(data); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console.log and implement proper form submission
While the typed parameter for onSubmit is good for type safety, there are a couple of issues to address:
- As mentioned in a previous review, logging user-submitted data with
console.log(data);can lead to security concerns, especially in a production environment. - The current implementation doesn't actually submit the form data or provide user feedback.
Please remove the console.log statement and implement proper form submission logic. Consider the following steps:
- Remove the console.log statement.
- Implement an API call to submit the form data.
- Handle success and error states appropriately.
- Provide user feedback (e.g., success message, error message).
Example:
const onSubmit = async (data: saveJobsInput) => {
try {
// Implement API call to submit form data
// const response = await api.submitJobPost(data);
// Handle success (e.g., show success message, redirect user)
} catch (error) {
// Handle error (e.g., show error message)
}
};
app/(app)/jobs/create/_client.tsx
Outdated
| </div> | ||
| <Field> | ||
| <RadioGroup defaultValue="full_time"> | ||
| <RadioGroup defaultValue="full-time"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integrate RadioGroup with react-hook-form
While the addition of defaultValue to the RadioGroup and value props to individual Radio components improves usability, the RadioGroup is not currently integrated with react-hook-form. This means that the selected job type is not included in the form data and won't be validated.
Please integrate the RadioGroup with react-hook-form. Here's an example of how you can do this:
<RadioGroup {...register("jobType")}>
<RadioField>
<Radio value="full-time" />
<Label>Full-time (€150)</Label>
<Description>Salaried Position</Description>
</RadioField>
{/* ... other radio fields ... */}
</RadioGroup>
{errors?.jobType && (
<ErrorMessage>{errors.jobType.message}</ErrorMessage>
)}Don't forget to add the jobType field to your Zod schema and the saveJobsInput type.
Also applies to: 230-230, 235-235
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
schema/job.ts
Outdated
| .max(50, "Job title should contain atmost 50 characters"), | ||
| jobDescription: z | ||
| .string() | ||
| .max(200, "Job Description should contain atmost 200 characters") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a min character count on this too. Without a job description the post will be pretty bad. Say 100 characters. you can max it at 2000.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
| relocation: z.boolean().optional().default(false), | ||
| visa: z.boolean().optional().default(false), | ||
| jobType: z.enum(["full-time", "part-time", "freelancer", "other"]), | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love some thoughts on if you think all of these are sensible too? 🦾
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes, these should also be populated. As a result these values can be shown in the jobs page with their associated jobs.
A sample shown below present on YC jobs page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- app/(app)/jobs/create/_client.tsx (9 hunks)
- schema/job.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- schema/job.ts
🧰 Additional context used
🔇 Additional comments (6)
app/(app)/jobs/create/_client.tsx (6)
10-15: Excellent implementation of form handling and validation!The integration of react-hook-form with Zod schema validation significantly improves the form's robustness and user experience. The use of defaultValues in the useForm setup is a good practice, ensuring that all form fields have initial values. This implementation will make it easier to manage form state, handle submissions, and provide user feedback.
Also applies to: 25-27, 31-31, 34-53
65-68: Great implementation of form submission and field validationThe changes to the form element and the company name input field are well-implemented:
- The form now correctly uses the
handleSubmitfunction from react-hook-form.- The company name input is properly registered with react-hook-form.
- Error handling and display for the company name field have been added, improving user feedback.
These improvements enhance the form's functionality and user experience.
Also applies to: 125-129
146-150: Consistent implementation of form field validationThe job title and job description inputs have been updated in line with best practices:
- Both fields are correctly registered with react-hook-form.
- Error handling and display have been added for both fields.
This consistent approach to form field validation improves the overall reliability of the form and provides clear feedback to users when input errors occur.
Also applies to: 166-170
335-340: Excellent improvements to the submit buttonThe changes to the submit button enhance the form's usability and prevent potential issues:
- The
type="submit"attribute ensures that the button correctly triggers form submission.- The
disabled={isSubmitting}prop prevents multiple submissions while the form is being processed.These improvements contribute to a better user experience and help prevent data inconsistencies.
Line range hint
1-346: Overall excellent improvements to the job creation formThe integration of react-hook-form with Zod schema validation has significantly enhanced the form's functionality, validation, and user experience. The consistent implementation across all form fields is commendable. Here's a summary of the improvements and remaining issues:
Improvements:
- Proper form state management and validation using react-hook-form and Zod.
- Consistent error handling and display for most form fields.
- Use of the Controller component for complex form controls like checkboxes and radio buttons.
- Improved submit button functionality to prevent multiple submissions.
Remaining issues to address:
- Implement proper form submission logic in the
onSubmitfunction.- Correct the typo in the "visa_sponsership" field name.
- Add error handling for the job type field.
Once these minor issues are resolved, the form will be robust and user-friendly.
57-59:⚠️ Potential issueImplement proper form submission and remove console logging
The current implementation of the
onSubmitfunction only logs the form data to the console, which is insufficient for a production environment and poses potential security risks. Consider the following improvements:
- Remove the
console.log(values)statement.- Implement an API call to submit the form data.
- Handle success and error states appropriately.
- Provide user feedback (e.g., success message, error message).
Example implementation:
const onSubmit: SubmitHandler<saveJobsInput> = async (values) => { try { // Implement API call to submit form data // const response = await api.submitJobPost(values); // Handle success (e.g., show success message, redirect user) } catch (error) { // Handle error (e.g., show error message) } };
| {...register("applicationUrl")} | ||
| /> | ||
| {errors?.applicationUrl && ( | ||
| <ErrorMessage>{errors.applicationUrl.message}</ErrorMessage> | ||
| )} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good implementation of application URL and job type fields, but missing error handling for job type
The changes to the application URL input and job type radio group are well-implemented:
- The application URL input is correctly registered with react-hook-form.
- The job type radio group uses the Controller component, which is appropriate for this type of form control.
- Error handling has been added for the application URL field.
However, error handling for the job type field is missing. Consider adding error display for the job type field to maintain consistency with other form fields.
Add error handling for the job type field:
{errors?.jobType && (
<ErrorMessage>{errors.jobType.message}</ErrorMessage>
)}Also applies to: 255-289
| <Input | ||
| placeholder="Dublin (2 days in the office per week)" | ||
| {...register("jobLocation")} | ||
| /> | ||
| <CheckboxGroup className="mt-3"> | ||
| <CheckboxField> | ||
| <Checkbox name="remote" value="is_remote" /> | ||
| <Controller | ||
| name="remote" | ||
| control={control} | ||
| render={({ field }) => ( | ||
| <Checkbox checked={field.value} onChange={field.onChange} /> | ||
| )} | ||
| /> | ||
| <Label>Work is remote</Label> | ||
| </CheckboxField> | ||
| <CheckboxField> | ||
| <Checkbox name="relocation" value="is_relocation_package" /> | ||
| <Controller | ||
| name="relocation" | ||
| control={control} | ||
| render={({ field }) => ( | ||
| <Checkbox checked={field.value} onChange={field.onChange} /> | ||
| )} | ||
| /> | ||
| <Label>Relocation package given</Label> | ||
| </CheckboxField> | ||
| <CheckboxField> | ||
| <Checkbox name="visa" value="is_visa_sponsored" /> | ||
| <Controller | ||
| name="visa_sponsership" | ||
| control={control} | ||
| render={({ field }) => ( | ||
| <Checkbox checked={field.value} onChange={field.onChange} /> | ||
| )} | ||
| /> | ||
| <Label>Visa sponsorship provided</Label> | ||
| </CheckboxField> | ||
| </CheckboxGroup> | ||
| {errors?.jobLocation && ( | ||
| <ErrorMessage>{errors.jobLocation.message}</ErrorMessage> | ||
| )} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good implementation of location field and checkboxes, but there's a typo
The changes to the location input and checkbox fields are well-implemented:
- The location input is correctly registered with react-hook-form.
- Checkbox fields now use the Controller component, which is appropriate for more complex form controls.
- Error handling has been added for the location field.
However, there's a typo in the "visa_sponsership" field name. It should be "visa_sponsorship".
Please correct the typo in the field name:
- name="visa_sponsership"
+ name="visa_sponsorship"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <Input | |
| placeholder="Dublin (2 days in the office per week)" | |
| {...register("jobLocation")} | |
| /> | |
| <CheckboxGroup className="mt-3"> | |
| <CheckboxField> | |
| <Checkbox name="remote" value="is_remote" /> | |
| <Controller | |
| name="remote" | |
| control={control} | |
| render={({ field }) => ( | |
| <Checkbox checked={field.value} onChange={field.onChange} /> | |
| )} | |
| /> | |
| <Label>Work is remote</Label> | |
| </CheckboxField> | |
| <CheckboxField> | |
| <Checkbox name="relocation" value="is_relocation_package" /> | |
| <Controller | |
| name="relocation" | |
| control={control} | |
| render={({ field }) => ( | |
| <Checkbox checked={field.value} onChange={field.onChange} /> | |
| )} | |
| /> | |
| <Label>Relocation package given</Label> | |
| </CheckboxField> | |
| <CheckboxField> | |
| <Checkbox name="visa" value="is_visa_sponsored" /> | |
| <Controller | |
| name="visa_sponsership" | |
| control={control} | |
| render={({ field }) => ( | |
| <Checkbox checked={field.value} onChange={field.onChange} /> | |
| )} | |
| /> | |
| <Label>Visa sponsorship provided</Label> | |
| </CheckboxField> | |
| </CheckboxGroup> | |
| {errors?.jobLocation && ( | |
| <ErrorMessage>{errors.jobLocation.message}</ErrorMessage> | |
| )} | |
| <Input | |
| placeholder="Dublin (2 days in the office per week)" | |
| {...register("jobLocation")} | |
| /> | |
| <CheckboxGroup className="mt-3"> | |
| <CheckboxField> | |
| <Controller | |
| name="remote" | |
| control={control} | |
| render={({ field }) => ( | |
| <Checkbox checked={field.value} onChange={field.onChange} /> | |
| )} | |
| /> | |
| <Label>Work is remote</Label> | |
| </CheckboxField> | |
| <CheckboxField> | |
| <Controller | |
| name="relocation" | |
| control={control} | |
| render={({ field }) => ( | |
| <Checkbox checked={field.value} onChange={field.onChange} /> | |
| )} | |
| /> | |
| <Label>Relocation package given</Label> | |
| </CheckboxField> | |
| <CheckboxField> | |
| <Controller | |
| name="visa_sponsorship" | |
| control={control} | |
| render={({ field }) => ( | |
| <Checkbox checked={field.value} onChange={field.onChange} /> | |
| )} | |
| /> | |
| <Label>Visa sponsorship provided</Label> | |
| </CheckboxField> | |
| </CheckboxGroup> | |
| {errors?.jobLocation && ( | |
| <ErrorMessage>{errors.jobLocation.message}</ErrorMessage> | |
| )} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
app/(app)/jobs/create/_client.tsx (2)
34-53: LGTM: Form setup with react-hook-form and ZodThe integration of react-hook-form with Zod for form handling and validation is well-implemented. The default values for form fields are appropriately set.
Consider extracting the default values into a separate constant for better maintainability:
const DEFAULT_FORM_VALUES: saveJobsInput = { companyName: "", jobTitle: "", // ... other fields }; const { ... } = useForm<saveJobsInput>({ resolver: zodResolver(saveJobsSchema), defaultValues: DEFAULT_FORM_VALUES, });This change would make it easier to update default values in the future and improve code readability.
125-129: LGTM: Input fields correctly integrated with react-hook-formThe input fields are now properly registered with react-hook-form, and error handling has been added for each field. This implementation addresses the PR objectives by adding validation to the jobs create page.
However, the jobLocation field is missing the id attribute. Consider adding it for better accessibility:
<Input id="job-location" placeholder="Dublin (2 days in the office per week)" {...register("jobLocation")} />This change will improve the accessibility of the form by associating the input field with its label.
Also applies to: 146-150, 166-170, 184-187, 220-222, 239-243
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- app/(app)/jobs/create/_client.tsx (9 hunks)
- schema/job.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- schema/job.ts
🧰 Additional context used
🔇 Additional comments (7)
app/(app)/jobs/create/_client.tsx (7)
10-15: LGTM: Necessary imports added for form validationThe new imports from react-hook-form, @hookform/resolvers/zod, and additional UI components are appropriate for implementing form validation. These changes align well with the PR objectives of adding validation to the jobs create page.
Also applies to: 25-25, 27-27, 31-31
65-68: LGTM: Correct integration of form submission with react-hook-formThe form element is now properly set up with the onSubmit handler using handleSubmit from react-hook-form. This ensures that form validation will be performed before the onSubmit function is called, which aligns with the PR objectives of adding validation to the jobs create page.
255-289: LGTM: Radio group correctly integrated with react-hook-formThe radio group for job type is well-implemented using the Controller component from react-hook-form. This ensures that the selected job type will be included in the form data and properly validated. The implementation includes all necessary job type options and aligns with the overall form validation strategy.
335-340: LGTM: Submit button properly configuredThe submit button is now correctly set up with the type="submit" attribute and is disabled during form submission. These changes improve the form submission process by ensuring that:
- The button triggers form submission when clicked.
- Multiple submissions are prevented while the form is being processed.
This implementation aligns with best practices for form handling and enhances the overall user experience.
Line range hint
1-345: Overall assessment: Good implementation with minor improvements neededThe changes in this file successfully implement form validation for the jobs create page using react-hook-form and Zod, addressing the main objectives of the PR. The form fields are properly integrated with the validation system, and error handling has been added where necessary.
Key points:
- Form setup and field integration are well-implemented.
- Proper use of Controller components for complex form controls.
- Submit button is correctly configured to prevent multiple submissions.
Areas for improvement:
- Implement proper form submission logic instead of console.log.
- Fix the typo in the visa_sponsorship field name.
- Add an id attribute to the jobLocation input for better accessibility.
- Consider extracting default form values into a separate constant.
Once these minor issues are addressed, the implementation will be robust and align perfectly with the PR objectives.
57-59:⚠️ Potential issueImplement proper form submission and remove console.log
The current implementation doesn't actually submit the form data or provide user feedback. Additionally, logging user-submitted data with
console.log(values);can lead to security concerns, especially in a production environment.Please implement proper form submission logic and remove the console.log statement. Consider the following steps:
- Remove the console.log statement.
- Implement an API call to submit the form data.
- Handle success and error states appropriately.
- Provide user feedback (e.g., success message, error message).
Example:
const onSubmit: SubmitHandler<saveJobsInput> = async (values) => { try { // Implement API call to submit form data // const response = await api.submitJobPost(values); // Handle success (e.g., show success message, redirect user) } catch (error) { // Handle error (e.g., show error message) } };
190-216:⚠️ Potential issueFix typo in visa_sponsorship field name
The integration of checkbox fields with react-hook-form using the Controller component is well-implemented. However, there's a typo in the "visa_sponsorship" field name. It's currently spelled as "visa_sponsership".
Please correct the typo in the field name:
- name="visa_sponsership" + name="visa_sponsorship"This correction will ensure that the form data is properly handled and validated for the visa sponsorship field.
|
@NiallJoeMaher @John-Paul-Larkin Can I implement the upload image functionality here (similar to settings page)? |
|
Yes, in fact you could do it with an action similar to how I handle the upload on the blog post. I'll share a link when I'm on my laptop. |
NiallJoeMaher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! You can work on the image upload next. Create the issue and I'll
Assign you.

✨ Codu Pull Request 💻
Fixes #1140
Pull Request details
Any Breaking changes
Associated Screenshots