Skip to content
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

feat(contract): add javascript validation #148

Merged
merged 21 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8871f90
feat (contract): Validation Contracts
Chuck-D-Norris Nov 28, 2024
8fc2b54
Merge branch 'main' into feat/contract
0x1026 Nov 28, 2024
c6e4e74
fix: .env won't be uploaded
0x1026 Nov 28, 2024
97d9930
Merge branch 'main' into feat/contract
0x1026 Dec 2, 2024
7ffbd0a
Jacascript
Chuck-D-Norris Dec 3, 2024
0e6ceae
Merge branch 'main' into feat/contract
Chuck-D-Norris Dec 3, 2024
d7f4c58
Merge branch 'main' into feat/contract
0x1026 Dec 3, 2024
e8b039c
Merge branch 'feat/contract' of https://github.com/Projecte-UrbanTree…
Chuck-D-Norris Dec 3, 2024
723b94f
Solution conflicts
Chuck-D-Norris Dec 3, 2024
bfbd965
Merge branch 'main' into feat/contract
0x1026 Dec 3, 2024
becf1cb
Merge remote-tracking branch 'origin/main' into feat/contract
0x1026 Dec 3, 2024
31093b9
Merge branch 'main' into feat/contract
0x1026 Dec 4, 2024
7a6d833
Merge branch 'main' into feat/contract
0x1026 Dec 4, 2024
b628285
Merge branch 'main' into feat/contract
projecte-urbantree-bot Dec 4, 2024
2de3850
Merge branch 'main' into feat/contract
0x1026 Dec 9, 2024
54219be
fix(database): change contract date fields from timestamp to date
0x1026 Dec 10, 2024
c007953
refactor(contract): update form structure and validation, remove obso…
0x1026 Dec 10, 2024
ca66f9f
refactor(tree-type): rename form IDs for consistency
0x1026 Dec 10, 2024
ee04f10
fix(contract): add max attribute to invoice fields for validation
0x1026 Dec 10, 2024
14d83e2
refactor(validations): improve validations for both contract and tree…
0x1026 Dec 10, 2024
b06d149
Merge branch 'main' into feat/contract
0x1026 Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions app/src/app/Views/Admin/Contract/Create.php
Original file line number Diff line number Diff line change
@@ -1,71 +1,65 @@
<div class="mb-4 flex justify-end">
<a href="/contracts"
<a href="/admin/contracts"

Check warning on line 2 in app/src/app/Views/Admin/Contract/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Create.php#L2

Added line #L2 was not covered by tests
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg shadow focus:outline-none focus:ring focus:ring-green-500 flex items-center space-x-2">
<!-- Heroicon for return/back (chevron-left) -->
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
</svg>
<span>Return to Contract</span>
<span>Return to Contracts</span>

Check warning on line 7 in app/src/app/Views/Admin/Contract/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Create.php#L7

Added line #L7 was not covered by tests
</a>
</div>

<div class="bg-white p-8 border border-gray-300 rounded-lg shadow-md">
<h2 class="text-2xl font-semibold text-gray-800 mb-6">Create Contract</h2>
<form action="/contract/store" method="POST" class="space-y-6">
<!-- Name -->

<form id="contractForm" action="/admin/contract/store" method="POST" class="space-y-6">
<div id="errorMessages"
class="hidden bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-6"></div>

Check warning on line 16 in app/src/app/Views/Admin/Contract/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Create.php#L14-L16

Added lines #L14 - L16 were not covered by tests

<div>
<label for="name" class="block text-sm font-medium text-gray-700 mb-1">Name</label>
<input type="text" id="name" name="name"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500"
required>
</div>

<!-- Start Date -->
<div>
<label for="start_date" class="block text-sm font-medium text-gray-700 mb-1">Start Date</label>
<input type="date" id="start_date" name="start_date"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500"
required>
</div>

<!-- End Date -->
<div>
<label for="end_date" class="block text-sm font-medium text-gray-700 mb-1">End Date</label>
<input type="date" id="end_date" name="end_date"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500"
required>
</div>

<!-- Invoice Proposed -->
<div>
<label for="invoice_proposed" class="block text-sm font-medium text-gray-700 mb-1">Invoice Proposed</label>
<input type="number" step="0.01" id="invoice_proposed" name="invoice_proposed"
<input type="number" step="0.01" id="invoice_proposed" name="invoice_proposed" max="999999999.99"

Check warning on line 41 in app/src/app/Views/Admin/Contract/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Create.php#L41

Added line #L41 was not covered by tests
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500"
required>
</div>

<!-- Invoice Agreed -->
<div>
<label for="invoice_agreed" class="block text-sm font-medium text-gray-700 mb-1">Invoice agreed</label>
<input type="number" id="invoice_agreed" name="invoice_agreed"
<label for="invoice_agreed" class="block text-sm font-medium text-gray-700 mb-1">Invoice Agreed</label>
<input type="number" id="invoice_agreed" name="invoice_agreed" max="999999999.99"

