-
Notifications
You must be signed in to change notification settings - Fork 52
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
[Fix]:- Remove the Mandatory Field #3742
Conversation
WalkthroughThe pull request introduces several modifications to the Changes
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 (
|
Employee portal Run #8885
Run Properties:
|
Project |
Employee portal
|
Branch Review |
refs/pull/3742/merge
|
Run status |
Passed #8885
|
Run duration | 00m 25s |
Commit |
84192bfd90 ℹ️: Merge 24795b2d02726a2328786da2a15e46828a4b0cab into ef79f3dd8cc38f36fbf000379391...
|
Committer | Ayush |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
4
|
View all changes introduced in this branch ↗︎ |
Coverage report for commit: 24795b2
Summary - Lines: 3.16% | Methods: 5.43%
🤖 comment via lucassabreu/comment-coverage-clover |
…tfix/remove-mandatory-fields
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: 3
🧹 Outside diff range and nitpick comments (5)
Modules/Prospect/Http/Requests/ProspectRequest.php (1)
Line range hint
47-52
: Add custom error messages for new validation rules.The messages array only includes errors for required fields. Consider adding custom messages for URL and date validations to improve user experience.
public function messages() { return [ 'org_name.required' => 'Organization name is required', 'poc_user_id.required' => 'Point of contact user ID is required', + 'proposal_sent_date.date' => 'Proposal sent date must be a valid date', + 'last_followup_date.date' => 'Last followup date must be a valid date', + 'rfp_link.url' => 'RFP link must be a valid URL', + 'proposal_link.url' => 'Proposal link must be a valid URL', ]; }Modules/Prospect/Resources/views/index.blade.php (1)
71-71
: Use number_format() for consistent decimal formatting.Using
round()
for budget display might not provide the desired formatting. Consider usingnumber_format()
for consistent decimal places and thousand separators.-{{ $prospect->budget ? round($prospect->budget, 2) : '-' }} +{{ $prospect->budget ? number_format($prospect->budget, 2) : '-' }}Modules/Prospect/Resources/views/subviews/prospect-details.blade.php (1)
Line range hint
1-144
: Consider breaking down the template into smaller components.The template contains repeated div structures for form rows and groups. This could be extracted into reusable Blade components for better maintainability and DRY principles.
Consider creating these components:
- A
prospect-detail-row
component for the form-row structure- A
prospect-detail-field
component for individual fieldsExample implementation:
<!-- prospect-detail-field.blade.php --> @props(['label', 'value']) <div class="form-group col-md-12"> <label class="font-weight-bold">{{ $label }}:</label> <span class="ml-2">{{ $value ?? 'N/A' }}</span> </div> <!-- Usage --> <x-prospect-detail-field label="Organization Name" :value="$prospect->organization_name" />Modules/Prospect/Resources/views/subviews/edit-prospect-details.blade.php (2)
58-60
: Consider adding visual feedback for optional currency selection.While the currency selection logic is correct, consider adding visual indicators or helper text to show that this field is now optional. This would improve user experience by making the form's requirements clearer.
<option value="{{ $country->currency }}" - {{ $prospect->currency == $country->currency ? 'selected' : '' }}> + {{ $prospect->currency == $country->currency ? 'selected' : '' }} + class="{{ !$prospect->currency ? 'text-muted' : '' }}"> {{ $country->currency }}</option>
Line range hint
1-150
: Enhance form accessibility and validation feedback.The form structure could benefit from several improvements:
- Add proper ARIA labels for accessibility
- Include validation feedback states
- Use translation strings consistently
Here's an example improvement for the budget input group:
<div class="input-group"> <div class="input-group-prepend"> - <select name="currency" v-model="currency" id="currency" class="input-group-text"> + <select name="currency" + v-model="currency" + id="currency" + class="input-group-text @error('currency') is-invalid @enderror" + aria-label="{{ __('Select Currency') }}">Consider applying similar improvements to other form fields for consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- Modules/Prospect/Http/Requests/ProspectRequest.php (1 hunks)
- Modules/Prospect/Resources/views/index.blade.php (1 hunks)
- Modules/Prospect/Resources/views/subviews/edit-prospect-details.blade.php (1 hunks)
- Modules/Prospect/Resources/views/subviews/prospect-details.blade.php (1 hunks)
🔇 Additional comments (2)
Modules/Prospect/Http/Requests/ProspectRequest.php (1)
19-28
: Verify template handling of nullable fields.The validation changes allow nullable fields, but we should verify that the blade templates properly handle null values, especially for budget and currency display.
✅ Verification successful
Proper null handling confirmed in blade templates
The templates already implement appropriate null handling for both budget and currency fields:
- Index view uses ternary operators with fallbacks:
{{ $prospect->budget ? round($prospect->budget, 2) : '-' }}
- Details view handles nulls with 'N/A' fallback:
{{ $prospect->budget ? round($prospect->budget, 2) : 'N/A' }}
- Currency display checks both the currency value and symbol existence:
{{ isset($prospect->currency) && isset($currencySymbols[$prospect->currency]) ? $currencySymbols[$prospect->currency] : '' }}
- Form inputs properly handle old values and existing data
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check blade templates for null checks on the newly nullable fields echo "Checking blade templates for proper null handling..." # Look for currency and budget handling in blade templates rg -l "budget|currency" "Modules/Prospect/Resources/views/" # Check for isset/empty/null checks around these fields rg "(\@if|\?\?|isset|empty|\@empty|\@isset).*?(budget|currency)" "Modules/Prospect/Resources/views/"Length of output: 644
Script:
#!/bin/bash # Let's fix the regex and check for proper handling of nullable fields echo "Checking blade templates for proper null handling..." # Search for budget and currency usage patterns with fixed regex rg "@if.*?\b(budget|currency)\b" "Modules/Prospect/Resources/views/" rg "\{\{.*?\b(budget|currency)\b" "Modules/Prospect/Resources/views/" # Also check for null coalescing and other null checks with fixed regex rg "\?\?.*?\b(budget|currency)\b" "Modules/Prospect/Resources/views/" rg "@empty.*?\b(budget|currency)\b" "Modules/Prospect/Resources/views/" rg "@isset.*?\b(budget|currency)\b" "Modules/Prospect/Resources/views/" # Let's also check how these fields are used in forms rg "name=['\"](?:budget|currency)['\"]" "Modules/Prospect/Resources/views/"Length of output: 2928
Modules/Prospect/Resources/views/index.blade.php (1)
70-71
: LGTM! Improved error handling for currency display.The added null checks using
isset()
prevent undefined index errors when currency data is missing. This aligns well with making fields nullable.
'proposal_sent_date' => 'nullable|date', | ||
'domain' => 'nullable', | ||
'customer_type' => 'nullable', | ||
'budget' => 'nullable', | ||
'proposal_status' => 'nullable', | ||
'introductory_call' => 'nullable', | ||
'last_followup_date' => 'nullable|date', | ||
'rfp_link' => 'nullable|url', | ||
'proposal_link' => 'nullable|url', | ||
'currency' => 'nullable', |
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.
🛠️ Refactor suggestion
Consider strengthening validation rules for better data integrity.
While making fields nullable aligns with the PR objective, some fields would benefit from additional validation constraints:
- 'customer_type' => 'nullable',
- 'budget' => 'nullable',
- 'proposal_status' => 'nullable',
- 'currency' => 'nullable',
+ 'customer_type' => 'nullable|in:direct,agency,referral',
+ 'budget' => 'nullable|numeric|min:0',
+ 'proposal_status' => 'nullable|in:draft,sent,accepted,rejected',
+ 'currency' => 'nullable|size:3|alpha',
This ensures that even when optional:
- customer_type contains valid categories
- budget is a non-negative number
- proposal_status contains valid states
- currency follows the ISO 4217 format (3-letter codes)
Committable suggestion was skipped due to low confidence.
{{ isset($prospect->currency) && isset($currencySymbols[$prospect->currency]) ? $currencySymbols[$prospect->currency] : '' }} | ||
{{ $prospect->budget ? round($prospect->budget, 2) : '-' }} | ||
</span> |
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.
🛠️ Refactor suggestion
Consider moving formatting logic to a presenter class.
The budget and currency formatting logic in the view could be encapsulated in a presenter class to improve maintainability and reusability.
Example implementation:
// app/Presenters/ProspectPresenter.php
class ProspectPresenter
{
public function formattedBudget($prospect, array $currencySymbols)
{
if (!$prospect->budget) {
return '-';
}
$symbol = isset($prospect->currency) && isset($currencySymbols[$prospect->currency])
? $currencySymbols[$prospect->currency]
: '';
return $symbol . ' ' . number_format($prospect->budget, 2);
}
}
Then in the view:
-{{ isset($prospect->currency) && isset($currencySymbols[$prospect->currency]) ? $currencySymbols[$prospect->currency] : '' }}
-{{ $prospect->budget ? round($prospect->budget, 2) : '-' }}
+{{ $prospect->present()->formattedBudget($currencySymbols) }}
<span class="ml-2"> | ||
{{ isset($prospect->currency) && isset($currencySymbols[$prospect->currency]) ? $currencySymbols[$prospect->currency] : '' }} | ||
{{ $prospect->budget ? round($prospect->budget, 2) : 'N/A' }} | ||
</span> |
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.
🛠️ Refactor suggestion
Consider simplifying the nested conditionals for better readability.
While the null checks are a good addition, the nested ternary operations make the code harder to read. Consider extracting this logic into a dedicated Blade component or helper method.
- <span class="ml-2">
- {{ isset($prospect->currency) && isset($currencySymbols[$prospect->currency]) ? $currencySymbols[$prospect->currency] : '' }}
- {{ $prospect->budget ? round($prospect->budget, 2) : 'N/A' }}
- </span>
+ @php
+ $currencySymbol = isset($prospect->currency) && isset($currencySymbols[$prospect->currency])
+ ? $currencySymbols[$prospect->currency]
+ : '';
+ $formattedBudget = $prospect->budget ? round($prospect->budget, 2) : 'N/A';
+ @endphp
+ <span class="ml-2">{{ $currencySymbol }} {{ $formattedBudget }}</span>
📝 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.
<span class="ml-2"> | |
{{ isset($prospect->currency) && isset($currencySymbols[$prospect->currency]) ? $currencySymbols[$prospect->currency] : '' }} | |
{{ $prospect->budget ? round($prospect->budget, 2) : 'N/A' }} | |
</span> | |
@php | |
$currencySymbol = isset($prospect->currency) && isset($currencySymbols[$prospect->currency]) | |
? $currencySymbols[$prospect->currency] | |
: ''; | |
$formattedBudget = $prospect->budget ? round($prospect->budget, 2) : 'N/A'; | |
@endphp | |
<span class="ml-2">{{ $currencySymbol }} {{ $formattedBudget }}</span> |
Changes
Summary by CodeRabbit