Skip to content

Commit 7f53912

Browse files
author
Itamar Junior
committed
Add company details view and refactor company actions menu
1 parent 35ef83e commit 7f53912

File tree

3 files changed

+155
-6
lines changed

3 files changed

+155
-6
lines changed

app/Livewire/Company/Company.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Support\Facades\Auth;
1010
use App\Jobs\CompanyFetchCroSubmissions;
1111
use App\Models\Company as ModelsCompany;
12+
use Illuminate\Database\Eloquent\Model;
1213

1314
class Company extends Component
1415
{
@@ -27,6 +28,9 @@ class Company extends Component
2728
public array $financialYearEnds = [];
2829
public array $lastAGMs = [];
2930

31+
public $companyDetailsModal = false;
32+
public ?ModelsCompany $viewingCompany = null;
33+
3034

3135
/**
3236
* Perform initialisation when the component is mounted.
@@ -232,6 +236,19 @@ public function toggleCroDocument(int $definitionId)
232236
$this->selectedCompany->load('croDocDefinitions');
233237
}
234238

239+
public function viewCompanyDetails(ModelsCompany $company)
240+
{
241+
abort_unless(
242+
Auth::user()->businesses()->where('business_id', $company->business_id)->exists(),
243+
403,
244+
'You do not have permission to view this company'
245+
);
246+
247+
$this->viewingCompany = $company;
248+
$this->companyDetailsModal = true;
249+
}
250+
251+
235252
public function render()
236253
{
237254
return view('livewire.company.company', [
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
@php
2+
$dateFields = [
3+
'Effective Date',
4+
'Registration Date',
5+
'Last Annual Return',
6+
'Next Annual Return',
7+
'Next Financial Statement Due',
8+
'Last Accounts',
9+
'Last AGM',
10+
'Financial Year End',
11+
];
12+
13+
$details = [
14+
'Company Number' => $company->company_number,
15+
'Custom Name' => $company->custom,
16+
'Company Type' => $company->company_type_code . ' | ' . $company->company_type,
17+
'Status' => $company->status,
18+
'Status Code' => $company->company_status_code,
19+
'Effective Date' => $company->effective_date,
20+
'Registration Date' => $company->registration_date,
21+
'Last Annual Return' => $company->last_annual_return,
22+
'Next Annual Return' => $company->next_annual_return,
23+
'Next Financial Statement Due' => $company->next_financial_statement_due,
24+
'Last Accounts' => $company->last_accounts,
25+
'Last AGM' => $company->last_agm,
26+
'Financial Year End' => $company->financial_year_end,
27+
'Place of Business' => $company->place_of_business,
28+
'Address' => $company->postcode . ' | ' . $company->address_line_1 . ' , ' . $company->address_line_2,
29+
'Address Line 3' => $company->address_line_3,
30+
'Address Line 4' => $company->address_line_4,
31+
];
32+
@endphp
33+
34+
<div>
35+
<div class="px-4 sm:px-0">
36+
<h3 class="text-base/7 font-semibold text-gray-900">{{ $company->name }}</h3>
37+
<p class="mt-1 max-w-2xl text-sm/6 text-gray-500">Company details.</p>
38+
</div>
39+
<div class="mt-6 border-t border-gray-100">
40+
41+
<dl class="divide-y divide-gray-100">
42+
43+
44+
@foreach ($details as $label => $value)
45+
@if (!empty($value))
46+
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
47+
<dt class="text-sm/6 font-medium text-gray-900">{{ $label }}</dt>
48+
<dd class="mt-1 text-sm/6 text-gray-700 sm:col-span-2 sm:mt-0">
49+
@if (in_array($label, $dateFields))
50+
{{ \Carbon\Carbon::parse($value)->format('Y-m-d') }}
51+
@else
52+
{{ $value }}
53+
@endif
54+
</dd>
55+
</div>
56+
@endif
57+
@endforeach
58+
</dl>
59+
60+
<dl class="divide-y divide-gray-100">
61+
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
62+
<dt class="text-sm/6 font-medium text-gray-900">Attachments</dt>
63+
<dd class="mt-2 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
64+
<ul role="list" class="divide-y divide-gray-100 rounded-md border border-gray-200">
65+
{{-- <li class="flex items-center justify-between py-4 pl-4 pr-5 text-sm/6">
66+
<div class="flex w-0 flex-1 items-center">
67+
<svg class="size-5 shrink-0 text-gray-400" viewBox="0 0 20 20" fill="currentColor"
68+
aria-hidden="true" data-slot="icon">
69+
<path fill-rule="evenodd"
70+
d="M15.621 4.379a3 3 0 0 0-4.242 0l-7 7a3 3 0 0 0 4.241 4.243h.001l.497-.5a.75.75 0 0 1 1.064 1.057l-.498.501-.002.002a4.5 4.5 0 0 1-6.364-6.364l7-7a4.5 4.5 0 0 1 6.368 6.36l-3.455 3.553A2.625 2.625 0 1 1 9.52 9.52l3.45-3.451a.75.75 0 1 1 1.061 1.06l-3.45 3.451a1.125 1.125 0 0 0 1.587 1.595l3.454-3.553a3 3 0 0 0 0-4.242Z"
71+
clip-rule="evenodd" />
72+
</svg>
73+
<div class="ml-4 flex min-w-0 flex-1 gap-2">
74+
<span class="truncate font-medium">resume_back_end_developer.pdf</span>
75+
<span class="shrink-0 text-gray-400">2.4mb</span>
76+
</div>
77+
</div>
78+
<div class="ml-4 shrink-0">
79+
<a href="#"
80+
class="font-medium text-indigo-600 hover:text-indigo-500">Download</a>
81+
</div>
82+
</li>
83+
<li class="flex items-center justify-between py-4 pl-4 pr-5 text-sm/6">
84+
<div class="flex w-0 flex-1 items-center">
85+
<svg class="size-5 shrink-0 text-gray-400" viewBox="0 0 20 20" fill="currentColor"
86+
aria-hidden="true" data-slot="icon">
87+
<path fill-rule="evenodd"
88+
d="M15.621 4.379a3 3 0 0 0-4.242 0l-7 7a3 3 0 0 0 4.241 4.243h.001l.497-.5a.75.75 0 0 1 1.064 1.057l-.498.501-.002.002a4.5 4.5 0 0 1-6.364-6.364l7-7a4.5 4.5 0 0 1 6.368 6.36l-3.455 3.553A2.625 2.625 0 1 1 9.52 9.52l3.45-3.451a.75.75 0 1 1 1.061 1.06l-3.45 3.451a1.125 1.125 0 0 0 1.587 1.595l3.454-3.553a3 3 0 0 0 0-4.242Z"
89+
clip-rule="evenodd" />
90+
</svg>
91+
<div class="ml-4 flex min-w-0 flex-1 gap-2">
92+
<span class="truncate font-medium">coverletter_back_end_developer.pdf</span>
93+
<span class="shrink-0 text-gray-400">4.5mb</span>
94+
</div>
95+
</div>
96+
<div class="ml-4 shrink-0">
97+
<a href="#"
98+
class="font-medium text-indigo-600 hover:text-indigo-500">Download</a>
99+
</div>
100+
</li> --}}
101+
</ul>
102+
</dd>
103+
</div>
104+
</dl>
105+
106+
<dl class="divide-y divide-gray-100">
107+
<div class="px-4 py-6 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
108+
<dt class="text-sm/6 font-medium text-gray-900">Actions</dt>
109+
<dd class="mt-2 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
110+
<div class="flex flex-col gap-2 text-right">
111+
<flux:button wire:click="$set('companyDetailsModal', false)"
112+
wire:keydown.escape.window="$set('companyDetailsModal', false)">
113+
Close
114+
</flux:button>
115+
</div>
116+
</dd>
117+
</div>
118+
</dl>
119+
120+
</div>
121+
</div>

resources/views/livewire/company/company.blade.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class="absolute left-1/2 top-full mt-2 -translate-x-1/2 z-50 w-[200px] rounded-l
316316
</span>
317317
</td>
318318
<td class="px-6 py-1.5 flex items-center">
319-
<div wire:click="showCompanySubmissions({{ $company->id }})">
319+
{{-- <div wire:click="showCompanySubmissions({{ $company->id }})">
320320
<div
321321
class="relative inline-flex items-center p-3 text-sm font-medium text-center">
322322
<svg xmlns="http://www.w3.org/2000/svg" fill="none"
@@ -331,7 +331,7 @@ class="absolute inline-flex items-center justify-center size-6 text-xs font-bold
331331
{{ $company->submissionDocuments->count() }}
332332
</div>
333333
</div>
334-
</div>
334+
</div> --}}
335335
@if ($company->croDocDefinitions->count() > 0)
336336
<div class="relative inline-flex items-center p-3 text-sm font-medium text-center"
337337
wire:click="showCroDefinition({{ $company->id }})">
@@ -374,8 +374,14 @@ class="block py-2 px-4 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-
374374
</li>
375375
</ul> --}}
376376
<div class="py-1">
377-
<a href="#"
378-
class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white cursor-not-allowed">Delete</a>
377+
<div wire:click="viewCompanyDetails({{ $company->id }})"
378+
class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white cursor-pointer">
379+
View</div>
380+
</div>
381+
<div class="py-1">
382+
<div
383+
class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white cursor-not-allowed">
384+
Delete</div>
379385
</div>
380386
</div>
381387
</div>
@@ -384,7 +390,7 @@ class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gra
384390
@endforeach
385391
</tbody>
386392
</table>
387-
@if ($selectedCompany)
393+
{{-- @if ($selectedCompany)
388394
<x-ui.modal wire:model="showDetailsModal" maxWidth="7xl">
389395
<div class="mb-4">
390396
<h2 class="text-lg font-semibold text-gray-800 dark:text-white">
@@ -429,7 +435,7 @@ class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gra
429435
</flux:button>
430436
</div>
431437
</x-ui.modal>
432-
@endif
438+
@endif --}}
433439
@if ($showCroDefinitionsModal)
434440
<x-ui.modal wire:model="showCroDefinitionsModal" maxWidth="7xl">
435441
<div class="mb-4">
@@ -493,6 +499,11 @@ class="px-3 py-1 rounded-full text-sm
493499
</div>
494500
</x-ui.modal>
495501
@endif
502+
@if ($viewingCompany)
503+
<x-ui.modal wire:model="companyDetailsModal" maxWidth="7xl">
504+
<x-company.company-details :company="$viewingCompany" />
505+
</x-ui.modal>
506+
@endif
496507
</div>
497508
<div class="p-4">
498509
{{ $companies->links() }}

0 commit comments

Comments
 (0)