Check warning on line 48 in app/src/app/Views/Admin/Contract/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Create.php#L47-L48

Added lines #L47 - L48 were not covered by tests
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500"
required>
</div>

<!-- Invoice Paid -->
<div>
<label for="invoice_paid" class="block text-sm font-medium text-gray-700 mb-1">Invoice paid</label>
<input type="number" id="invoice_paid" name="invoice_paid"
<label for="invoice_paid" class="block text-sm font-medium text-gray-700 mb-1">Invoice Paid</label>
<input type="number" id="invoice_paid" name="invoice_paid" max="999999999.99"

Check warning on line 55 in app/src/app/Views/Admin/Contract/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Create.php#L54-L55

Added lines #L54 - L55 were not covered by tests
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500"
required>
</div>

<!-- Submit Button -->
<div class="flex items-center">
<button type="submit"
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500">
Create Contract
</button>
</div>
<button type="submit"
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500">
Create Contract
</button>

Check warning on line 63 in app/src/app/Views/Admin/Contract/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Create.php#L60-L63

Added lines #L60 - L63 were not covered by tests
</form>
</div>
</div>

Check warning on line 65 in app/src/app/Views/Admin/Contract/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Create.php#L65

Added line #L65 was not covered by tests
35 changes: 15 additions & 20 deletions app/src/app/Views/Admin/Contract/Edit.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div class="mb-4 flex justify-end">
<a href="/contracts"
<a href="/admin/contracts"

Check warning on line 2 in app/src/app/Views/Admin/Contract/Edit.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Edit.php#L2

Added line #L2 was not covered by tests
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg shadow focus:outline-none focus:ring focus:ring-green-500 flex items-center space-x-2">
<!-- Heroicon for return/back (chevron-left) -->
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
</svg>
Expand All @@ -11,60 +10,56 @@

<div class="bg-white p-8 border border-gray-300 rounded-lg shadow-md">
<h2 class="text-2xl font-semibold text-gray-800 mb-6">Edit Contract</h2>
<form action="/contract/<?php echo htmlspecialchars($contract->getId()); ?>/update" method="POST" class="space-y-6">
<!-- Name -->

<form id="contractForm" action="/admin/contract/<?php echo htmlspecialchars($contract->getId()); ?>/update"

Check warning on line 14 in app/src/app/Views/Admin/Contract/Edit.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Edit.php#L14

Added line #L14 was not covered by tests
method="POST" class="space-y-6">
<div id="errorMessages"
class="hidden bg-red-100 border border-red-400 text-red700 px-4 py-3 rounded relative mb-6"></div>

<div>
<label for="name" class="block text-sm font-medium text-gray-700 mb-1">Name</label>
<input type="text" id="name" name="name" value="<?php echo htmlspecialchars($contract->name); ?>"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500">
</div>

<!-- Start Date -->
<div>
<label for="start_date" class="block text-sm font-medium text-gray-700 mb-1">Start Date</label>
<input type="date" id="start_date" name="start_date"
value="<?php echo htmlspecialchars($contract->start_date); ?>"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500">
</div>

<!-- End Date -->
<div>
<label for="end_date" class="block text-sm font-medium text-gray-700 mb-1">End Date</label>
<input type="date" id="end_date" name="end_date"
value="<?php echo htmlspecialchars($contract->end_date); ?>"
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500">
</div>

<!-- Invoice Proposed -->
<div>
<label for="invoice_proposed" class="block text-sm font-medium text-gray-700 mb-1">Invoice Proposed</label>
<input type="number" step="0.01" id="invoice_proposed" name="invoice_proposed"
value="<?php echo htmlspecialchars($contract->invoice_proposed); ?>"
value="<?php echo htmlspecialchars($contract->invoice_proposed); ?>" max="999999999.99"

Check warning on line 42 in app/src/app/Views/Admin/Contract/Edit.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Edit.php#L42

Added line #L42 was not covered by tests
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500">
</div>

<!-- Invoice Agreed -->
<div>
<label for="invoice_agreed" class="block text-sm font-medium text-gray-700 mb-1">Invoice Agreed</label>
<input type="number" step="0.01" id="invoice_agreed" name="invoice_agreed"
value="<?php echo htmlspecialchars($contract->invoice_agreed); ?>"
value="<?php echo htmlspecialchars($contract->invoice_agreed); ?>" max="999999999.99"

Check warning on line 49 in app/src/app/Views/Admin/Contract/Edit.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Edit.php#L49

Added line #L49 was not covered by tests
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500">
</div>

<!-- Invoice Paid -->
<div>
<label for="invoice_paid" class="block text-sm font-medium text-gray-700 mb-1">Invoice Paid</label>
<input type="number" step="0.01" id="invoice_paid" name="invoice_paid"
value="<?php echo htmlspecialchars($contract->invoice_paid); ?>"
value="<?php echo htmlspecialchars($contract->invoice_paid); ?>" max="999999999.99"

