Skip to content

Commit

Permalink
#443 - fix: fixes after code review - fixed validation and edit view
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilpiech97 committed Jun 26, 2024
1 parent 1e8b1f6 commit f283321
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Http/Requests/UserHistoryRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function rules(): array
{
return [
"from" => ["required", "date"],
"to" => ["date", "after:from"],
"to" => ["nullable", "date", "after:from", "required_if:type," . UserHistoryType::MedicalExam->value . "," . UserHistoryType::OhsTraining->value],
"comment" => ["nullable", "string", "max:255"],
"type" => ["required", new Enum(UserHistoryType::class)],
"employmentForm" => [new Enum(EmploymentForm::class), "required_if:type," . UserHistoryType::Employment->value],
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public function toArray($request): array
"lastActiveAt" => $this->last_active_at?->toDateTimeString(),
"employmentForm" => $this->profile->employment_form->label(),
"employmentDate" => $this->profile->employment_date->toDisplayString(),
"lastMedicalExamDate" => $lastMedicalExam?->from->toDisplayString(),
"nextMedicalExamDate" => $lastMedicalExam?->to->toDisplayString(),
"lastOhsTrainingDate" => $lastOhsTraining?->from->toDisplayString(),
"nextOhsTrainingDate" => $lastOhsTraining?->to->toDisplayString(),
"lastMedicalExamDate" => $lastMedicalExam?->from?->toDisplayString(),
"nextMedicalExamDate" => $lastMedicalExam?->to?->toDisplayString(),
"lastOhsTrainingDate" => $lastOhsTraining?->from?->toDisplayString(),
"nextOhsTrainingDate" => $lastOhsTraining?->to?->toDisplayString(),
];
}
}
3 changes: 3 additions & 0 deletions lang/pl/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@
"employmentForm" => [
"required_if" => "Forma zatrudnienia jest wymagana.",
],
"to" => [
"required_if" => "Data zakończenia jest wymagana.",
],
],
"attributes" => [
"to" => "do",
Expand Down
1 change: 1 addition & 0 deletions resources/js/Pages/UserHistory/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function createForm() {
Dodaj wpis
</h2>
</div>
{{ form }}
<form
class="px-6 h-full border-t border-gray-200"
@submit.prevent="createForm"
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Pages/UserHistory/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const form = useForm({
to: props.history.to,
comment: props.history.comment,
type: props.types.find(type => type.value === props.history.type),
employmentForm: props.employmentForms.find(employmentForm => employmentForm.value === props.history.employmentForm),
employmentForm: props.employmentForms.find(employmentForm => employmentForm.value === props.history.employmentForm) ?? '',
})
function updateForm() {
Expand Down Expand Up @@ -154,7 +154,7 @@ function updateForm() {
v-for="employmentForm in employmentForms"
:key="employmentForm.value"
v-slot="{ active, selected }"
:value="form"
:value="employmentForm"
as="template"
>
<li :class="[active ? 'bg-gray-100' : 'text-gray-900', 'cursor-default select-none relative py-2 pl-3 pr-9']">
Expand Down

0 comments on commit f283321

Please sign in to comment.