Check warning on line 56 in app/src/app/Views/Admin/Contract/Edit.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contract/Edit.php#L56

Added line #L56 was not covered by tests
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring focus:ring-blue-500 focus:border-blue-500">
</div>

<!-- Submit Button -->
<div class="flex items-center">
<button type="submit"
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500">
Update Contract
</button>
</div>
<button type="submit"
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500">
Update Contract
</button>
</form>
</div>
</div>
6 changes: 3 additions & 3 deletions app/src/app/Views/Admin/Contracts.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<?php } ?>

<div class="mb-4 flex justify-end">
<a href="/contract/create"
<a href="/admin/contract/create"

Check warning on line 15 in app/src/app/Views/Admin/Contracts.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contracts.php#L15

Added line #L15 was not covered by tests
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg shadow focus:outline-none focus:ring focus:ring-green-500">
Create Contract
</a>
Expand Down Expand Up @@ -63,7 +63,7 @@
</td>
<td class="px-4 py-3 border-b text-center flex justify-center space-x-4">
<!-- Edit Button (Pencil Icon) -->
<a href="/contract/<?php echo htmlspecialchars($contract->getId()); ?>/edit"
<a href="/admin/contract/<?php echo htmlspecialchars($contract->getId()); ?>/edit"

Check warning on line 66 in app/src/app/Views/Admin/Contracts.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contracts.php#L66

Added line #L66 was not covered by tests
class="text-blue-500 hover:text-blue-700" title="Edit">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5">
Expand All @@ -72,7 +72,7 @@
</svg>
</a>
<!-- Delete Button (Trash Icon) -->
<a href="/contract/<?php echo htmlspecialchars($contract->getId()); ?>/delete"
<a href="/admin/contract/<?php echo htmlspecialchars($contract->getId()); ?>/delete"

Check warning on line 75 in app/src/app/Views/Admin/Contracts.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Contracts.php#L75

Added line #L75 was not covered by tests
onclick="return confirm('Are you sure you want to delete this contract?');"
class="text-red-500 hover:text-red-700" title="Delete">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
Expand Down
14 changes: 6 additions & 8 deletions app/src/app/Views/Admin/TreeType/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="bg-white p-8 border border-gray-300 rounded-lg shadow-md">
<h2 class="text-2xl font-semibold text-gray-800 mb-6">Create Tree Type</h2>

<form id="treeForm" action="/admin/tree-type/store" method="POST" class="space-y-6">
<form id="treeTypeForm" action="/admin/tree-type/store" method="POST" class="space-y-6">

Check warning on line 15 in app/src/app/Views/Admin/TreeType/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/TreeType/Create.php#L15

Added line #L15 was not covered by tests
<div id="errorMessages"
class="hidden bg-red-100 border border-red-400 text-red700 px-4 py-3 rounded relative mb-6"></div>

Expand Down Expand Up @@ -41,11 +41,9 @@
</div>

<!-- Submit Button -->
<div class="flex items-center">
<button type="submit"
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500">
Create Tree Type
</button>
</div>
<button type="submit"
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500">
Create Tree Type
</button>

Check warning on line 47 in app/src/app/Views/Admin/TreeType/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/TreeType/Create.php#L44-L47

Added lines #L44 - L47 were not covered by tests
</form>
</div>
</div>

Check warning on line 49 in app/src/app/Views/Admin/TreeType/Create.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/TreeType/Create.php#L49

Added line #L49 was not covered by tests
15 changes: 7 additions & 8 deletions app/src/app/Views/Admin/TreeType/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

<div class="bg-white p-8 border border-gray-300 rounded-lg shadow-md">
<h2 class="text-2xl font-semibold text-gray-800 mb-6">Edit Tree Type</h2>
<form id="treeForm" action="/admin/tree-type/<?php echo htmlspecialchars($tree_type->getId()); ?>/update"

<form id="treeTypeForm" action="/admin/tree-type/<?php echo htmlspecialchars($tree_type->getId()); ?>/update"

Check warning on line 15 in app/src/app/Views/Admin/TreeType/Edit.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/TreeType/Edit.php#L15

Added line #L15 was not covered by tests
method="POST" class="space-y-6">
<div id="errorMessages"
class="hidden bg-red-100 border border-red-400 text-red700 px-4 py-3 rounded relative mb-6"></div>
Expand Down Expand Up @@ -39,11 +40,9 @@


<!-- Submit Button -->
<div class="flex items-center">
<button type="submit"
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500">
Update Tree Type
</button>
</div>
<button type="submit"
class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg focus:outline-none focus:ring focus:ring-blue-500">
Update Tree Type
</button>
</form>
</div>
</div>
Loading
Loading